Just another idiot with a blog

Google Analytics Asynchronous Tracking, Finally!

Unlike the regular tracking code google analytics has, this snippet directly from google, this optimizes the way the page loads…SO if some of you have noticed on sites they get hung up and won’t load because its waiting on analytics loading in the header..Well fuck that.

here is the snipper


<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';
    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
  })();

</script>

It inserts the ga.js into the page, it specified the page’s web property ID and then calls _trackPageview to send the data back. Just Replace the UA-XXXXX-X with your web property ID. Visit this page from google for more details!

Leave a Reply

Copyright ©2010 wessray.com
Protected by Copyscape Unique Content Validation