Dot Net Perls

Google Analytics Speed Impact

by Sam Allen

Problem

What are the performance problems with Google Analytics, and how do they impact websites? On the Internet, performance is important, and you don't want to lose sales or visits because of a tracking package on your pages. You want to increase your website's speed.

Solution

I consulted many resources regarding the speed of Google Analytics, and looked at many timelines in Firebug, Safari, and AOL Pagetest. I noted that there seemed to be a short pause when running/loading the ga.js file, on every page load.

Performance measurements

Let's cut to the chase. I compared two of my sites with Google Analytics installed (the JavaScript being present), and then those two sites without Google Analytics. (I would later replace the analytics with something on my local server.)

Before and after. The following chart shows the time with Google Analytics on the left, and without it on the right. The browser loading the pages (Safari) had its cache completely erased, which I felt was fair as browsers cannot be assumed to have caches (see the Yahoo Exceptional Performance site).

Google Analytics is slow

It is clear to me that Google Analytics was having a negative impact on my sites' performance. Note that I had the JavaScript near the end of the document, which is the best way to do it. Let's look at some factors next.

How much does it waste?

In my testing, IE sent about 100 bytes of cookies for each request because of Google Analytics (_utm). This slowed down every request, and on a page with 10 objects, this is ~ 1 kb. Further, the JavaScript that may be cached must always execute. JavaScript is a very slow language, so this too takes its toll.

Conclusion

Google Analytics may be damaging your site's performance, and its added value may be dwarfed by the negative impact on every page your visitors load. Many sites have conducted experiments (Amazon.com, Google itself) that show that time = money on the Internet.

Selective analytics? In my experience, having every page in Google Analytics was not useful. I want to benchmark certain pages only. Thus, it may be a good compromise to include Google Analytics only on certain pages, and uses server logs or other stats (such as Google Webmaster Tools) to gauge your site's reach.

Dot Net Perls
About
Sitemap
Source code
RSS
Internet
Firefox 3 Memory Benchmarks and Comparison
iPhone Web App Example Code
Back Button Use
DNS Lookups for Subdomain
GET and POST Requests in AJAX
Recent
Pi
NGEN Installer Class
List Element Equality
DateTime Tips and Tricks
Remove HTML Tags From String
© 2008 Sam Allen. All rights reserved.