Is Your Google Analytics Code Up to Date?

Have you looked at your Google Analytics setup recently? No, seriously. When was the last time you thought about the Google Analytics code mucking up your website? If it's been a while, you might just want to look into it.

Are You Asynchronous?

its-an-older-code-sir-but-it-checks-outMore times than not, your Google Analytics code is likely a "set it and forget it" type of process. Once it's in your site, you let it be.

Sure, you've gone through various site redesigns. With each iteration, you've remembered to carefully copy and paste the exact elements you need into the new design. But why?

Do you know the recommended Google Analytics tracking code changed just over three years ago? If you've been copying and pasting since then, your code might not be exactly optimized. The modern code uses asynchronous calls.

What does asynchronous mean? Simply put, it means that the code will contact Google's servers and do what it needs to do in the background while the rest of your page continues to load and render in the browser.

Synchronous code (the old version) means that the analytics code must finish executing before the rest of the commands on the page (HTML and what not) can continue.

What Difference Does it Make?

Back in May 2009, just before the change, it made worlds of difference when Google Analytics went down and took out 14 percent of the sites that used the service with it.

Without using asynchronous calls, your site has to wait until the JavaScript finishes before continuing to render the rest of the page. This means that if Google's Analytics servers can't be reached for some reason, your site doesn't finish loading until after the timeout period, typically two minutes. If you place the Google Analytics code in the head area of your web pages, this means the entire page won't load.

Scary stories of your site going down aside, if you want to use any of the cool new features of Google Analytics, like Enhanced Link attribution, you need to use the asynchronous code.

Keep in mind that it's been nearly three years that site speed has been a ranking factor. Waiting for Google Analytics code to execute, hit Google's servers and come back adds to your site's loading time. The asynchronous code allows the rest of the page to continue loading while the Google code is executing which doesn't affect the site speed as much, if at all.

Has Your Analytics Code Reached its Expiration Date?

While keeping your code up to date may seem like common sense, it apparently isn't always the norm. I've been auditing a great many sites as of late and over half of them had out-of-date tracking code.

Maybe I've hit every statistical anomaly and the clients I've taken on recently are all outliers. But I've seen some big brands doing it too. One site still had the really old Urchin code in it:

old-urchin-code

Even worse, the code started at line 14, above everything in the document, except the title and meta tags.

Urchin is old. If you once had Urchin and your code has been copied and pasted over time, you need to change it. Google provides help for migrating from urchin.js code to the newer, asynchronous tracking code.

Where to Find the Latest Tracking Code

Keeping the latest version of the Google Analytics tracking code on your site is straightforward and easy. You can always copy the code directly from Google Analytics.

From anywhere within Google Analytics, click the "Admin' button. This takes you to the Account Administration area your account.

Once within the account administration area, click of the the properties and select the "Tracking Info" tab. Here, you will find your property tracking ID, site tracking options and other items to help you track your site.

In the middle of the page, scroll and you'll see large, bold lettering that states: "This is your tracking code. Copy and paste it into the code of every page you want to track."

this-is-your-tracking-code

Click once in the box and the code is highlighted. Copy to your clipboard and paste into your website in the <head> area (you'll get more accurate data). It's that easy to stay up to date!

Summary

As good site owners, we train ourselves to go through monthly checklists looking for drops in ranking, 404s, proper redirects and other bad things. If you've redesigned your site in the past few years, make sure your Google Analytics code is up to date, too.

Image Credit: Adam Singer