web statistics
Image 01 Image 02

Google Analytics Asynchronous Tracking Code For Faster Page Load

2
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 Google Analytics Asynchronous Tracking Code For Faster Page Load

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


Posted on 6th December 2009 by Avinash under category Analytics, Google, Scripts, Tutorials


2 Responses to “Google Analytics Asynchronous Tracking Code For Faster Page Load”

  1. Hi there,

    Nice post… by the way, I just modified the Google Analytics plugin for WordPress and added the new asynchronous tracking method… Please review my post about Asynchronous Google Analytics plugin for WordPress at http://www.minilibra.com/wordpress/plugins/analytics.html

    Cheers
    Bambang Sugiarto

Leave a Reply


Web Informer Button