Last active
October 18, 2018 14:13
-
-
Save simondahla/66bb5358f7335d8fac770ad29774ce91 to your computer and use it in GitHub Desktop.
#googleanalytics
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
function logTimes(message) { | |
if (window.performance) { | |
performance.mark(message); // this one is for WebPageTest | |
console.timeStamp(message); // this is for the Performance tab in Chrome DevTools | |
console.info(message, performance.now()); // this is for the console, duh | |
// this here is for Google Analytics | |
ga('send', { | |
hitType: 'timing', | |
timingCategory: 'Performance', | |
timingVar: message, | |
timingValue: Math.round(performance.now()) | |
}); | |
} | |
} | |
// use it like so | |
bindAllMyEventsOrWhateverGetsThePageReady(); | |
logTimes('The page is really ready'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment