Time To Update Your Google Analytics Code

Google wants you to change the code you use for Google Analytics, in order to support better the features in the new version. You have a year, at the least, before the old code stops working, but you won’t get all the cool new stuff until you update. Just add this new code in place of your old, code, replacing UA-YOURNUMBER-1 with your account ID number:

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”));

var pageTracker = _gat._getTracker(”UA-YOURNUMBER-1″);
pageTracker._initData();
pageTracker._trackPageview();

If you are confused, clickthe “Check Status” link in your Analytics account, and it’ll run you through everything. If you are tracking subdomains, add this line before the pageTracker._initData(); line:
pageTracker._setDomainName(”yourwebsite.com”);

Read up on subdomains here to make sure you have everything implemented correctly.

Original post by Nathan Weinberg