Thursday, December 13, 2007

Solution for Google Analytics tracking code problem with Blogger

Google is behind both Blogger and Google Analytics but this problem slipped through. If you get the error below when you try to add the new tracking code for Google Analytics to your blogger/blogspot blog take a look at this solution. Notice that if you just copy the code from that page you will get _gat is undefined error on your pages so use the code below and just make sure to change UA-XXXX-X to your code.

For HTTP:

<script type="text/javascript" src="http://www.google-analytics.com/ga.js"></script> <script type="text/javascript"> var pageTracker = _gat._getTracker("UA-XXXX-X"); pageTracker._initData(); pageTracker._trackPageview(); </script>

For HTTPS:

<script type="text/javascript" src="https://ssl.google-analytics.com/ga.js"></script> <script type="text/javascript"> var pageTracker = _gat._getTracker("UA-XXXX-X"); pageTracker._initData(); pageTracker._trackPageview(); </script>

Error message:

We were unable to save your template
Please correct the error below, and submit your template again.
Your template could not be parsed as it is not well-formed. Please make sure all XML elements are closed properly.
XML error message: Open quote is expected for attribute "{1}" associated with an element type "type".

Why would you want to make this update and switch from urchin.js to ga.js?

This will allow you to take advantage of the most up-to-date tracking functionality as it is added to Google Analytics.

Reading through the migration guide I also learned how to track downloaded files.


Some of the latest blog posts

Subscribe to RSS headline updates from:
Powered by FeedBurner