Last active
August 29, 2015 14:16
-
-
Save jaan/60eebd308c7ebc61555b to your computer and use it in GitHub Desktop.
How to track javascript/jquery errors in google anlaytics?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Track javaScript errors | |
| window.addEventListener('error', function (err) { | |
| var lineAndColumnInfo = err.colno ? ' line:' + err.lineno +', column:'+ err.colno : ' line:' + e.lineno; | |
| ga( | |
| 'send', | |
| 'event', | |
| 'JavaScript Error', | |
| err.message, | |
| err.filename + lineAndColumnInfo + ' -> ' + navigator.userAgent, | |
| 0, | |
| true | |
| ); | |
| }); | |
| // jQuery errors handler (jQuery API) | |
| jQuery.error = function (message) { | |
| _gaq.push([ | |
| '_trackEvent', | |
| 'jQuery Error', | |
| message, | |
| navigator.userAgent, | |
| 0, | |
| true | |
| ]); | |
| } | |
| Source: http://blog.gospodarets.com/track_javascript_angularjs_and_jquery_errors_with_google_analytics/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment