8

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");
pageTracker._trackPageview();
} 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?

2
  • 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
    Commented Aug 17, 2011 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'
    Commented Aug 17, 2011 at 20:02

2 Answers 2

2

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");
pageTracker._trackPageview();
var pageTracker = _gat._getTracker("UA-profile-code");
pageTracker._trackPageview();
} 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.

0

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()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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