Google Analytics Asynchronous Snippet Update Excitement

Published 2010 March 25th, Last Modified 2010 March 25th

Today was an exciting day for me. I discovered that my tweak to Google’s Asynchronous Snippet was published a couple of days ago.

The Asynchronous Tracking (code.google.com) page now shows:

<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>

And it can go in the head of your document, or I suppose anywhere. Hurray!

Thanks to Brian Kuhn (twitter.com) top guy who took in my tweak (google.com), tested it out and announced the new iteration of the snippet!

Time to start using it in earnest. Here’s hoping it stands the rigours of daily web life.