Skip to content

Instantly share code, notes, and snippets.

@dcvogi
Last active October 18, 2018 21:14
Show Gist options
  • Save dcvogi/b22acd16ae3c14f56955add75328fa24 to your computer and use it in GitHub Desktop.
Save dcvogi/b22acd16ae3c14f56955add75328fa24 to your computer and use it in GitHub Desktop.
Track the on-page errors on Google Analytics
(function errorTracking() {
window.onerror = function(msg, url, lineNo, columnNo, error) {
var errorStack = error ? JSON.stringify(error.stack) : 'stack unavailale';
var content = [
msg, url, lineNo, columnNo, errorStack
].join(' - ');
ga('send', 'event','error tracking', content);
return false;
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment