How to track Drupal comments as goals in Google Analytics
I was inspired by this episode of SEOMoz's whiteboard friday where Rand talks about tracking non-traditional conversions (like when someone posts a comment on your blog) so I decided to check out how easy this was to do in Drupal.
By default, when someone submits a comment, they are redirected back to the node to view their comment (even if it needs approval first). This causes a problem because it doesn't really give us a unique URL to use as a goal in Google Analytics (unlike the webform module).
What you'll need to do is grab the great actions module which we will use to redirect the user to a custom thank you page once their comment has been submitted. And while thats downloading and installing, create a new page that will be the thank you page when users submit a comment.
Next, navigate to Site Configuration > Actions and create a new advanced action to redirect to your new thank you page click save. Now, just head over to the Triggers settings (Site Building > Triggers > Comments) and assign your new action to the "After saving a new comment" trigger.
Now all you need to do is setup the goal in Google Analytics and wait for the data.
Do you have any other non-traditional conversions that you're tracking? If so, what are they and how are you tracking them?


Comments
Nice tip.. not using it atm,
Nice tip.. not using it atm, but it's a good usage of actions module
It would be nice to keep the
It would be nice to keep the user experience while still collecting the data. Lets muse on this a bit more.
I've just had a thought of
I've just had a thought of how this could be done by adding an extra line to the Google Analytics code that will allow us to track the goal, while still redirecting the user back to their comment. I'll play around with that this weekend and let you know how I go.
Subscribe
;-) subscribed
Non Traditional Conversions
Great idea. If you find a way to do this then I'll use it on my site.
On a related point I'm trying to find a way to get an action to send me an email with the text of the comment. The "%body" variable sends the body of the original post rather than the comment.
Post new comment