Speed Up Google Analytics - gHacks Tech News

Speed Up Google Analytics

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




  • We need your help

    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:

    Comments

    1. 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.

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

      “hey it’s amazing

    3. 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?

    Leave a Reply