Highlighted

Is there a possibility to set up a dependency on a Tag?

Bronze Contributor
Bronze Contributor

Hi There

 

I want to make sure a specific Tag only gets executed after another Tag already is.

 

Greetings

2 REPLIES 2
Highlighted

Is there a possibility to set up a dependency on a Tag?

Tealium Employee

Hi @kay_lehmann,

 

Good to see you active on the community :-)

There isn't a built-in feature to do this, but you can achieve it by using a JavaScript extension.

Example scenario: you want to fire a tag (UID 23 in IQ) first and then fire another one (UID 49) when this has completed.

Steps:

 

1. Create a JS extension scoped to tag 23 with the following contents:

 

window.utag_post_send_q = window.utag_post_send_q || [];
window.utag_post_send_q.push({event:a, data:b, uids:['49']});

2. Create a second JS extension scoped to "All Tags", but change the execution order drop-down to "After Tags". This will then run after all tags have completed. The contents of this extension should be:

 

// declared for later use
var evt_obj;
// take items from the front of the queue and fire a utag.track call for each one
while (evt_obj = window.utag_post_send_q.shift()) {
// utag.track accepts: event type (view/link), data object, object containing: callback function (null if not required), array of tag UIDs 
utag.track(evt_obj.event, evt_obj.data, {cb:null, uids:evt_obj.uids});
}

Now, tag #23 will run when the page loads, and as soon as all tags have finished sending, tag #49 will load, with the data that was originally passed to tag #23.

 

Please be aware that this solution is untested, but it should work. It's recommended to have the latest utag version to use this, but v4.36 is the minimum.

Check out our new Swift integration library for iOS, macOS, tvOS and watchOS: https://github.com/Tealium/tealium-swift with updated
documentation https://community.tealiumiq.com/t5/Swift/tkb-p/swift.
Highlighted

Is there a possibility to set up a dependency on a Tag?

Bronze Contributor
Bronze Contributor
Thank you very much.

copy'n'paste and after updating the utag.loader the code worked as intended!

Greetings