SHARE: LinkedIn Facebook Google+ Tweet Email

Google Analytics Code

Google Analytics (GA) has evolved over the years to make it better, faster and more accurate. But only if you keep it updated...

     In November 2005 Google Analytics launched after Google acquired URCHIN SOFTWARE earlier that year.
     In December 2007 Google introduced their TRADITIONAL/SYNCHRONOUS version.
     In December 2009 the ASYNCHRONOUS version was released. Its JavaScript runs parallel to others in a website. In addition
      to minimizing drag on page load speed, it moved higher up within a website's code - allowing for more accurate data collection.
     In April 2014 the UNIVERSAL version came out of beta. This latest version uses a single cookie to (potentially) track users
      across multiple devices and is highly customizable.

Unless your IT team has updated your Google Analytics along the way, you may not be accurately tracking your website traffic. The following provides location and appearance of each of the iterations of Google Analytics Code. Pass it along to your team to confirm your GA is truly up to date!


2005 - URCHIN

The code goes before closing body tag </BODY>

<script src=“http://www.google-analytics.com/urchin.js” type=“text/javascript”></script>
<script type=“text/javascript”>
_uacct = “UA-#####-#”;
urchinTracker();
</script>


2007 - TRADITIONAL/SYNCHRONOUS

The code goes before closing body tag </BODY>

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "href="https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try{
var pageTracker = _gat._getTracker("UA-######-#");
pageTracker._trackPageview();
} catch(err) {}</script>


2009 - ASYNCHRONOUS

The code goes before closing head tag </HEAD>

<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-########-#']);
_gaq.push(['_trackPageview']);
function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'href="https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>


2014 - UNIVERSAL

The code goes before closing head tag </HEAD>

<script>
(function(i,s,o,g,r,a,m){i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].|=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-########-#', 'larslofgren.com');
ga('send', 'pageview');
</script>