Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@hmnd
Created March 29, 2020 03:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hmnd/5d06856e4dec5edc6cecd69dd3d5f61c to your computer and use it in GitHub Desktop.
Save hmnd/5d06856e4dec5edc6cecd69dd3d5f61c to your computer and use it in GitHub Desktop.
// Add Google Analytics
var gAnalytics = document.createElement('script');
gAnalytics.setAttribute('async', '');
gAnalytics.setAttribute(
'src',
'https://www.google-analytics.com/analytics.js'
);
gAnalytics.onload = function () {
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', 'UA-XXXXX-Y', 'auto');
ga('send', 'pageview');
};
document.head.insertBefore(gAnalytics, document.head.firstChild);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment