Thursday, November 29, 2007

Google Analytics and Blogger.com

As you know, it is not trivial to insert Google Analytics tracking code into your blog on Blogger.com. Google just doesn't see your code - it says that tracking code is installed, but gets no data from your pages (you see "Tracking code installed - waiting for data" on your analytics page). In order to make your tracking code work, you should do following:

1) Go to your blog template editing page
2) Paste your tracking code into <head>...<head> section of template
3) Make sure Google detected code on your page by updating it's status in Analytics interface
4) Then wrap actual call of urchinTracker in Javascript's eval function like this:

<script src='http://www.google-analytics.com/urchin.js' type='text/javascript'>
</script>
<script type='text/javascript'>
eval('_uacct = "your_id_goes_here"; urchinTracker();');
</script>


Click "Save" and it should work! I don't know what actually prevents Google Analytics code from running properly, but wrapping it with eval() call works.

No comments: