Skip to content

Instantly share code, notes, and snippets.

@sgelob
Last active July 17, 2018 19:57
Show Gist options
  • Save sgelob/0cd92a3e72947e7adf82d1bc927f83e1 to your computer and use it in GitHub Desktop.
Save sgelob/0cd92a3e72947e7adf82d1bc927f83e1 to your computer and use it in GitHub Desktop.
Measuring the Critical Rendering Path via GTM an Google Analytics
<script type="text/javascript">
// https://developers.google.com/web/fundamentals/performance/critical-rendering-path/measure-crp
(function() {
var t = window.performance.timing,
interactive = t.domInteractive - t.domLoading,
dcl = t.domContentLoadedEventStart - t.domLoading,
complete = t.domComplete - t.domLoading;
dataLayer.push({
"event": "measuringCRP",
"interactive": interactive,
"DCL": dcl,
"complete": complete
});
})();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment