Created
April 10, 2014 19:07
-
-
Save varmais/10412835 to your computer and use it in GitHub Desktop.
Track Javascript errors with Google Analytics
This file contains 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
window.addEventListener('error', function(event) { | |
_gaq.push([ | |
'_trackEvent', | |
'JS Error', | |
event.message, | |
event.filename + ': ' + event.lineno, | |
true | |
]); | |
}); | |
// ajax errors with jquery | |
$(document).ajaxError(function(event, request, settings, error) { | |
_gaq.push([ | |
'_trackEvent', | |
'Ajax error', | |
settings.url, | |
event.result, | |
true | |
]); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment