Skip to content

Instantly share code, notes, and snippets.

@kostasx
Last active December 20, 2018 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kostasx/267b5202d6f37d2342c17443beb7eb01 to your computer and use it in GitHub Desktop.
Save kostasx/267b5202d6f37d2342c17443beb7eb01 to your computer and use it in GitHub Desktop.
Google Analytics JavaScript async Snippet to paste on the GA input field
(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');
var s = document.createElement('script');
s.setAttribute('async', true);
s.setAttribute('src', 'https://www.google-analytics.com/analytics.js');
var $head = document.getElementsByTagName('head');
$head[0] && $head[0].appendChild(s);
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment