Speed Up Google Analytics

Martin Brinkmann
Dec 2, 2009
Updated • Jan 8, 2017
Google
|
3

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
  • Elimination of tracking errors from dependencies when the JavaScript hasn’t fully loaded

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.

Summary
Speed Up Google Analytics
Article Name
Speed Up Google Analytics
Description
Find out how to speed up the loading of Google Analytics scripts on your websites by configuring it to load asynchronously.
Author
Publisher
Ghacks Technology News
Logo
Advertisement

Tutorials & Tips


Previous Post: «
Next Post: «

Comments

  1. Diego said on December 4, 2009 at 4:40 am
    Reply

    @Tun
    That’s exactly what I’ve done!

    Now I have to wait all sites over the world change their code…
    I think that kind of scripts should be dynamic, so any change will be reflected in any site.
    Could Javascript do that?

  2. hak01 said on December 3, 2009 at 4:52 pm
    Reply

    “hey it’s amazing

  3. Tun said on December 2, 2009 at 11:25 pm
    Reply

    I believe most people have already blocked google analytics on their computers using ‘no script’ due to it being too slow since day one. so the systems already killed its self off and useless.

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.