Posts Tagged ‘google analytics’

How to switch to Google asynchronous analytics

Now that Google has officially begun including load time in their page rank algorithms, should you switch to the faster version of Google Analytics?

That depends on how easy it will be for you to swap out all your code.

If you can globally change the Java Script snippet go for it.  But if you have to do it one page at a time, I would worry about other issues that slow down your page load time first.

Tech Wyse Internet Marketing ran an alpha beta test comparing identical web pages with both versions of Google Analytics.  This is what

“A crude estimate of the improvement experienced is that it takes about 1/3 of the time as the standard code. What does this equate in time saved? Perhaps 50-100ms, a very, very small fragment of the time for this page to complete.”

In addition to shaving a few ms off your page load time, Google Asynchronous Analytics has another perk:  it is placed at the top of the HTML document (the original version of Google Analytics is placed at the bottom, just before the closing tag.)  According to Google, “This increases the likelihood that the tracking beacon will be sent before the user leaves the page,”  which can mean more accurate analytical data.

If you are not sure which version of Google Analytics you are using, you are probably not using the asynchronous version.  If you want to upgrade your code, first remove all tracking data and then replace it with the following code snippet:

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXX-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>

Be sure to replace UA-XXXXX-X in the snippet above with your own account information.  You can find your account code (which Google refers to as web property ID) in your Google Analytics account.  Another way you can find the code is by visiting your website, right clicking to view the source code, and then locating your current snippet at the very bottom of the page.  WordPress users can find the ID in the plug in settings you are currently using to add Google Analytics to your site.

For more information and instructions on customizing data tracking visit Google’s Asynchronous Tracking information page.

Share
Must Read Attorney Marketing
Archives