Analytics & Testing

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.
existing-profile.png

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!
Include-author.png

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 :).

Douglas Karr

Douglas Karr is CMO of OpenINSIGHTS and the founder of the Martech Zone. Douglas has helped dozens of successful MarTech startups, has assisted in the due diligence of over $5 bil in Martech acquisitions and investments, and continues to assist companies in implementing and automating their sales and marketing strategies. Douglas is an internationally recognized digital transformation and MarTech expert and speaker. Douglas is also a published author of a Dummie's guide and a business leadership book.

Related Articles

Back to top button
Close

Adblock Detected

Martech Zone is able to provide you this content at no cost because we monetize our site through ad revenue, affiliate links, and sponsorships. We would appreciate if you would remove your ad blocker as you view our site.