Best practice for onHandler to fire only one tag

Silver Contributor
Silver Contributor
I'm triggering a number of events using jQuery onHandler events. On a few of these events, I want to fire only one tag instead of all tags, and I'm trying to identify the best way to do this. One option I can think of would be to have the extensions that should fire only one tag to populate a UDO variable (only_tag=dart for example), then use load rules on my other tags to fire only when only_tag!=dart. This makes for undesirably complex load rules that require adjustment whenever I add a new configuration, though. Another option would be to use custom JavaScript instead of a tracking type of 'link', and fire utag.link manually so that I can specify which tag to fire. This adds the complexity of having custom JavaScript, but at least contains the configuration to the extension(s) in question. Ideally, the onHandler would have a dropdown box that would let me limit which tags would fire, just like utag.view and utag.link do, but that feature doesn't seem to be present. Is there another option I'm missing? Any other factors I should consider when making my decision? Has anyone else implemented something like this and run into any gotcha moments?
6 REPLIES 6

Best practice for onHandler to fire only one tag

Employee Emeritus
Wes Thank you for your question. The best way to do this is with the custom JavaScript option you have listed. utag.view(data_object_to_be_used_in_track_call, null, array_of_ids_to_fire); If you are using utag version 4.38 or greater, you can also call utag.link with an array of ids. utag.link(data_object_to_be_used_in_track_call, null, array_of_ids_to_fire); To find out what version of utag you are running, bring up your webpage and in the console run this command: utag.cfg.v;

Best practice for onHandler to fire only one tag

Silver Contributor
Silver Contributor
Looks like I'm stuck on 4.33 for the moment, and upgrading would break some other functionality that we don't have resources to update at the moment. If it doesn't support doing that with utag.link, I've got to find another solution. Are load rules evaluated after extensions scoped to all tags? If so, it occurs to me that I could use a single extension to set a UDO variable for each tag, and set a load rule for each tag to fire only when that variable is set. Then when I want to disable one tag, I can change the variable value, knowing that it'll still be enabled again for the next event to fire. Would that work?

Best practice for onHandler to fire only one tag

Employee Emeritus
Wes I got feedback that my first response was unclear. So I am adding an image as part of my first response. After that I will address your second comment.

Best practice for onHandler to fire only one tag

Silver Contributor
Silver Contributor
I followed your first response just fine. :)

Best practice for onHandler to fire only one tag

Gold Contributor
Gold Contributor
Hi Wes " set a load rule for each tag to fire only when that variable is set. " Your way would work, I did that too. I had the same problem and did it the same way.

Best practice for onHandler to fire only one tag

Employee Emeritus
Wes I got pulled away yesterday and was not able to get back to this conversation until just now. Looks like Samrat beat me to it. Let me know if his solution does not work and we can try to address in more detail.
Public