I was asked recently how to setup a blog with Google Analytics. Google has made the process extremely easy but I’ll show you step-by-step how it’s done.

  1. Create an account with Google Analytics
  2. Add a website profile for your blog. Click on the link to Add Website Profile.

  1. Enter the information about your blog. Click the radio button to create a profile for a new domain and then enter the base URL for your blog without the leading http. For example, tedwise.com.

  1. On the next page you’ll see a warning message that the tracking code is not yet installed. Of course, it’s not installed, we haven’t been given the tracking code yet. The tracking code is JavaScript that runs every time a user views your blog. This is, by far, the hardest part of setting up Google Analytics.

The bottom of the page shows you the EXACT code you need to copy and paste into your blog’s HTML. The code should be placed right before the closing </body> tag.

  1. Copy the tracking code and insert it into your blog. This is where the instructions get hazy. You need to find the code in your blog that displays the footer. The footer is the part of your site that displays at the bottom of every single page, whether your blog is displaying the front page, a blog article or a history page.

If you’re not comfortable with editing HTML I highly suggest using a blog plug-in. For WordPress there are several plug-ins for activating Google Analytics support.

To edit the HTML for WordPress, go to the wp-content/themes directory and find the theme that you are using. For example, on my blog, it’s wp-content/themes/connections-reloaded. If you’re using WordPress, there should be a file in that directory named footer.php. Before you modify the file you should copy it to a backup location. Then edit the file and copy the tracker code from the Google Analytics page into it. Google recommends you place it just before the closing </body> tag in your footer.

If you’re using some other blog software you’ll need to search through the files to find the footer HTML.

  1. After you save the modified file, bring up your blog to make sure you haven’t broken anything. If the page looks broken, replace the modified footer with the copy you made and try again. If the page looks normal, right click on it in the browser and select View Source. Scroll all the way to the bottom and make sure that the tracking code is present and identical to the code that Google gave you. Again, the code should be BEFORE the </body> tag, not after it.

  2. If you go back to the Google Analytics site the dashboard will display an error icon next to your site.

That’s normal. Google hasn’t verified your new code yet.

  1. At this point you’re done setting up your site with Google Analytics. After some time the error icon should change to this:

This icon indicates that Google has verified the code is present but isn’t receiving enough data yet. When the hits start pouring in, the icon will change to this:

At that point, you’re in business! You can go into Google Analytics and start seeing the hit data and make use of the tracking features. It shouldn’t take more then a day or two before the icon turns into a green check mark. If it does then tracking code probably wasn’t installed properly. Take another look at it.

BTW, the eBook ‘Digging Into Wordpress’ has helped me understand Wordpress development.