Created
April 9, 2013 00:35
-
-
Save necenzurat/5341912 to your computer and use it in GitHub Desktop.
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
<!-- Async Tracking Code - http://code.google.com/intl/en-US/apis/analytics/docs/tracking/asyncTracking.html --> | |
<script type="text/javascript"> | |
var _gaq = _gaq || []; | |
_gaq.push(['_setAccount', 'YOUR ANALYTICS ID GOES HERE']); | |
_gaq.push(['_trackPageview']); | |
//******************* | |
// Trick #1: Track page load time in Google Analytics | |
// (note: only works for HTML5 browsers) | |
//******************* | |
_gaq.push(['_trackPageLoadTime']); | |
(function() { | |
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; | |
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; | |
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); | |
})(); | |
//******************* | |
// Trick #2: Add a Javascript error handler so that it creates an event in Google Analytics | |
// whenever there's a CLIENT-SIDE javascript error | |
//******************* | |
window.onerror = function(message, file, line) { | |
var sFormattedMessage = '[' + file + ' (' + line + ')] ' + message; | |
_gaq.push(['_trackEvent', 'Errors', 'Browser', sFormattedMessage, null, true]); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment