Sunday, May 8, 2011

Setting up Google Analytics for your blog

This article shows how to add Google Analytics to your blog.

Google Analytics and Blogger

Google Analytics is one option if you want more detailed statistics about your blog than you can get from Blogger's Stats tab.  It provides more features than most bloggers need, but it can be handy to use it from the beginning anyway, so that you have historical data when you do eventually want more detailed statistics.

It works by running a small script each time that a person views a screen from your blog:  this reads some information about the person, their computer and what content they looked at, and adds it to a statistical database that you (and Google) can get reports from.  It only collects data (number of visits, length of time spent, etc) from when the script is installed into your blog.  Initially you had to install the code yourself, but a change that Blogger made in October 2011 made this a lot easier.

Now, to install it into your blog, you simply have to:
  • Set up a profile for your blog in Analytics
  • If your blog uses Dynamic Views or has a Mobile template enabled (*)  (either all the time, or as an option):  put the Web Property ID you get assigned in Analytics into your blog's options, AND
  • Put the tracking code into your template, AND
  • Save the changes that you have made to your profile  (be careful - it's easy to forget this step!)

(*)  At the time of writing (15 Oct 2011) the help materials weren't 100% clear about the status of mobile templates.   My best guess is that you should install the Web-Property-ID anyway, just in case.   But I will update this article if I find any more information.

How to set up an Analytics profile

1   Log in to Analytics, using the Google account that you want to do reporting from.    (If you're already logged in to Google when you go to that page, you may need to click the blue Access Analytics button).

This doesn't have to be the same account that owns or even has administrator rights to the blog that's being analysed - so long as you can figure out how to copy some code from Analytics into the blog.)   Personally, I keep my Analytics statistics in the same account that I use for AdSense and AdWords.

2   From the Analytics Settings tab, choose Add New Profile  (currently it's a link on the right hand side of the page)

3   Choose Add a Profile for a new domain  
(I'm assuming that anyone reading this article doesn't already have a profile to be extending.)

4   Enter the name of your blog (including the www at the beginning of the URL), and press Continue

In the next steps, you need to copy two different items from this screen.   So it's best if you leave this open, and switch to another screen to continue.

Putting the Web Property ID into your options

5   Copy the Web-property-id from the top section of the screen:

6   Add ito your blog:
  • Go to Settings > Other
  • At the bottom of the screen, you will find a field for Google Analytics account number - paste the value you copied into this field
  • Click Save Settings at the top of the screen

How to add the Analytics code to your site

Analytics is used by many people running websites built with all sorts of tools, so the standard installation instructions are very general:
Copy the following code, then paste it onto every page you want to track immediately before the closing </head> tag

The Previous Instructions given by Analytics

The detailed instructions link in Analytics leads to the appropriate section in the Analytics help-centre.  At one stage, this had a link to Blogger-specific instructions, but this seems to be gone.   But I'm pretty sure that it said to find the  <body> tag and paste the code from Analytics immediately after it.   This still works, but it's harder to describe now, because some templates put other content in the body statement, and you need to locate the place after the angle-bracket ">" that closes the <body statement.

Searching the help-centre for "blogger" shows various articles, including some that tell you to put the code into your template just before the closing </head> statement.    Some of these remind you to download a full copy of your template before making changes to it - and none of them warn you about the disadvantages of editing your template.

Another Alternative

An alternative suggested by Google engineers in some places is to install the tracking code into a HTML/Javascript gadget - this is Option 1 in ways to install 3rd party HTML into your blog.

A major advantage of this approach is that your statistics won't be interrupted if you change templates:  remember that changing templates keeps your gadgets (though it sometimes moves them around), but deletes any template changes that you have made.

You do need to decide where to put the gadget:  it doesn't actually show anything on the screen (except perhaps a small space that looks blank to your readers), but visitors to your will be "counted" when the gadget runs:  if your blog page takes a long time to load, and your gadget is in the footer, then visitors who don't wait for the entire page to load before clicking away won't be counted.  Personally, I like to put the gadget immediately under the Blog Posts gadget, like this:

Blogger Page Elements design screen, with area under the Blog Posts gadget highlighted

IMPORTANT:  Don't forget to press the orange Save button after your have shifted the gadget to where you want it to go.

After the code is installed, it takes a little time (maybe even 24 hours) for tracking to start.   Once it's started, you can get reports by selecting the profile from the View Reports drop-down in the Analytics application.

Related Articles

Advantanges and disadvantages of editing your template.

Planning changes to your blog's template

Advertising on your Blog:  some things to consider

How the data in Blogger is organised

Blogs, bloggers and Blogger, Post, Pages and Screens - some basic concepts

AdSense and AdWords - understanding the difference

Share this Article


HTML link code:

BB (forum) link code:

Subscribe to Blogger-hints-and-tips

FeedBurner will send a confirmation message. Click the verify link in it to start your subscription.

Follow Me on Pinterest Subscribe to Blogger-HAT on Google + RSS subscription icon Follow BloggerHAT on Twitter


  1. Okay, you're site is just the best. I should just come here instead of roaming around google to find the answers to my questions.
    It would save me a lot of time! I just implemented the analytics html into a gadget and placed it right under the posts gadget. I was worried that it might create a blank space on my page but it doesn't.
    Thanks for all of your help.

  2. Hi, Thanks for the tip. I added the tracking code to the gadget and placed it at the bottom of my blog...but it is visible to the reader not blank. Any thought?

  3. Sue, are you sure you copied the entire code from Analytics, and pasted it into an HTML/Javascript gadet - the gadget from Blogger that you see when you go one click down the list of widgets. (There are some 3rd party ones that come up when you search in the gadget list, but they don't always work.)

  4. Hi there, I need help! Please! haha... So I've just started my first blog, and I just don't have a clue about HTML. I don't know where to start in setting up my analytics - I've done most of what you've explained above, but the html I have attempted and failed at... Please could you explain where I start & how to do It!! Thank you so much.