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 Google Analytics code (which looks something like the following).
var gaJsHost = ((“https:” == document.location.protocol) ? “https://ssl.” : “http://www.”);
document.write(unescape(“%3Cscript src=’” + gaJsHost + “google-analytics.com/ga.js’
var pageTracker = _gat._getTracker(“UA-XXXXXXX-X”);
Install Google Analytics
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.
Configure Goal Tracking For Blog Registrations
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…
Configure Analytics For Blog / Page Comments
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;
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;
That’s all there is too it. You have now setup goal tracking on your WordPress blog.