Created
June 8, 2012 13:32
GA.js track errors
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
// For hackers: | |
window.onerror = function(m, f, l){ | |
var err = JSON.encode({ message:m, file:f, line:l }) | |
(new Image).src = '/errors?e='+err | |
} | |
// For Google Analytics users: | |
window.onerror = function(m, f, l){ | |
var err = [f, l, m].join(' : ') | |
_gaq.push(['_trackEvent', 'Errors', 'App', err, null, true]) | |
} | |
// Analytics will allow you to filter by OS, browser, and all the other environment data it already captures. And nice graphs as a bonus :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment