Home / Analytics & Testing / Tracking Multiple WordPress Authors with Google Analytics

Tracking Multiple WordPress Authors with Google Analytics

I wrote another post on how to track multiple authors in WordPress with Google Analytics once before, but got it wrong! Outside the WordPress Loop, you’re unable to capture the author names so the code did not work.

Sorry for the fail.

I’ve done some additional digging and found out how to do it smarter with multiple Google Analytics profiles. (Quite honestly – this is when you come to love professional analytics packages like Webtrends!)

Step 1: Add a Profile to an Existing Domain

The first step is to add an additional profile to your current domain. This is an option that most people aren’t familiar with but works perfectly for this type of scenario.

Step 2: Add an Include Filter to the New Author Profile

You’ll want to only measure page views tracked by authors in this profile, so add a filter for the subdirectory /author/. One note on this – I had to make “that contain” as the operator. Google’s instructions call for a ^ before the folder. In fact, you can’t write an ^ into the field!

Step 3: Add an Exclude Filter to your Primary Profile

You won’t want to actually track all the extra pageviews by author in your original Profile, so add a filter to your original profile to exclude the subdirectory /by-author/.

Step 4: Add a Loop in the Footer Script

Within your existing Google Analytics tracking and below your current trackPageView line, add the following loop in your footer theme file:
<p class="code">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
var authorTracker = _gat._getTracker("UA-xxxxxxxx-x");
authorTracker._trackPageview("/by-author/<? echo the_author(); ?>");
<?php endwhile; else: ?>
<?php endif; ?></p>

This will capture all of your tracking, by author, in a second profile for your domain. By excluding this tracking from your primary profile, you don’t add additional unnecessary pageviews. Keep in mind that if you have a home page with 6 posts, you’ll track 6 pageviews with this code – one for each post, tracked by author.

Here’s how the Author Tracking will look in that specific profile:
Screen shot 2010-02-09 at 10.23.32 AM.png

If you’ve accomplished this in a different way, I’m open to additional ways to track the author information! Since my Adsense revenue is associated with the profile, I can even see which authors are generating the most ad revenue :).

About Douglas Karr

Douglas Karr is the founder of The Marketing Technology Blog. Doug is the CMO of CircuPress and CEO of DK New Media, an agency specializing in assisting marketing technology companies with their inbound marketing - leveraging social media, blogging, search engine optimization, pay per click and public relations. Their clients include Angie's List, GoDaddy, Mindjet and many more. Douglas is also the author of Corporate Blogging for Dummies.

Check Also

Wistia Videos

Interview: Ben Ruedlinger of Wistia on Video Marketing

Ben Ruedlinger is the Vice President of Operations at Wistia. Wistia is the leader in …


  1. Great post Doug! An alternative for tracking Authors at this level is with event tracking in GA. You can get a tally of how many times each of your authors’ posts were viewed, in the same profile as your regular data, without inflating pageviews. Also, you can use multiple dimensions in the Event reporting to see what sources were driving visitors to various authors (e.g. who is attracting the most readers via Twitter), where they are coming from, etc. I tried to post the script, but I was over the character limit. Here is the link: http://www.wheresitworking.com/2010/02/08/tracking-authors-in-wordpress-with-google-analytics-event-tracking/

  2. Doug, you always seem to put up the right post at the right time, I’m going to implement this on our Indiana Insider blog (http://www.VisitIndiana.com/blog/) today!

  3. My Site (click to edit)

    Awesome, thanks for sharing this Doug! I’m finding that the_author() needs to be replaced with get_the_author() in order to prevent the author name being duplicated and outputted twice.

    Also, how does your solution compare with Adam’s?

  4. Doug, I tried to implement this, but it’s only tracking views of the actual author pages (…/author/AUTHORNAME), and not views of each post viewed, separated by author – any thoughts?

  5. Thanks very much. I’m trying this out now. One thing though, I removed “echo” out of the loop because it seemed to be duplicating the author name. For instance /by-author/Author NameAuthor Name was appearing with the echo.

  6. Thanks for the tutorial. I need to track the pageviews each writer on a news blog accumulates in order to pay them by views.

    Including the homepage doesn’t really work, though.

    Can you just exclude code from the homepage? If that code was inserted only in the single-page layouts (an option on custom webpages), would that work? excluding homepage views from the count?

  7. How do you do step 1 please: “add an additional profile to your current domain”

    You show how to complete the step, but not how to get there in the first place.

Leave a Reply