What is Google Analytics – Asynchronous Tracking
Quite recently Google has upgraded its Web Analytics Tracking Code, and the new version is called Asynchronous Tracking. This code is different from the previous GA code, below is an introduction.
Asynchronous Tracking in Google Analytics:
Asynchronous tracking is an improved way to track website visitors with Google Analytics. Asynchronous tracking optimizes how browsers load ga.js so its impact on user experience is minimized. It also allows you to put your Analytics snippet higher in the page without delaying subsequent content from rendering.
Although asynchronous tracking uses a different Analytics snippet and a different syntax for tracking calls, it supports the exact same tracking customizations as the traditional snippet. In fact, the asynchronous tracking syntax is also more flexible than the traditional snippet.
The following snippet represents the minimum configuration needed to track a page asynchronously. It uses _setAccount to set the page’s web property ID and then calls _trackPageview to send the tracking data back to the Google Analytics servers.
<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’;
var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);
})();</script>
To use this on your pages, copy the code snippet above, replacing UA-XXXXX-X with your web property ID.
Check out the tips to install Google Analytics – Asynchronous Tracking.
