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.

Share with friends

About the Author: P Chandra is editor of QOT, one of India's earliest tech bloggers since 2004. A tech enthusiast with expertise in coding, WordPress, web tools, SEO and DIY hacks.