Get the most out of Google Analytics and Thesis for WordPress

There are many things you can do with Google Analytics, WordPress, and a little Thesis theme magic, but really the tips I’ll go over here don’t require Thesis. Most of what you’ll learn here can also be applied to just about any WordPress theme with a bit of customization.

Before I lay the tips on you, let me point out that there’s a useful plugin called Stats. Don’t let the name fool you, the plugin is for self hosted ( blogs. In addition, you might also want to use Popular Posts (you need Stats for this plugin); the Popular Posts plugin gives me that widget on the sidebar of I like using the Stats plugin because it provides a quick, rough idea in real-time of my blog traffic, which isn’t Google Analytics’ strong suit.

Tools you’ll need

There aren’t many things you’ll need to improve the data collection from your blog using Google Analytics. Start with these plugins:

This tutorial assumes that you have a Google Analytics account, have it set up, and have some very basic understanding of how it works. This isn’t a tutorial about how to use Analytics, it’s to show you how to capture customized blog traffic and action data with Analytics if you’re using a Thesis theme (or not).

Tip 1: Installing your Analytics code

We have to start with this one if you’re using the Thesis theme: under Thesis > Site Options > Stats Software/Scripts never add your Google Analytics code here (I don’t know anything about Mint or other stats software). Never. I know what the fine folks at DIY Themes say; still, don’t install your Analytics code using their method. If you do, then Analytics will also be tracking page views of your traffic on the site, which doesn’t make much sense. To get the most accurate site traffic data, you shouldn’t be tracking any of the administrators, editors, or authors on the site (or at least segment that traffic, which you can do with a Analytics plugin). This is one reason you’re going to install the Google Analyticator plugin, to cut out all of undesirable traffic from your stats.

Tip 2: Getting the most out of your Google Analytics plugin

Before we start customizing the theme, let’s get the most we can out of our Analytics plugin. I’m going to reference Google Analyticator, but for the most part all of the WordPress Analytics plugins have the same features.

As I said above, you do not want to track logged-in users, so make sure that feature is turned off. There are now more granular options in the plugin for logging specific user roles, such as premium subscriber or subscribers. This is a nice feature.

Enable both “event tracking” and “outbound link tracking”. When visitors click on outbound links or downloads, those are events that should be tracked.

If Google Adsense ads are on your site, you should definitely enter your account ID (make sure your Adsense and Analytics accounts are linked). This is going to give you much more information in Analytics, such as what pages are generating the most ad clicks. If you have one page that’s outperforming all the others, you can study the page for the reasons the ads are performing well and try to replicated that formula on other pages.

Tip 3: Using tracking codes for site visitor behavior

Links good for event tracking

Tracking the behavior of visitors to your site might be important. For example, wouldn’t you like to know every time someone subscribes to your RSS feed? That’s an event to be tracked. If you’re using the Thesis theme that may be tricky, depending on what you’re looking to track. In this example, I’ve developed a RSS subscribing widget that fits my needs, that includes other things like a YouTube, Flickr, and LinkedIn links (in another tutorial I’ll go over my “stay in touch” widget). I can go in there and manually edit all those links. First, the code you’ll need:

<a href=""
onClick="pageTracker._trackEvent('category', 'action', 'optional label');">Anchor Text</a>

What you need to do now is customize the variables of the event: category, action, and optional label. For example this is how I might track people clicking on my LinkedIn profile link:

<a href=""
onClick="pageTracker._trackEvent('intouch', 'followlink', 'linkedin');">Anchor Text</a>

Many people get confused about what variables that can or should use when tracking events. The short answer is, there is no wrong answer; it’s totally up to you and what kind of data that you want to gather. With that said, you want to be smart. In this example, my logic was pretty simple. For the category I used the name of the area where I’m tracking links; any tracking code under Stay In Touch will have the category of “intouch”. The action I was tracking was following links, thus I used “followlink” (note: I will probably use this action with other links on the page because it isn’t category dependent). Lastly, the label is “linkedin”, which is self explanatory; this label should be the one unique variable that you use.

These variables are important because they’ll help you create some great reports in Analytics. In this example, I can create reports that tell me all about the Stay In Touch area (category), or create reports about one specific action on my site (followlink), or I can combine “followlink” and the label “linkedin” (imagine I was tracking multiple “linkedin” links on my site) and see in total how many people were clicking on my LinkedIn profile link. You could go wild creating customized reports if you capture the right data.

Tip 4: Advanced data capture

Let’s continue with the same example, my “stay in touch” widget. But now I want see how effective that widget is on my home page, compared any other page on my site. I’m thinking that even though my home page gets the most traffic, for some reason the widget’s not performing as well as when it’s on a single entry page. That’s the premise for this tip.

"stay in touch" with widget logic

Given this problem, what I need to do is create two “stay in touch” widgets that are the same except for the tracking code, then serve these different widgets onto the appropriate pages (home page, then all other pages).

To begin, we need to install the Widget Logic plugin I mention above. There are similar plugins that purport to be simpler, but I don’t find them such because their user interfaces are convoluted. With the Widget Logic plugin and a little knowledge about WordPress conditional tags, you can do some clever things.

If you look at the image to the left you’ll see my “stay in touch” widget with the Widget Logic field highlighted. That’s where you enter the conditional tags (this example is simple; using PHP you can get pretty elaborate). We’re going to create two of these widgets, one that has is_front_page() (is the front page) and the other with !is_front_page() (is not the front page) in the Widget Logic field.

Next we want to make changes to our tracking code, leaving everything else untouched for our experiment. For the home page (is_front_page()) I’ll use this as the tracking code:

onClick="pageTracker._trackEvent('intouchhome', 'followlink', 'linkedin');"

and for all other pages (!is_front_page()) I’ll use this tracking:

onClick="pageTracker._trackEvent('intouchothers', 'followlink', 'linkedin');"

Notice how I changed up the category? Now in Analytics I can create reports comparing the two.

Of course, this is a simple example of what you could do using Widget Logic. If you’ve done some other cool things, please drop a note in the comments.

I’ve got many other ideas for Thesis/Analytics tutorials. What do you think would be most useful?

2 responses

  1. Thanks for the tutorial.

    I’ve always wondered about tracking and such.

    Now that i’m redoing my site, i’ll think about adding events and tracking to see where people go and do.


    1. You’re most welcome! I’ve got a bunch of other tips I’ll be posting in the future. Stay tuned.