Installing Google Analytics

Instructions for installing Google Analytics on a website:

Installing Google analytics is as easy as inserting the Analytics snippet which is a small piece of JavaScript code that you paste into your pages. It activates Google Analytics tracking by inserting ga.js into the page.

For more information on setting up Google Analytics.

Copy the following code below, replacing UA-XXXXX-X with your web property ID, then paste it onto every page you want to track immediately before the closing </head>tag.

For more information on getting a Web Property ID.

<script type=”text/javascript”>

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

The snippet above represents the minimum configuration needed to track a page asynchronously. It uses _setAccount to set the page’s web property ID and then calls_trackPageview to send the tracking data back to the Google Analytics servers.

One of the main advantages of the asynchronous snippet is that you can position it at the top of the HTML document. This increases the likelihood that the tracking beacon will be sent before the user leaves the page. It is customary to place JavaScript code in the <head> section, and we recommend placing the snippet at the bottom of the <head> section for best performance.