Analytics Market is a one-stop resource for anything you can do with Google Analytics. Tips and tricks, product news, API tools, and more!
Analytics Market Chart

Upgrading Your Site From urchin.js to ga.js

The fear that sites using older code will one day suddenly stop receiving any data is overblown, to say the least.

There has been some hullabaloo about how long Google will continue supporting urchin.js, the older version of the Google Analytics tracking code. It was marked as deprecated more than a year ago, and they stopped making updates to it. The future is certainly with ga.js.

However, it should be noted that many of Google's own sites still use urchin.js. As do many very large websites. Google has been very clear that there are no plans to drop the code--especially not without warning.

In other words, the fear that sites using older code will one day suddenly stop receiving any data is overblown, to say the least. It is arguably unwise for Google to make that decision for about a hundred reasons.

Advantages to ga.js

There are some clear advantages to using the newer code, however. And those advantages will only multiply with time.

  1. Access to new and also upcoming features, like Event Tracking
  2. Smaller file size means faster downloads
  3. Automatic detection of HTTPS
  4. Increased namespace safety
  5. Object-oriented code is more flexible in many ways
    • Easier e-commerce setup
    • If you're using multiple accounts or profiles, more control over what data gets sent to which profiles
    • Rename or create multiple tracker objects
  6. You can point and laugh at the websites that haven't upgraded yet (which includes many large and prestigious sites)

If you update the code correctly, no data will be lost. The newer code doesn't change how visit data is collected or calculated. In other words, it provides all these benefits without any drawbacks besides the pain of changing the code once.

Switching from urchin.js to ga.js

Depending on how your site is set up, making the switch will be very easy.

First, log into your Google Analytics account.

From the Analytics Settings page (the one listing your profiles), click Edit next to the profile for the website you are upgrading.

On this page, you will see a box titled "Main Website Profile Information". Just above this box, in the right hand corner is a little link that says "Check status". Clicking this link will give you the most updated version of the tracking code.

If you haven't done any modifications to your code, you can simply replace your current code with this code. Make sure you get every page! The two versions don't always play nicely with each other.

Modifying ga.js

If you have made any modifications to your tracking code, making this upgrade becomes a little bit more complicated. With urchin.js, you primarily just set different values for variables. In ga.js, you call methods of the pageTracker object instead.

Below are some common modifications and their equivalents in ga.js. Please note that all ga.js equivalents are methods of the tracker object. They are not stand-alone functions! Example: _link() must be called as pageTracker._link().

urchin.js ga.js
_utmLinker() _link()
_ulink=1 _setAllowLinker(true)
_utmSetVar() _setVar()
_userv=0 _setLocalServerMode()
_userv=1 _setRemoteServerMode()
_userv=2 _setLocalRemoteServerMode()
_urchinTracker() _trackPageview()