web statistics

Google Analytics Asynchronous Tracking Code For Faster Page Load

Posted on December 6th, 2009 under Analytics, Google, Scripts, Tutorials
ADVERTISMENTS
Share |

Google Analytics is the best and most complete free analytics for webmasters and sometimes the Google Analytics tracking code could be the culprit for slower page loads, pages stop responding and slow down the overall load time of the website.To overcome this problem Google has come out with a new tracking alternative called Asynchronous Tracking.

ganalytics

What To Change ?

Remove your existing Google Analytics Code from your Website and Replace it the following code, and also replacing UA-XXXXX-X with your User Account Number (UA).

<script type=”text/javascript”>

var _gaq = _gaq || [];  _gaq.push(['_setAccount', 'UA-XXXXX-X']);  _gaq.push(['_trackPageview']);

(function() {    var ga = document.createElement(’script’);    ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘.google-analytics.com/ga.js’;    ga.setAttribute(‘async’, ‘true’);    document.documentElement.firstChild.appendChild(ga);  })();

</script>

Note : Place the code above the </head> tag and replace the UA-XXXXX-X with your tracking id.

What The New Code Provides ?

  • Faster tracking code load times for your web pages due to improved browser execution
  • Enhanced data collection & accuracy
  • Elimination of tracking errors from dependencies when the JavaScript hasn’t fully loaded

Source : Google Code Blog

Written by Avinash

Browse Tech Yard for the latest & interesting web applications, Freewares, Wordpress Tips, Firefox Hacks and Addons, Mobile Phones, Windows - Linux - MAC OS Tricks.

Stumble Digg Technorati Reddit Delicious


Related Posts

One Response to “ Google Analytics Asynchronous Tracking Code For Faster Page Load ”



Leave a Reply

Subscribe to TECH YARD:

RSS

Grab the RSS feed for Free Updates!


subscribe

Get blog updates sent directly to your inbox by entering your email address above.