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:
<?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:
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 :).
Consider why machine learning and predictive analytics can provide top- and- bottom- line value to organizations like yours with the right tools, training, and processes for a range of objectives and use cases.