I've been trying to get GTM to fire a tag every time a user clicks on the link text below ("Click here to donate").
<a href="https://www.testurl.com/donate" target="_blank" >
<span class="donate"><img src="donate-icon.png"></span>
Click here to donate! </a>
I'm able to get the tag to fire when users click on the image by using trigger with the following settings below. But I can't get the tag to fire when users click on the link text.
Trigger type: Click - All Elements
Trigger fires on: Some Clicks
Click Element --> matches CSS selector --> .donate
*Note: I'm unable to insert any CSS into the A tag directly due to the site template not being directly controlled by me. I could make a request but it would take weeks if not longer to get the necessary approvals and work done.
Any suggestions are greatly appreciated! Thank you!
答案 0 :(得分:3)
您可以使用Click URL
代替Click Element
尝试以下设置:
https://www.testurl.com/donate
或其他解决办法可能是:
Click here to donate!
解决方案基于: https://support.google.com/tagmanager/answer/6106961?hl=en#Click
另一种可能性是使用触发器类型Click - Just Links
:
https://www.testurl.com/donate
如果您没有文字或网址,该怎么办?
在这种情况下,您可以跟踪具有特定class
属性的元素:
toggle-sidebar
(或更具体的课程)答案 1 :(得分:-1)
是的,您可以使用jquery添加css类 .addClass(&#39;捐赠&#39)
如果您可以将JS添加到您的页面,这应该适合您