How to Add Google Analytics to Your WordPress Blog


shades-1.jpgOne of the first steps to setting up this web analytics blog was to install Google Analytics so that I could track my success (or failure). More than likely I will be using a lot of real world examples about Google Analytics from this blog, so I thought I would start with a little tutorial to get your blog up and tracking correctly.

(At the time of this post I was using WordPress 2.7.1, while the exact names of the links may change, the theory still remains true.)

Manual Method

If you are a coder form a previous life, an avid Google Analytics user, or just not a WordPress user, you would probably just want to go the manual route and add the code yourself. To do that, it’s pretty straight forward: 1) Go to WP Admin, 2) Click on “Appearance” on the left hand side, 3) Click on “Editor”, 4) Find and select your “Footer (footer.php)” file, 5) Right before the </body> tag, copy and paste your Google Analytics code from the set up screen, 6) Click the “Update File” button at the bottom, 7) Enjoy analytics (in about 12-24 hours). shades.jpg

This solution will work for a lot of you, but I would advise against this. Whenever you update the source of a file in your theme or in the WordPress build itself, you run the risk of losing that code anytime you upgrade. Also, with the above method, you will lose the tracking if you switch themes. OH NOESSS! That’s not good! So what are we to do?

Plugins

WordPress has these nifty little things called plugins. They are code extensions of your blog that can do a lot of amazing things. Do yourself a favor and check out the different plugins that are available, you may stumble across the fix to a problem you have always had, or a feature that you always thought was missing. A search shows you that there are lot of different plugins available to make this a very easy task. The two most up-to-date and commonly used plugins for GA are:

Some benefits of going the plugin route:

  • Track outbound links, quickly and easily
  • Quickly move the code from the header to the footer without touching a file
  • Exclude the “admin” user from tracking (you don’t want to inflate your numbers do you!)
  • Both of these plugins provide a much easier experience for installing Google Analytics as well.

After reviewing their features, I ultimately chose “Google Analytics for WordPress”. I thought both of them offered very similar feature sets, but it seemed like GA for WP was updated more frequently and had a better following. Quick updating is always important in the analytics world.

Quick Guide

Go to your Admin Section and click on Plugins. Next, click on “Add New”
shades-2.jpg

In the search bar, type “google analytics” to find all the plugins that deal with GA.
shades-3.jpg

Click on the plugin you want to install, read through the various features and comments. Click the “Install Now” button.

After installation go ahead and shades-5.jpg

Now, it is important to point out here. YOU ARE NOT DONE. You still need to insert your Google Analytics report ID#. You can find this in your GA tracking code “var pageTracker = _gat._getTracker(“UA-#######-1“);” Make sure you have your code and click on the new “Google Analytics” option under your Plugins menu.

shades-6.jpg

Enter your UA String in the box and click on “Update Settings”

Example:
shades-7.jpg

Congratulations, you are now tracking your blog. Within the plugin settings, you will see some advanced settings that we will get into further posts. For now, wait about 12-24 hours and verify that everything is tracking correctly and start making some valuable insights into how to optimize your blog.

No related posts.

, ,

  1. #1 by Kevin Hillstrom on March 14, 2009 - 11:16 pm

    Good luck with your blog and Twitter page!

  2. #2 by Patrick Patterson on March 14, 2009 - 11:18 pm

    Thanks Kevin! I’m just getting started here with blogging. Hopefully I can rise to the occasion. :)

  3. #3 by Birte on April 26, 2009 - 11:20 am

    Amazing. Had just put in the code, and as not sure if I had done it correctly.
    I had just received a twit that you were following me, and I checked out your website, and found this, and more on GA.
    Talk about coincidence.
    It seems, thanks to you, that I did do it right. I am looking forward to reading more on this. A bit above my head sometimes, but that’s the only way to learn.

(will not be published)