- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
10-13-2014
11:05 AM
- last edited on
06-22-2017
11:09 AM
by
TealiumJustin
I am looking for the best practice with Tealium. And also to find out if there is there a way to configure utag.js. Configure it in a manner to not take control over window.onerror and allow the client to implement utag.js's error handler? My code currently works as such:
// utag.js loads and updates window.onerror. // my scripts var oldOnError = window.onerror || function(){}; var myOnError = function ( errorMessage, url, lineNumber ) { // handle error for client reporting
}; // update window.onerror window.onerror = function ( ) { var args = Array.prototype.splice.call( arguments ); // run my error handler myOnError.apply( window, args ); // run previously set error handler oldOnError.apply( window, args ); };
But, I feel it would be good practice for utag.js to not take over window.onerror based on a configuration. The implementation could look like this:
window.utag_cfg_ovrd= { no_onerror: true }; window.onerror = function ( ) { var args = Array.prototype.splice.call( arguments ); // run my error handler myOnError.apply( window, args ); // run utag's onError handler utag.onError.apply( window, args ); };
Thanks, Drew
Solved! Go to Solution.
10-14-2014
02:09 AM
- last edited on
06-22-2017
11:05 AM
by
TealiumJustin
Hi Drew, The utag.js error tracking is added in when you have entered a email address into the "Alert Notify Email" under the Publish Configuration settings. If you wanted to remove the utag error tracking code, then removing this email address would be the way to go. With regards to the the code you have it isn't very dynamic in regards to other scripts appending to the window.onerror. What I would suggest is something more like:
var oldOnError = window.onerror || function(){}; var myOnError = function (errorMessage, url, lineNumber, colNumber) { // pass through to standard error handling oldOnError(errorMessage, url, lineNumber, colNumber); // custom error handling here... }; window.onerror = myOnError;
Hope this helps, Adrian
10-14-2014 02:46 PM
Copyright All Rights Reserved © 2008-2023