I’m sure you have heard of Google Analytics which enables you to track the behaviour of a site. The key to success with Analytics is using website goals. This allows you to conveniently measure the success of your website to criteria you dictate. For a blog (for me), 2 goals would be a user registration - and a user posting a comment on a page or post. For this, we need to ensure tracking is on all appropriate pages and that the goals are correctly configured.
If you haven’t already - you should be using the new Google Analytics code (which looks something like the following).
<script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> var pageTracker = _gat._getTracker("UA-XXXXXXX-X"); pageTracker._initData(); pageTracker._trackPageview(); </script>
The new version has many new features (which I am not going into in this post) - but it allows you to use a function we need to track blog comments (namely an onclick event).
Firstly, make sure the Google Tracking Code is on all pages. You can do this by editing your themes footer.php file. Simply paste the Google Code before </body>. But you’re not done yet. You need to edit wp-login.php. Search for </body> and before every instance add your Google code here too. This will put tracking not only on your blog contents, but also registration and various front end forms too.
You are now ready to configure Google Analytics to track goal actions on your blog. To start with, we will setup the goal for a user registration. Remember the additional code we added to wp-login.php? This is where it comes into use. Create a conversion goal based on the screenshot below. I always give a goal conversion like this a value of 1 - due to reporting and keyphrase / traffic reports - which assigns a calculated money value field to various keywords and traffic sources to work out profitable items.
To make sure this goal is only counted when people register (and not just visit the page), add the following funnel configuration too;
There we have it. If you leave this goal running for a while - you will be able to see exactly what keywords / traffic sources are driving registrations - and infact - whether your registrations are growing or falling…
The new version of Google Analytics allows us to track onclick events. Every comments box has a submit button or image. We can track when this button is clicked using Google Analytics. To get your head around this concept, we setup what we call a virtual page view (a page that doesnt actually exist - the submit button) and we link this virtual page view to a goal in Analytics.
The first thing to do is edit your themes template file - namely comments.php. Unfortunately, you will need a little bit of HTML knowledge to find the HTML code for the submit/image button. Once you have located this, add the following code to the input object;
onclick=”javascript: pageTracker._trackPageview(’/goal/wordpress.html’);”
Thats it! Now - everytime the submit button is pressed on the comments form - analytics will log that /goal/wordpress.html has been visited. This leaves the logical conclusion to add a goal conversion to this page. See the screenshot below on how to do this;
Thats all there is too it. You have now setup goal tracking on your wordpress blog.
Feel free to discuss this post in the web developer forum we have on TD Creative. I look forward to your comments.
15 Responses for "How To Track Wordpress Signups and Comments With Google Analytics"
[...] Original post by DooBDee [...]
[...] Using Google Analytics to track comments. [...]
Thanks for the article. Just implemented this on my blog and looking forward to seeing the results. I can’t believe I didn’t look for something like this when I first switched to Google Analytics.
[...] How To Track Wordpress Signups and Comments in Google Analytics [...]
Thanks for this post, it helps me to solve my problem. Just I’m not sure, not so good in javascript, but when I copy the code, there was problem with single quote in ’/goal/rss.html’ there needs to be ‘. Is this possible?
Hello Marten,
Try this (it must be the way Wordpress renders quotes);
'/goal/rss.html'Cheers
[...] this goal, check out TD Creative ‘tracking comments in google [...]
[...] * How To Track Wordpress Signups and Comments With Google Analytics [...]
[...] For more technical information on how to configure this goal, check out TD Creative ‘tracking comments in google [...]
[...] For more technical information on how to configure this goal, check out TD Creative ‘tracking comments in google [...]
[...] There are a ton of resources for implementing this type of technology. For Google, go to the Analytics Help section. Here is a random link to a blog post I found on the topic just doing a Google search. : How to count a comment as a goal in Google Analytics. [...]
[...] No he encontrado ningún plugin que lo haga automáticamente, así que os tengo que explicar cómo hacerlo manualmente, basándome en el método que he encontrado aquí. [...]
[...] Setting goals for blog registration requires adding Google Analytics code to the wp-login.php page, which may not be tracked by the Google Analytics plugin. (I should read the code… nah… I leave for the reader: dig through Joost’s source for GA Plugin to see whether he inserts tracking into the wp-login.php page.) [...]
[...] on the blog the numbers are yet unknown. I have started tracking in GA using the technique found at http://www.tdcreative.net/blog/how-to-track-wordpress-signups-and-comments-with-google-analytics/ but if anyone has a better method let me [...]
[...] Idéen er nærmere beskrevet her: http://www.tdcreative.net/blog/how-to-track-wordpress-signups-and-comments-with-google-analytics/ [...]
Leave a reply
You must be logged in to post a comment.