Created
October 23, 2013 14:42
-
-
Save bchumney/7120100 to your computer and use it in GitHub Desktop.
JavaScript Resource Load Tracking Time
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
var nexacStartTime; | |
loadJs('https://e.nexac.com/e/a-1319/s-2915.js', myCallback); | |
function loadJs(url, callback) { | |
TE('Nexac', 'Requested', (typeof referrer !== 'undefined' ? referrer : 'not defined')); | |
var js = document.createElement('script'); | |
js.async = true; | |
js.src = url; | |
var s = document.getElementsByTagName('script')[0]; | |
js.onload = callback; | |
nexacStartTime = new Date().getTime(); | |
s.parentNode.insertBefore(js, s); | |
} | |
function myCallback(event) { | |
var endTime = new Date().getTime(); | |
var timeSpent = endTime - nexacStartTime; | |
TE('Nexac', timeSpent.toString(), (typeof referrer !== 'undefined' ? referrer : 'not defined')); | |
_gaq.push(['_trackTiming', 'nexac', 'loading pixel', timeSpent, 'nexac.com', 100]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment