Google Analytics Code is Slowing Down My Site
Fast page load times are vital for websites. Internet users have a notoriously short attention span, and will leave if a site takes more than a few seconds to load. Before placing additional code onto a website, it's important to determine whether that will effect page load times negatively.
If Google Analytics tracking code doesn't load before a visitor leaves the site or clicks away from the page, the page data won't show up in Google Analytics. You can compensate for this scenario by running web log analysis software in conjunction with Google Analytics.
Does Google Analytics Code Slow Down My Site?
Next, the code requests a 1x1 transparent image named __utm.gif. It attaches information in the query string of this file, and that's how it sends information to Google Analytics. This file is requested with every pageview, but it is 35 bytes. Small enough to be insignificant, regardless of what speed your Internet connection is. It might take 1/100 or 1/50 of a second to load.
With previous versions of Google Analytics, Google recommended placing the tracking code at the very end of the body just before the closing </body> tag. This way, in the chance that there were any delays with Google's servers or (more likely) with the visitors' device, the rest of the page would still display normally. This has been alleviated with asynchronous tracking code.
"Waiting for google-analytics.com"
Some have noticed on slow-loading pages that the status message in their browser sometimes says "Waiting for google-analytics.com". This only happens on sites that run an ancient version of the Google Analytics tracking code!
If you are still concerned that Google's tracking code that is slowing down your pageload times, you can try a few things to test its impact:
- Use Google Webmaster Tools to identify and fix slow-loading components of your website
- Make sure you're using the current version of the ga.js snippet
- Move the code to the very bottom of the page, if you haven't already
- Move another code just after the tracking code to see if it shows up in the status bar instead
- Delete or optimize other large files, like css files and images, to see what impact they are having
- Host the ga.js and __utm.gif file locally and execute the _setLocalServerMode() method. This goes through the same process as normal, except it requests the __utm.gif file locally instead of from Google's servers. (This also means that no data will be sent to your Google Analytics account during the test.)
Google Analytics for Intranets
Does your company use Google Analytics to track Intranet websites? If so, there's a slight problem: