Update Google Analytics Code to ga.js for Better Tracking

Google Analytics is a very powerful site traffic tracking tool used by most websites. Google Analytics has updated the code for better tracking and compatibility with new features. The old code works well, but you can optionally update the code and get more powerful statistics analysis.

urchin.js to ga.js

The basic code move is from from urchin.js to ga.js – though the urchin.js page tags will continue to work as usual. The Analytics blog explains that

This will allow you to take advantage of the most up-to-date tracking functionality as it is added to Google Analytics. An immediate benefit you’ll notice is that the ga.js tags allow you to track ecommerce transactions in a more readable way. And, we’ve created a special resource on the ga.js javascript for power users who want more control over Google Analytics tracking.

They have created a Tracking Code Migration Guide which details benefits about switching from urchin.js to ga.js. I have updated my code (takes a minute at most!) and recommend you do the same to get full benefits of Google Analytics.

Updating Google Analytics Code

I have never changed the Analytics code since I first installed it, so finding it was difficult. Anyway just so that you do not have to go looking…

After logging in, Click on “Edit” next to the website profile you want to edit. On the Edit Profile screen, click the “Check Status” link next to “Recieving data” text, if Analytics code is live on your site.

There you will find Instructions for adding tracking
Legacy Tracking Code (urchin.js) option is selected.
Click the New Tracking Code (ga.js), copy and paste the code in your template immediately before the </body> tag, and that’s it.

Remember: do not include both tracking code snippets together on any given page or be prepared for inaccurate report data.


  1. Haris says:

    ga.js tracking code looks a lot better. I never knew that. Thanks for sharing it! :)

  2. Alp says:

    thank you, very handy

  3. Dave Pen says:

    This is an eye opener to most bloggers. Thanks

  4. les says:

    You appear to be using WordPress – I cannot get this new code to validate on my wordpress blog – I am also having trouble with mybloglog and blogcatalog – it is a shame as I would like to use the new code. Did you have any difficulties with validation?

    the radical blogger

  5. jon nixon says:

    Check out line 435 of the source of this page the “/” and “” are replaced by their numerical ascii characters

  6. Dean says:

    When switching from legacy to the newer ga.js, do you get a lull in statistics?

  7. todd says:

    I am currently using Google Analytics and I have all pages tagged properly including the receipts page (with the GA ecommerce tracking code)however I cannot seem to get my revenue indicators to report. What might I be doing wrong?

Leave a Reply

Your email address will not be published. Required fields are marked *