Created
February 20, 2015 05:19
-
-
Save pwenzel/eb4f04552ef410f60406 to your computer and use it in GitHub Desktop.
Track 404 errors as events with Google Universal Analytics, capturing the referrer as well.
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
<script type="text/javascript"> | |
// Track 404 errors with Universal Analytics | |
if($('body').hasClass('error404')) { | |
ga('send', 'event', 'error', '404', 'page: ' + document.location.pathname + document.location.search + ' ref: ' + document.referrer, {'nonInteraction': 1}); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@jnachtigall undefined is unnecessary, Google themselves do not use it in their examples. But you're correct on the "1" thing.