-
-
Save underdown/2913821 to your computer and use it in GitHub Desktop.
How fast is my site? integrate boomerang and google analytics
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
<script type="text/javascript"> | |
BOOMR.init({ | |
beacon_url: "/boomerang.gif", | |
BW: { | |
enabled: false | |
} | |
}); | |
BOOMR.subscribe('before_beacon', trackInAnalytics); | |
var pageTitle = document.title; // customize this | |
function trackInAnalytics(beacon) { | |
try { | |
if (!beacon.t_done || beacon.t_done < 0) return; | |
var timeTaken = beacon.t_done; | |
_gaq.push(['_trackEvent', pageTitle + 'PageLoad', getBucket(timeTaken), timeTaken]); | |
} catch (e) {} | |
} | |
function getBucket(timeTaken) { | |
var bucketString; | |
var bucket = [1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 9000, 10000, 15000, 20000, 30000, 45000, 60000]; | |
for (var b = 0; b < bucket.length; b++) { | |
if (timeTaken < bucket[b]) { | |
bucketString = '< ' + bucket[b] / 1000 + 's'; | |
break; | |
} | |
} | |
if (!bucketString) bucketString = '> ' + bucket[bucket.length - 1] / 1000 + 's'; | |
return bucketString; | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment