Archive for March 14th, 2009
How to Add Google Analytics to Your WordPress Blog
Posted by Patrick Patterson in Google Analytics on March 14, 2009
One 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). ![]()
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:
- Google Analytics for WordPress, Author: Joost de Valk
- Google Analyticator, Author: Ronald Heft, Jr.
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”

In the search bar, type “google analytics” to find all the plugins that deal with GA.
![]()
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 ![]()
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.

Enter your UA String in the box and click on “Update Settings”
Example:
![]()
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.














Recent Comments