Highlighted

How can I trigger a tag on a link click, based on link tag ID?

Silver Contributor
Silver Contributor

Hello Devs & Devas,

How can I trigger a tag on a link click, based on link tag ID?
Haven't found an answer to this very basic problem anywhere.

A load rule specifying these 2:

  • click_element_id
  • pathname

doesn't work. Any help SO MUCH APPRECIATED.

Thanks,
Flo

1 REPLY 1
Highlighted

How can I trigger a tag on a link click, based on link tag ID?

Tealium Employee

@florian_perl

 

If I understand you correctly, you're trying to perform link tracking, and you want to target an HTML element on a specific URL. Is that correct?

 

If so, you'll need to leverage the jQuery extension to complete this. The first step is to declare the HTML element to listen to, and you can read about how to do that at the following two links:
1) https://community.tealiumiq.com/t5/Browser-utag-js/Event-Tracking-Options-with-utag-link/ta-p/15588#...
2) https://community.tealiumiq.com/t5/Tealium-iQ-Tag-Management/jQuery-onHandler-Extension-jQuery-v1-7-...

 

The second step is to apply a "condition" to the extenion that determines on which page(s) it should run.

 

The result will be an extension that will trigger a utag.link based on your requirements, and pass any data that you've mapped in the extension. Remember that utag.link will cause all tags that are link track enabled to be fired.

 

If you need to trigger only a single tag, you'll need to change the Tracking Event type to "Custom" and manually make the utag.link call. You can do so following this example, being sure to change [1,2] to the Tag UID of you vendor.
utag.link({ "event_name":"cart_add", "product_id":["12345"], "product_name":["Lucky Shirt"] }, null, [1,2]);
So if your vendor Tag UID is 103 you'd trigger:
utag.link({ "event_name":"cart_add", "product_id":["12345"], "product_name":["Lucky Shirt"] }, null, [103]);

 

Cheers,
-Dan