• Follow us on Twitter
  • Add me on Linkedin
  • RSS

  • Home
  • Services
  • Tools + Calculators
    • Google Analytics Content Targeting Generator
    • A/B/n Split Test Confidence Calculator with Graphing
    • Simple Feedback Form with Google Analytics Integration
  • About
  • Contact

Blog - Latest News

4 Unique Google Analytics Segments to Use on WordPress

5 Comments/ in Analytics / by Robert Kingston
December 6, 2010

What good are your Analytics if you can’t make sense of the data and suit it to better your needs? Sometimes, you can get more meningful information out of the reports by customising the data to suit your needs. For instance, have you ever wondered what the value of comments are on your pages? How about determining the longevity of posts? Or seeing which author rocks up the higher number of pageviews per month?

4 Segments to help answer those questions…

Here are some great segments you can get out of WordPress. In the following order:

  1. Author name
  2. Number of comments
  3. Post date
  4. Logged in or not
// 1. This will show the Author's name in your Analytics
_gaq.push(['_setCustomVar',2,'Author','<?php the_author(); ?>',3]);
// 2. This will show your comments number for each post in Analytics
_gaq.push(['_setCustomVar',3,'Comments-Number','<?php echo get_comments_number(); ?>',3]);
// 3. This will display the date a page was posted in Analytics (you may need some regex to get the value out of this one)
_gaq.push(['_setCustomVar',4,'Post-Date','<?php echo get_the_date(); ?>',3]);
// 4. Finally, this set's the user's session as a logged in user or a logged out user
_gaq.push(['_setCustomVar',5,'Logged-In','<?php if ( is_user_logged_in() ) { echo 'Yes'; } else { echo 'No'; }; ?>',2]);

Implementing these custom variables

I suggest reading up on Google’s Custom Variables documentation and the WordPress Codex for more detailed instructions about these sorts of custom variables (both of these sites are fantastic resources for developers). From my experience though, you will need to consider a couple of things:

  1. Some of the PHP functions I presented above can only be called from certain parts of the page
  2. You may need to consider where your Google Analytics script runs
  3. You MUST set the custom variable before _trackPageview, but after _setAccount - otherwise it will not track

Of course, you don’t want to go crazy and implement any custom variable just for the hell of it either. Think first about what you need out of your reports and what you’re going to act on before wasting slots you may need in the future.

Let me know if there are any more great segments you like to use as a blogger, in the comments.

← Track Leads from Traffic Source to Point of Sale in Google Analytics
Why CRO Gives More/Less Than You Bargained For →
Comments

5 Responses to 4 Unique Google Analytics Segments to Use on WordPress

  1. Dries says:
    June 5, 2011 at 23:54

    You could filter the author and see which post did best, so you can advise him to post in a certain category he’s good at. So you’ll get a more structured approach on who’s posting what and keep content fresh in each category.

    Reply
  2. Robert Kingston says:
    June 6, 2011 at 19:52

    Totally… if you ran a blog with multiple authors, this would be a hell of a variable to track.

    By the way Dries, I’ve found that all of this can be achieved through Joost de Valk’s Google Analytics plugin for WordPress which is exceptionally good (not too sure how resource intensive it is, but it got me to switch).

    Reply
  3. Dries says:
    June 7, 2011 at 03:00

    Not all sites run WordPress :)

    Reply
  4. Robert Kingston says:
    June 7, 2011 at 18:43

    Indeed… I eat my own words.

    No doubt others could apply these in Drupal, Joomla or another blogging platform.

    (+ title changed - thanks Dries)

    Reply
  5. Burak says:
    November 4, 2012 at 16:22

    Is it possible to show top 10 authors based on google analytcis? Thanks for the article.

    Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

About Rob

I'm a freelance web analytics and optimisation specialist that helps companies make data driven decisions to improve sales, revenue or other objectives. Currently, I work with clients in education, retail, banking, energy and not for profits. Enjoy my site!

Subscribe For More Great Tips


Subscribe by RSS


Follow me on Twitter


Categories

  • Analytics
  • Conversion Rate Optimisation
  • Marketing & Consumer Insight
  • News
  • Testing

Most Popular Posts

  • Track WordPress Blog Comments in Google Analytics
  • Google Analytics’ New Site Speed Report Tracks Page Load Times
  • Build a Conversion Rate Heatmap by Hour & Day of Week in Google Docs
  • Cohorts.js: Open Source JavaScript MVT Split Testing Framework
  • Track What Visitors Copy From Your Site in Google Analytics

Recent Posts

  • A Guide to Measuring Split Tests in Google Analytics & Other Tools
  • Web Browsers Most Susceptible to Browser Fingerprinting
  • Cohorts.js: Open Source JavaScript MVT Split Testing Framework
  • 10 Sources of Direct Traffic & How To Track Direct Shares
  • Track What Visitors Copy From Your Site in Google Analytics

Blogroll

  • Analytics Ninja
  • Justin Koro
  • LunaMetrics Blog
  • Marketing Experiments
  • Mint Metrics
  • SnowPlow Analytics
  • Teacup Marketing
  • Home
  • Services
  • Tools + Calculators
    • Google Analytics Content Targeting Generator
    • A/B/n Split Test Confidence Calculator with Graphing
    • Simple Feedback Form with Google Analytics Integration
  • About
  • Contact
418Follower294Subscribers
© Copyright - Optimisation Beacon - Wordpress Theme by Kriesi.at