Google Analytics ga.js vs urchin.js

Back in 2007 Google Analytics decided to switch over to ga.js, which is a new version of the javascript tracking code which is loaded through the snippet of code implemented on your webpages. Ga.js provides the functionality required for specific actions and events to be captured, processed and passed on to your Google Analytics reporting.

Although urchin.js continues to deliver the data just like it did in the early days of Google Analytics, there are some important benefits to updating your code to ga.js:

  • ga.js loads and works faster than urchin.js, reducing page load time
  • ga.js is easier to understand and customize
  • It detects the use of https automatically
  • e-Commerce and cross-domain tracking are easier to set up
  • Allows you to use new features offered by GA now, and in future updates

Using urchin.js

Continuing the use of urchin.js is not recommended. This what you should know if you do decide to continue using urchin.js:

  • If you want to be able to use the newer features (as well as upcoming features) you should switch to ga.js
  • Support for urchin.js *could* be stopped at any point by Google, so waiting to switch isn’t a good strategy

Note: You can’t use both urchin.js and ga.js tracking codes together at the same time.

How do I switch to ga.js?

Switching from urchin.js to ga.js tracking code is easy. Just log in to your Google Analytics account, go to Analytics Settings and click on Edit for the website profile you’d like to update your tracking code for. In the top of the page, above the first table of website profile information you can click on “Check Status” and collect the ga.js tracking code. Now log in to your CMS (website backend system) or go through your HTML editor and overwrite the old urchin.js tracking code, save and publish/upload.google analytics tracking code 150x150 Google Analytics ga.js vs urchin.js

The basic urchin.js tracking code looks like this:

<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
try {
_uacct = "UA-#####-#";
urchinTracker();
} catch(err) {}</script>

The basic ga.js tracking code looks like this:

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-#####-#");
pageTracker._trackPageview();
} catch(err) {}</script>

Ga.js for Wordpress users

If you’re using Wordpress on your blog and your tracking code is set up through a plugin based on the old urchin.js version you can simply update your plugin and it should switch to using the new ga.js tracking code. How can you tell which version is used? In both Internet Explorer and Firefox, simply load your website, go to View > Page Source and run a search (CTRL + F) for ‘urchin.js’ and/or ‘ga.js’.

I recommend using Yoast’s Google Analytics plugin for Wordpress.

Bookmark and share!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google
  • Furl
  • NewsVine
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • TwitThis
  • LinkedIn
  • MySpace


Leave a Reply