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!
You can try the following setup using Click URL
instead of Click Element
:
https://www.testurl.com/donate
or another solution could be:
Click here to donate!
solutions based on: https://support.google.com/tagmanager/answer/6106961?hl=en#Click
Another possiblity would be to use the trigger type Click - Just Links
:
https://www.testurl.com/donate
What if you have no text or URL?
In this case you can track an element with a specific class
attribute:
toggle-sidebar
(or a more specific class)