Many bloggers are using Google Analytics (GA) on their site to collect information about their visitors. It is feature-rich, accurate, extensible through an API and, most importantly to many, completely free.
However, despite its popularity, it seems that most of its users have missed one of the most important improvements to the service in recent years.
Historically the only drawback to GA has been that it is somewhat slow. It has a tendency to block other elements from loading while it churns, causing sites to slow to a crawl, especially during times of high load for GA, and that forced most to put the code in their footer, where it fails to catch “quick” visits to the site. This caused many to be torn between having a slower site and going without Google’s impressive stat tracking tools.
This has been a major boon for my site, according to Pingdom, I managed to shave about 2 seconds off of my loading time (from about 5.6 seconds to 3.9) between when I added the new code and a test taken shortly before. Furthermore, GA itself is reporting about 10% more visitors from the prior day despite no noticeable changes in other statistics.
Though far from definitive as it is too soon to be certain if these changes will hold, it’s a sign that others should be looking into this code as well.
The effect can be like traffic on a one-lane road with a large truck going down it. The other vehicles have to wait for the slow truck to get to its destination before they can travel at normal speeds.
With GA, the solution many took and was recommended by Google was to put the code at the bottom of the page, thus putting the “truck” at the end of the line of traffic. However, this limited the accuracy of the code, causing it to load later, and still slowed down sites as many elements, especially complex media ones, were likely waiting to load until after GA was finished.
What the new code does is effectively create a “passing lane” that lets other items pass it by. This not only speeds up the loading time of sites that use GA, but also means that the code can be moved to the HEAD of the Web site, making it more accurate.
Clearly it is a win-win for current GA users and, with that in mind, here’s how to get the code and put it on your site.
How to Use It
If you want to use the new GA code, the process is very simple. All you have to do is follow these steps:
- Remove Your Old Code: Remove the old code from your template (most likely in your footer below the final /BODY tag. If you use a plugin to automatically add the code, disable it for right now. However, keep a copy of your old code, or your GA ID as you will need it.
- Get the New Code: Visit GA’s Google Code page and get the new tracking code.
- Insert your GA ID: Where the new GA code says “UA-XXXXX-X”, replace it with your ID number, which should be in that format.
- Put the New Code In Your Site: Place the new code in your site just before the /HEAD tag, which is mot likely in your header file, rather than your footer.
- Clear Your Cache: If you use WP Super Cache or any similar caching program, clear your cache to make sure that all of your pages are refreshed.
Once you do that, you’re done. The new code should be working fine and you can check in your GA account tomorrow to see if it is reading normally.
GA is a powerful tool for any Web site, including a blog. Knowing how many people visited your site, how long they stayed, what they read and how they got there is crucial information and GA makes it easy and free to collect some of the most robust information possible. Now, with the new code, it is also incredibly fast.
There’s literally almost no drawback to using GA on your site now, unless you have privacy concerns with Google, so it makes sense to at least give it a try. Though WordPress stats and other programs are interesting an useful, GA is the most in-depth solution available right now for free and certainly the most extensible.
I use GA currently with PostRank, on my site and love the combination. But even without PostRank, GA provides so much valuable information, I can’t imagine working without it.