Google Analytics-Asynchronous tracking

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...
December 3, 2009

Google Analytics, has recently launched an asynchronous tracking feature that will hopefully prove fruitful to large sites and even small ones should get benefited. The Asynchronous tracking feature boasts a significant reduction in website loading time upon its implementation. As said in Google Analytics blog, it uses a separate lane to handle the processing of the webpages. Large sites that use rich media content with lots of individual scripts will get benefited immensely. But smaller sites will also enjoy a relatively lesser loading time.

Well, its not just about time, the asynchronous tracking system collected data with more efficiency and accuracy than the previous system. And even if your visitor doesn’t fully load your page, you won’t loose the data as this snippet is able to gather data in such cases as well. Isn’t that great?

The asynchronous tracking code is currently in Beta but not to worry, all analytics users can use it right away. Using this code is optional and you can continue accessing the data gathered through the standard code.

The core script file ga.js that is the backbone of tracking a website puts a certain burden on the browser. The asynchronous code lessens this burden leading to a swifter loading time. Installing this code is easy as copy and pasting(like earlier), but this one needs to be added towards the top of the page unlike the older one that used to be added to the bottom. But remember, before your add this snippet, you need to remove the older one. It is advised to insert this code at the bottom of the <head> section of the pages.

The following is the snippet for tracking a page asynchronously.

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

To effectively add this code to your site, just replace the UA-XXXXX-X with your web property ID. You can copy your web property ID from the pageTracker parameter of your older code.  Or go to your analytics dashboard and then to Edit>Check status and copy your Web Property ID from there. You can also share the analytics data on your website.

You may also like...

Post a comment