With the following code, you do not need to supress the utag.view call as you will not be calling utag.js until after all of your async files have been executed.
/*
A Tealium best practice is to only call utag.js after utag_data is available.
In this example we are building the utag_data dynamically based on data coming back
from many async calls to external javaScript files.
We do not want to call utag.js until all of the extenal async calls are complete.
To accomplish this we have an object called utagDataReady which we build up each
time a javascript file completes. Then we check if all the async calls are complete
and if they are then we load utag.js
The function tryToCallUtag is called after each async file processes.
This code has not been tested and has been written for example purposes only.
*/
function tryToCallUtag(methodName){
window.utagDataReady = window.utagDataReady || {};
utagDataReady[methodName] = true;
if(utagDataReady["someMethodName"] && utagDataReady["someMethodName2"] && utagDataReady["someMethodName3"]){
(function(a,b,c,d){
a='//tags.tiqcdn.com/utag/services-brian/main/prod/utag.js';
b=document;c='script';d=b.createElement(c);d.src=a;d.type='text/java'+c;d.async=true;
a=b.getElementsByTagName(c)[0];a.parentNode.insertBefore(d,a);
})();
}
}
//call first method and wait for data to come back then try to call utag.js
jQuery.getScript("http://deploytealium.com/training/library.js")
.done(function(script, textStatus) {
// script loaded, call the callback
tryToCallUtag("someMethodName");
})
.fail(function(jqxhr, settings, exception) {
// have some sort of fall back plan
console.log( "Something went wrong"+exception );
});
//call second method and wait for data to come back then try to call utag.js
jQuery.getScript("http://deploytealium.com/training/library.js")
.done(function(script, textStatus) {
// script loaded, call the callback
tryToCallUtag("someMethodName2");
})
.fail(function(jqxhr, settings, exception) {
// have some sort of fall back plan
console.log( "Something went wrong"+exception );
});
//call third method and wait for data to come back then try to call utag.js
jQuery.getScript("http://deploytealium.com/training/library.js")
.done(function(script, textStatus) {
// script loaded, call the callback
tryToCallUtag("someMethodName3");
})
.fail(function(jqxhr, settings, exception) {
// have some sort of fall back plan
console.log( "Something went wrong"+exception );
});
... View more