Hi Roberto,
You could try the following:
{code:javascript}
(function (a, b, c, d) {
a = '//tags.tiqcdn.com/utag/monclick/qa/ita.desktop/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);
d.handlerFlag = 0;
d.onreadystatechange = function() {
if ((this.readyState === 'complete' || this.readyState === 'loaded') && !d.handlerFlag) {
d.handlerFlag = 1;
$(document).trigger('mkTealiumLoaded');
}
};
d.onload = function() {
if (!d.handlerFlag) {
d.handlerFlag = 1;
$(document).trigger('mkTealiumLoaded');
}
};
})();
{code}
Full disclosure: this code is "borrowed" from the Tealium Custom Container tag. It simply triggers your "mkTealiumLoaded" event when the browser determines that the script has finished loading (using the onreadystatechange or onload method, depending on browser support).
Another way would be to use a setTimeout loop to keep checking for the presence of the utag object, but I think this way is more elegant.
Craig.
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.