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

  • Home
  • Services
    • Biticodes
  • 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

Track WordPress Blog Comments in Google Analytics

5 Comments/ in Analytics / by Robert Kingston
April 17, 2010

Comments are really important to track, if you want to create a successful blog, for a number of reasons:

  • Comments create community
  • They add fresh, new content for search engines to crawl
  • Comments give you feedback

Tracking comments in Google Analytics lets you see what drives people to comment on your blog.

How to do it

1. Open up your WordPress Dashboard, browse to “Appearance”, “Editor” and find your comments code (usually, “comments.php”).

Click to enlarge.

2. Find the code that has something to the affect of “method=”post”” and “action=”<?php echo get_option(‘siteurl’); ?>/wp-comments-post.php””.

3. Insert the following code within the <form> tag itself.

If you have the normal GA code (this is most likely the one you need):

onSubmit="pageTracker._trackPageview('/tracking/comment-submit');"

Or, if you have the Asynchronous GA code (advanced users):

onSubmit="_gaq.push(['_trackPageview', '/tracking/comment-submit']);"

Like so:

<form id="commentform" action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" onSubmit="_gaq.push(['_trackPageview', '/tracking/comment-submit']);">

Click to enlarge.

4. Setup the goal in Analytics

Login to your account, click “Edit” beside your profile and “Add new goal”. You want to use URL destination as your goal type and in the goal URL, use exact match for “/tracking/comment-submit” (without quotation marks).

Click to enlarge.

Save that and you’re done! You’ll start seeing more actionable insights from your analytics from this point on.

← 5 Essential Google Analytics Tips for Bloggers
Track AdSense Clicks with Google Website Optimiser & Analytics →
Comments

5 Responses to Track WordPress Blog Comments in Google Analytics

  1. beto machado says:
    November 17, 2010 at 22:49

    hi,

    whats the difference between these 2 codes:

    onclick=””javascript:” _gaq.push(['_trackpageview',="" '=""/comment-submission.php']);”=””

    and yours:

    onSubmit=”pageTracker._trackPageview(‘/tracking/comment-submit’);”

    Im trying to track the post comments on this blog: http://www.adaoimoveisblog.com.br

    Thanks!

    Reply
    • Rob Kingston says:
      November 18, 2010 at 07:06

      Hi Beto,

      Well, as far as I can see there are four things:

      The top one uses incorrect javascript syntax and won’t work
      The top one is called when someone clicks the “Submit” button rather than when the form submits - in fact onclick may be the way to go here
      The top one seems to be referring to comment-submission.php - not that it matters (whatever you put in here just needs to be unique, so you can track it in Analytics)
      The bottom one seems to have been modified - the quotation marks are not the same (use ” and ‘ rather than ” and ’ for it to work)

      Reply
  2. sudhakar says:
    October 15, 2011 at 20:20

    Thanks nice submit form using php.

    Reply
  3. SEO Manchester says:
    July 21, 2012 at 00:34

    Wow, I didn’t even know this was possible, I’m going to implement it literally right now !!!!

    Reply

Trackbacks & Pingbacks

  1. 7 ways to get more comments on your articles | Socialmedia.biz says:
    November 27, 2012 at 23:32

    [...] is to set up a Google Analytics goal associated with a new comment. Here are some instructions on how to do this. You can also easily set up GA event tracking any number of ways using the Raven GA config [...]

    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
    • Biticodes
  • 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