Last active
August 29, 2015 13:56
-
-
Save dkrnl/e8b1e38a92c9900af225 to your computer and use it in GitHub Desktop.
Track Javasctipt Errors via Google Analytics
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
{% if not debug %} | |
<script> | |
var _gaq = window._gaq || []; | |
window.onerror = function(msg, url, line) { | |
var preventErrorAlert = true; | |
_gaq.push(['_trackEvent', 'JS Error', msg, '#{{ employee.id|default:"0" }} ip:{{ request.META.REMOTE_ADDR|escapejs }} ua:{{ request.META.HTTP_USER_AGENT|escapejs }} url:' + url + " line:" + line, 0, true]); | |
return preventErrorAlert; | |
}; | |
jQuery.error = function (message) { | |
_gaq.push(['_trackEvent', 'jQuery Error', message, '#{{ employee.id|default:"0" }} ip:{{ request.META.REMOTE_ADDR|escapejs }} ua:{{ request.META.HTTP_USER_AGENT|escapejs }}', 0, true]); | |
} | |
</script> | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment