How to stop tag firing multiple time on same page

Bronze Contributor
Bronze Contributor

I have tags wich fires on load of certain pages load but it is firing again when i call method utag.view({...}), but i wanted to fire this tag only once on the page, anyone please help

1 REPLY 1

How to stop tag firing multiple time on same page

Tealium Employee

The best way to prevent a tag from firing would be to adjust the loadrules to only be met for specific events.
Typically you would only have a "view" event fire once per page, there are some exceptions - but it may be worth confirming if you want to be using "utag.view" instead of "utag.link"

If the event data being sent for both of your view events is identical - and there isn't and easy way to be able to identify whether this is the second event on the page or not - You could look to add some functionality in one of a few places

 

  • Tag Template - Some of our tags already have this functionality built in - lots of them will make use of a "u.initialised" flag which you can use. This would involve modifying the template though, which many people prefer to avoid.

 

  • Extension / Loadrule update
    Add this code to a javascript extension which is scoped to the tag.
    utag.data.has_xxx_fired = true;
    Then add this code to a JavaScript Extension scoped to "Before Load Rules"
    b.has_xxx_fired = utag.data.has_xxx_fired || false;

    Then add this condition to a loadrule
    has_xxx_fired is not equal to true


You can change out the variable name "has_xxx_fired" with anything you like!
When the tag fires for the first time, we set has_xxx_fired in utag.data, which we then read on subsequent events, and we dont let the tag fire a second time.


Those options are a bit more work - And it would be easier if you already have something in your event to play from though. 

Public