Upgrade your Google Analytics tracker

Google Analytics logo

Google released a new version of its Google Analytics tracking code in December after a two-month limited beta. The new Google Analytics tracker is a complete rewrite of JavaScript inherited from the Urchin acquisition in 2005 and the first time the two products have been officially decoupled. The existing version of Google Analytics tracker, urchin.js, has been deprecated but should continue to function until the end of 2008. Google will only roll out new features on the new ga.js tracker. If you currently track website statistics using Google Analytics you should upgrade your templates to take advantage of the new libraries.

What changed?

The new Google Analytics tracker supports proper JavaScript namespacing and more intuitive configuration methods (e.g. _setDomainName instead of _udn). My tests show about a 100 ms faster execution even with a 24% increase (1514 bytes) in file size (ga.js is also minified).

The new tracking code makes advanced features a lot more accessible. You can now track a page on multiple Google Analytics accounts, which should help user generated content sites integrate their author’s Google Analytics IDs alongside the company’s own tracking account. The new event tracker lets you group a set of on-page related actions such as clicking a drop-down menu or typing a search query (very useful for widgets). Ecommerce tracking is now a lot more readable. You can read about all the tracker changes in the Google Analytics migration guide PDF.


Switching your site tracker is pretty simple. Trackers are now created as objects and configured before the page is tracked.

<script type="text/javascript" src="http://www.google-analytics.com/ga.js"></script>
<script type="text/javascript">
var pageTracker=_gat._getTracker('UA-XXXXXX-X');

That’s it. You are now running the new Google Analytics tracker. You’ll need to swap in your Analytics account and profile IDs, which should be pretty easy to spot in your existing code.


Google Analytics tracking code is completely rewritten for faster on-page behavior that plays well with others. The old tracker will be deprecated within a year, and new features are only available to users running the new code. Existing Google Analytics users should swap out their tracking code to take full advantage of this free stats tool.

  • Posted
  • Updated at
  • Comments [4]


Commentary on "Upgrade your Google Analytics tracker":

  1. Rick Rottman on wrote:

    Thanks for pointing this out. It’s most appreciated. I really should be checking out the Google Analytics site more often.

  2. Ted Rheingold on wrote:

    Agreed, you are the first and only reason I knew about this.Thx!

  3. Megan on wrote:

    So when you change from old code to new code- or vice versa you don’t lose your past data? I am concerned about losing a specific campaign’s data by changing from new to old- we’ve been having a lot of problems with ga.js- my data is jumping all over the place- from 700 visitors at 9am to only 190 by lunch. I am concerned that if I change back to the legacy code I will lose past data. Can you help?

    • Niall Kennedy on wrote:

      The back-end storage, and its representation as a Google Analytics report, should be the same regardless of your tracker code. The newer tracker, ga.js, may support more reporting features today or in the future but basics such as total visits or unique users should remain constant. I have no inside knowledge of the Google Analytics product or its features but I am an active user.