Google Analytics Code Updated – Asynchronous Tracking Overview
Google Analytics has introduced its latest tracking version termed as “Asynchronous Tracking Code”. Unlike a traditional installation, asynchronous tracking optimizes how browsers load ga.js so its impact on user experience is minimized. It allows you to add the snippet in the top of section section itself which will not delay the down the loading of the details in the page. The following snippet is the revised version of the existing code,
<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>
The first part of the asynchronous tracking code snippet assigns the _gaq variable to a JavaScript array. The second half of the snippet provides the logic that loads the tracking code in parallel with other scripts on the page. You can find the detailed info on Google Code Blog on Asynchronous Tracking.
Installation Procedure:
To make sure that your webpages use the asynchronous tracking code version follow the below process,
- Remove the existing version of the tracking code and any customizations.
- Insert the tracking code in the top of the <body> section
- Replace the UA in the _setAccount to your ID.
You can add the customizations for the asynchronous tracking following the process in the usage guide and migration examples.
The advantages of Asynchornous Tracking include,
- Speeding up overall page load time
- Collecting more visitor data from short visits to your content- or script-heavy pages
- Eliminating improper sequence operations between tracking user clicks and loading the tracking code
- Enhanced data collection and accuracy.
- Elimination of tracking errors from dependencies when the JavaScript hasn’t fully loaded.
The new version is still in Beta but this will really help you to improve the speed of your website. If you have already implemented this version of analytics or have any info on the same please share your thoughts in the comments section.
Popularity: 11% [?]

Comments
No comments yet.