Skip to content

Instantly share code, notes, and snippets.

@padicode
Created April 5, 2013 11:21
Show Gist options
  • Save padicode/5318565 to your computer and use it in GitHub Desktop.
Save padicode/5318565 to your computer and use it in GitHub Desktop.
Google Analytics Universal Tracking Init in Google Tag Manager
<script>
(function(q,u,i,c,k){window['GoogleAnalyticsObject']=q;
window[q]=window[q]||function(){(window[q].q=window[q].q||[]).push(arguments)},
window[q].l=1*new Date();c=i.createElement(u),k=i.getElementsByTagName(u)[0];
c.async=true;c.src='//www.google-analytics.com/analytics.js';
k.parentNode.insertBefore(c,k)})('ga','script',document);
ga('create', 'UA-XXXXXXXX-XX', 'yourwebsite.com'); //make sure to customize your tracking ID and your domainname
dataLayer.push({"event":"trackingLoaded"}); //don't forget to add this line
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment