How do I use Tealium's error handler?

Gold Contributor
Gold Contributor

https://community.tealiumiq.com/t5/JavaScript-utag-js/utag-js-version-4-40-through-4-44-Release-Note... says that Tealium has improved or changed its error handler.

 

Now I would like to use that error Handler to push Tealium script errors to our error reporting tool. 

However I don't know how I am supposed to apply this, e.g. in an Extension.

 

The docs say:

 

"Adds support for error handler function passed into utag.ut.loader utility function.  This is only for modern browsers (older browser will likely call the standard callback "cb" function instead -- at least that's what I saw on IE7 and IE8)"

utag.ut.loader({ "src" : "https://tealium.com/test/testing1.js", "cb" : function(){console.log("CALLBACK")}, "error" : function(){console.log("ERROR IN LOADING")} } );
2 REPLIES 2

How do I use Tealium's error handler?

Tealium Employee

Hi @loldenburg

 

So I think you might have gotten slightly confused between the different error handlings we have.

 

The error handling you are referring to in your post is with regards to using the utag.ut.loader to load a script/iframe/img and detecting if the file failed to load.

 

The other option we did have is in the publish settings Alert Error Notification (https://community.tealiumiq.com/t5/iQ-Tag-Management/Publish-Configuration/ta-p/13632). This is now deprecated, however, you could add the logic into the template and send your own requests with the data.

 

if (typeof utag_err == 'undefined') var utag_err = [];
window._tealium_old_error = window._tealium_old_error || window.onerror || function() {};
window.onerror = function(m, u, l) {
  if (typeof u !== 'undefined' && u.indexOf('/utag.') > 0 && utag_err.length < 5) {
utag_err.push({     e: m,     s: u,     l: l,     t: 'js'   });
}   window._tealium_old_error(m, u, l) };

 

So this tracks any errors that originate in the utag file domain. You might have issues with only seeing script error in the message though. I would recommend reading this : https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror#Notes

 

Adrian 

Ask me anything Tealium related or TypeScript/JavaScript, or NodeJS.
Please remember to mark solutions as accepted for future searchers.

How do I use Tealium's error handler?

Gold Contributor
Gold Contributor

Thanks, @adrian_browning!

Public