How to capture using Tealium to log JavaScript errors in Google Analytics

Gold Contributor
Gold Contributor

Hello,

 

Can anyone help to log the JS errors which is throwing in Console to capture in Google Analytics interface via Tealium.

Logging server-side application errors, but often times ignore client-side errors.  As the web evolves, we’re seeing more and more single page applications that are heavily reliant on client-side service calls using technologies like AJAX.  This makes sites heavily dependent on JavaScript.

Thanks in advance!!!

 

 

 

4 REPLIES 4

How to capture using Tealium to log JavaScript errors in Google Analytics

Gold Contributor
Gold Contributor
@kathleen

Could you please help me on this. Thanks in advance!

How to capture using Tealium to log JavaScript errors in Google Analytics

Employee Emeritus

Hi @Srinivasan. Of course. Sit tight...

Remember to give me a kudo if you like my post! Accepting my post as a solution is even better! Also remember that search is your friend.

How to capture using Tealium to log JavaScript errors in Google Analytics

Employee Emeritus

Hi @Srinivasan. My apologies. I have not been able to find someone to answer your question. :-( 

 

Still trying though... 

Remember to give me a kudo if you like my post! Accepting my post as a solution is even better! Also remember that search is your friend.

How to capture using Tealium to log JavaScript errors in Google Analytics

Moderator
Moderator

@Srinivasan it is possible to implement a global "onError" handler in JavaScript, which is designed to catch JavaScript errors (including a stack trace), which can then be reported to your analytics tool.

 

However, about 3-4 years ago, Chrome and Firefox changed the default security policies for error reporting for very good reasons. This means that errors will only be reported by the onError handler for scripts that are loaded from the same domain as the website, and errors occurring in other 3rd party scripts cannot be recorded (you just get a generic "script error" message, with no details of the actual error).

 

Therefore, if you wish to capture JavaScript errors originating from your own domain, you can do so by adding a window.onError handler function, but for script errors originating from other domains (Tealium's multi-CDN domain, for example, or another 3rd-party tracking tool), you're out of luck - it's just not possible to record these.

 

There are some exceptions to this rule, for cases where the 3rd party script returns an "Access-Control-Allow-Origin: *" response header, but this is generally not the case with 3rd party scripts. You can read more about the security issue on this very good StackOverflow thread: https://stackoverflow.com/questions/5913978/cryptic-script-error-reported-in-javascript-in-chrome-an....

 

In summary, you will be able to collect error information from scripts loaded from your own domain, and you could subsequently pass this information to Tealium, and pass it along in turn to your analytics tool, but it will not give you comprehensive coverage of all JS errors. Our Google Analytics tag in the marketplace does support Google's exception tracking functionality, so once you have passed the information to Tealium in a tracking call, it's just a case of mapping the variables to the correct slots in GA. See here for more details from Google's documentation: https://developers.google.com/analytics/devguides/collection/analyticsjs/exceptions

 

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.
Public