Several webmasters that I have talked to in the last year expressed their concern about Google's website traffic analyzer Google Analytics.
Once of the complaints was that the Analytics script would slow down the loading of the website. Some even moved to other web tracking scripts to make their websites load faster.
Everton over at Connected Internet has now spotted an alternative code to the standard code that has to be added to the website to improve site performance.
The alternative is also provided by Google and currently labeled as beta. The main change to the standard code is that it uses asynchronous tracking which optimizes the way the web browser loads the Google Analytics code embedded on websites.
Another difference is that the asynchronous code has to be placed at the end of the HTML head tag opposed to the standard code which is placed at the end of the body tag.
The new Google Analytics tracking snippet offers the following benefits:
- Faster tracking code load times for your web pages due to improved browser execution
- Enhanced data collection and accuracy
Just visit the Google Code page where the basic code for the asynchronous script is posted. All that needs to be done is to add this before the head tag and replace the UA-XXXXX-X with the code for that website (this can be found in the old code). It is also important to remove the old code from the website as it is not recommended to run both codes on the same website.
Update: Google released a Universal Analytics tracking code in 2013 which runs also asynchronously. You find the code directly on Google Analytics in the admin section when you select a domain you have added. Look under property settings Tracking Info > Tracking Code.
The asynchronous nature of the code is obtained through the variable a.async = 1. This means that it too will run right after the script has been downloaded without blocking page parsing operations. It is highly suggested to use this code from now on and not the one still offered on the original asynchronous code website.
Advertising revenue is falling fast across the Internet, and independently-run sites like Ghacks are hit hardest by it. The advertising model in its current form is coming to an end, and we have to find other ways to continue operating this site.
We are committed to keeping our content free and independent, which means no paywalls, no sponsored posts, no annoying ad formats (video ads) or subscription fees.
If you like our content, and would like to help, please consider making a contribution:
Ghacks is a technology news blog that was founded in 2005 by Martin Brinkmann. It has since then become one of the most popular tech news sites on the Internet with five authors and regular contributions from freelance writers.