Google Blogoscoped

Thursday, December 13, 2007

Google Analytics Tracker Code Change and More

There is no specific immediate need to do this, but if you are using Google Analytics for your traffic tracking, Google asks you to update the tracker script from this (replace YOURNUMBER with your ID, as contained in your old tracker code)...

<script src="" type="text/javascript"> </script> <script type="text/javascript"> _uacct = "UA-YOURNUMBER-1"; urchinTracker(); </script>

... to this:

<script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write("<script src='" + gaJsHost + "' type='text/javascript'></script>" ); </script> <script type="text/javascript"> var pageTracker = _gat._getTracker("UA-YOURNUMBER-1"); pageTracker._initData(); pageTracker._trackPageview(); </script>

The old code will still work though for at least another year, according to Google. Google says they "recommend you use for all new accounts and new profiles for new domains. ... This will allow you to take advantage of the most up-to-date tracking functionality as it is added to Google Analytics." (A migration guide in PDF format explains more.)

As another change to Google Analytics -- no matter which tracking code you are using -- you can now graph two metrics against each other, say, visits vs page views. Click the arrow button to the top right of your main visits chart to set this up.

Update: Google decided to actually validate their code (after they released it)... whoopie! They now suggest you replace the tracker code once again. You can find the updated code in your Google Analytics (next to your site click Edit -> Check Status) or below:

<script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> var pageTracker = _gat._getTracker("UA-YOURNUMBER-1"); pageTracker._initData(); pageTracker._trackPageview(); </script>


Blog  |  Forum     more >> Archive | Feed | Google's blogs | About


This site unofficially covers Google™ and more with some rights reserved. Join our forum!