如何跟踪已经讨论过该问题的<a> tag with span class inside using Google Tag Manager?

时间:2017-06-16 13:59:43

标签: html css google-tag-manager

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!

2 个答案:

答案 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添加到您的页面,这应该适合您