Google recently released updated tracking code for Google Analytics which allows for asynchronous tracking. This means the analytics tracking can be done at the same time as rendering other content and therefore won’t delay other page content from rendering. This results in what appears to be faster rendering pages.
For full documentation and examples please refer to the Google Analytics Asynchronous Tracking page which will always contain the most up to date information. I also include an example here for completeness sake and also to show where the tracker should be placed in relation to the rest of the HTML content.
Some of benefits of using this new asynchronous tracking script over the old style tracking script (which goes directly before the closing </body> tag) are:
1) It doesn’t cause any issues with blocking other content rendering while the script downloads and executes. This should make your page appear to load faster and may lead to less people exiting early due to a slow rendering page.
2) Because the tracking code is now at the top of the HTML it will track visitors who may bail out early and who wouldn’t have previously been tracked because the bottom of the document which contained the old style tracking code never loaded.
I’m rolling this out across my websites
I’ve started rolling this new asynchronous tracking out across my websites starting with this blog directly before posting this and it already seems to have improved the perceived speed of the page load.