Track Multiple Authors with Google Analytics

Google Analytics

On a multiple author site, each author can post in a multitude of categories, it’s nearly impossible to identify each author’s contributions to the overall strategy of the site. I was doing some testing with this recently and identified a nice simple way of measuring traffic by each author.

Google Analytics has the ability to track additional virtual pages. This is typically utilized to track outbound links to advertising or calls to action to landing pages. However, by simply manipulating your Google Analytics code on your single post pages, you can track the popularity of individual authors.

Typical GA code on a page looks like this:

var pageTracker = _gat._getTracker("UA-XXXXXX-X");

You can insert a ‘virtual’ pageview by adding the following:

var pageTracker = _gat._getTracker("UA-XXXXXX-X");
pageTracker._trackPageview("/by/author/Douglas Karr");

To customize for WordPress:

var pageTracker = _gat._getTracker("UA-XXXXXX-X");
<?php if (is_single()) { ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
pageTracker._trackPageview(?/author/<?php the_author() ?>?);
<?php endwhile; ?>
<?php } ?>

UPDATE: A couple of commentors pointed out that it didn’t work – I had to add the famous WordPress loop in!

This will only load the necessary pageview on a Single Post page. You may want to extend this to monitor the first post on the home page as well, but this is at least a start. Within Google Analytics, you can open a Content Report and simply filter it by “/author/” to get a list of all of the authors and their associated page views, bounce rates, time on page, and conversions.

Now you can begin rewarding your authors for the actual contribution they bring to your organization! Let me know if you run into issues using WordPress – I wrote the code and didn’t test it.


  1. 1

    Oh, NICE! I don’t have multiple authors on my blogs yet, but will definitely bookmark this for when that should occur. Great tips!!

  2. 2
    • 3

      Hey yawza!

      The easiest way, using the method above is to open the content report and filter by “/author/”. At that point, you can email the report to yourself weekly. Google Analytics does a nice job of saving filters on emailed reports (I wish they would allow saving the report that way!).


  3. 4

    I have tried installing your Code but its not working for me. I have 4 authors In My WordPress Blog and here is the code that i have pasted Just before the tag in my template

    var gaJsHost = ((“https:” == document.location.protocol) ? “https://ssl.” : “http://www.”);
    document.write(unescape(“%3Cscript src='” + gaJsHost + “’ type=’text/javascript’%3E%3C/script%3E”));

    try {
    var pageTracker = _gat._getTracker(“UA-XXXXXX-X”);


    } catch(err) {}

    I have replaced UA-XXXXXX-X with My ID …. Please tell me whether My code is right or wrong.

    When i look at the source i See Only One author Displayed. And for your Information I am Not using any WordPress plugin .

    Please help ! I need this Badly ..

    Thank you

  4. 5

    I believe that method of tracking will only work if your permalink structure includes the author. Mine does not so how can I track pageviews for a specific author when my url structure is

    Can the code be modified to use the _setVar function?

    I have tried the following code:

    var pageTracker = _gat._getTracker("UA-XXXXXXX-X");



    but I’m not sure I understand how that function operates or if it’s working. I’m new at this.

    • 6

      I believe I know what the issue is, you MUST wrap the php in the WordPress loop. Unfortunately, WordPress doesn’t distinguish whether it’s a single page or not. I’m going to update the code in the blog post.

  5. 7

    to add onto my preview comment…

    A problem I am having is that must be called within the Loop but normally you put the GATC in the footer or header, not in every template file that holds a loop. Thoughts?

    • 8

      Matt – I think you and I happened on the response at the same time, it must be within the loop. I’ve modified the code and believe the loop will still function outside the body and in the footer. It could probably be simplified by setting a variable within the normal loop and then calling it from the footer.

      Some of the commentors have been testing – we’ll see if this works well! I could see it slowing down a page, though.


  6. 9
  7. 10

    Still waiting for Your New code …. Douglas . I think You should Include Include an IF Else tag for both the home pages and the Single post pages…. tried it myself but didnt worked…

  8. 11

    This is a great insight on GA usage. I will surely share this with my clients. Thanks for posting this. Funny how we easily forget that Javascript can be manipulated when we are so busy adding code to pages!

    TGP — Truly a Great Post!


  9. 12

    I have try this code on joomla.

    after 2 day of stat… I see only /autor/someauthor in my stat. I dont see the real uri of the page anymore.

  10. 13

    So, what is the verdict here? I am very intrigued with this code but I don’t have room for mistakes. Douglas, what’s the word? I don’t see much chatter after your last post regarding success/not.

    Thanks and great idea!

  11. 14

    Verdict is that it’s 50% of the solution, Ross! You must specify the author in the Loop… if you do, then it will correctly pass the author info to Google. However, Google has since changed it’s data capture and allows more than one variable now… so I would abandon this method altogether. I’ll try to write a follow up!

  12. 15

    Hey Douglas,
    I’m also looking for a solution to track author-specific content in WordPress using GA. I’d love to see an updated version of this code as I need it for one of my multi-author blogs. Would you be able to write a follow up? I’ll write about it and give you some props. 🙂 Thanks for the awesome insights as usual.

  13. 16

    Thank you for the quick reply Doug, I look forward to seeing the update when you have a moment. Cheers on a great post and great followup!

    Ross Dunn

What do you think?

This site uses Akismet to reduce spam. Learn how your comment data is processed.