Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am tracking the pageviews that each of my authors' articles generates on a Wordpress site with Google Analytics Event Tracking:

var pageTracker = _gat._getTracker("UA-xxxxxxx-x");
} catch(err) {}
<?php if ( is_singular()) { ?> 
pageTracker._trackEvent('Authors','viewed','<?php the_author_meta('ID'); ?>'); 
<?php } ?>

I have an event category "Authors" and there's an event label for each of their IDs. How can I give each author access to the data for their respective label without giving them access to other author's stats and the sites stats as a whole?

share|improve this question
Where did you find the protocol for GA that tells you that you can use php calls where the label goes? pageTracker._trackEvent('Authors','viewed','<?php the_author_meta('ID'); ?>'); – user9649 Aug 17 '11 at 10:20
[This should've been a comment, by the way.] The PHP doesn't matter. GA will never see it. Remember, the GA code is Javascript and so happens in the browser. By that point, the server has already rendered the PHP bit as an actual value(the author's ID here), which is what GA will see. – Su' Aug 17 '11 at 20:02

You can set up multiple profiles for each site you add to Analytics, and give users access to specific profiles. I believe then it would simply be a matter of duplication the tracking code for the author on the page, something like this:

var pageTracker = _gat._getTracker("UA-base-code");
var pageTracker = _gat._getTracker("UA-profile-code");
} catch(err) {}

UA-base-code would be your ID for the main site profile (accessible by you) and UA-profile-code would be the profile associated with the article's author.

If that doesn't work, you might want to take a look at the Analytics API - it would take a bit of work, but you could create a mini app that just gives each user the appropriate data.

share|improve this answer

For a quick solution you can:

  • email reports, using your existing events (thus giving the author the information you have collected with the event thus far)
  • insert an iframe with a small page containing the tracking code (which can be hidden), or if the author prefers they can host a small page themselves elsewhere (living with the slightly decreased page speed)
  • give the advice on http://www.webmasterworld.com/analytics/3781851.htm a shot - here they use different variable names for the tracker and call _initData() before _trackPageview()
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.