Skip to content

Instantly share code, notes, and snippets.

@jrobinsonc
Last active August 30, 2017 19:21
Show Gist options
  • Save jrobinsonc/e5ef407ab3b02cd8d1f670e742f270ce to your computer and use it in GitHub Desktop.
Save jrobinsonc/e5ef407ab3b02cd8d1f670e742f270ce to your computer and use it in GitHub Desktop.
Handling JavaScript errors with Google Analytics
// https://developers.google.com/analytics/devguides/collection/analyticsjs/exceptions
window.onerror = function(errorMsg, url, line, lineColumn, errorObj) {
ga('send', 'exception', {
'errorMsg': errorMsg,
'url': url,
'line': line,
'lineColumn': lineColumn,
'errorObj': JSON.stringify(errorObj)
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment