Advanced Conversion Tracking For Your Blog.

Tracking conversions within a blog is a lot different to that of e-commerce websites. With an e-commerce website you will be generally looking at product sales, contact form enquiries, etc, whereas on a blog the goals are completely different. I’m going to show you how you can easily track all kinds of online conversions on your blog within Google Analytics.

Google Analytics Event Tracking

Event tracking within Google Analytics is feature that allows you to record user interactions on your website in various ways. For example, you can track when anyone clicks an external link on the site, subscribes to your newsletter, plays a video and much more.

You can set up event tracking by simply adding some extra code to your hyperlinks. The default event tracking code looks like this:

onclick=”_gaq.push([‘_trackEvent’, ‘category’, ‘action’, ‘label’]);”

This code is essentially broken up into the following:

Category: This is the type of event that is being tracked; for example, ‘Affiliate Link’, ‘RSS’, ‘Newsletter’, etc.

Action: This is used to identify the type of action that is related to the event; for example, this could be the product/company name of the affiliate link being tracked, it could be ‘Subscribe’ to signify RSS or Newsletter subscriptions, or it could be ‘Play’ to record video plays.

Label: This is an optional field that I use to attach the URL that the event occurred on.

If I were to track a newsletter subscription that happened on my WordPress category page, then I would use the following tracking code:

onclick=”_gaq.push([‘_trackEvent’, ‘Newsletter’, ‘Subscribe’, ‘/wordpress/’]);”

So, looking at this bedded into a full hyperlink, it would look like this:

<a href=”/feed/” title=”Subscribe to our RSS” onclick=”_gaq.push([‘_trackEvent’, ‘Newsletter’, ‘Subscribe’, ‘/wordpress/’]);”>Subscribe to our RSS</a>

Affiliate Links

One of the big revenue generators for blog sites is to run affiliate links. If you look within the header and sidebar of Find My Blog Way then you will see some of these affiliate banners that I run. I track all of the clicks from these site-wide and in-post banners within Google Analytics so that I can understand which posts on the blog have generated the most affiliate revenue, which sites are giving me the highest conversions from their referral traffic and much more.

Setting Up Site-Wide Banner Tracking in WordPress

One of the issues that you may have with tracking some of your affiliate links is that you have them dynamically placed within your sidebar or header. This can cause issues when trying to place in the correct URL for the event tracking ‘label’. Luckily, there is a quick way to dynamically pull in the URL that the banner is on when a link is clicked – an example of this code would look like this:

onclick=”_gaq.push([‘_trackEvent’, ‘Affiliate’, ‘ManageWP’, ‘<?php echo $_SERVER[‘REQUEST_URI’]; ?>’]);”

You can use the above line of PHP when setting up event tracking on any dynamically generated links. If you want to do this within your ‘Widgets’, then you will need to add the following code to your functions.php file that will allow you to use PHP within them:

add_filter(‘widget_text’,’execute_php’,100);

functionexecute_php($html){

if(strpos($html,”<“.”?php”)!==false){

ob_start();

eval(“?”.”>”.$html);

$html=ob_get_contents();

ob_end_clean();

}

return $html;

}

So here’s what that looks like for one of my affiliate links that I have in my ‘Widgets’ area of WordPress:

And then when I navigate to the blogging category page of the site (/blogging/) and view the source code, it looks like this:


Viewing the Results in Google Analytics

Once your event tracking code has been implemented, you will be able to see this data within Google Analytics. To find this information, navigate to Content>Events and you will be able to see each of the different user interactions and drill down deeper on information related to them.

The next step is to set up some conversion goals related to your events. This will help you to measure your affiliate clicks against other metrics, for example, affiliate clicks by traffic source, affiliate clicks by referral, top pages for affiliate clicks, etc. To set this up, do the following:

  • Navigate to the Admin area within Google Analytics and select your blog’s profile from the ‘Profiles’ tab.
  • Select the ‘Goals’ tab and click ‘Create a New Goal’.
  • Select the ‘Custom’ radio button on the goal setup page and press next.
  • Type a name for your goal in the goal description page (e.g Affiliate Link Click) and select the ‘Event’ goal type, then press next.
  • Finally, in the ‘Category’ event field, type ‘affiliate’ and press Save Goal (as shown below).

You can now use this goal as a conversion metric within Google Analytics.

Newsletter and RSS Feed Subscriptions

Like with affiliate link clicks, RSS feed subscriptions and newsletter subscriptions can be a key conversion metric for blog owners. You can easily track this within Google Analytics using the same type of method as the aforementioned affiliate example.

Link Up Your RSS Feed Button

Where you have a ‘Subscribe to my RSS feed‘ link on your blog, you will want to add the following code to the hyperlink:

onclick="_gaq.push(['_trackEvent', 'RSS', 'Subscribe', '<?php echo $_SERVER['REQUEST_URI']; ?>']);"

You can then follow the steps above to create another conversion goal within Google Analytics, except this time you will have ‘RSS’ as the event category field.

Tracking Newsletter Subscriptions

There are two ways that you can track your email signups, depending on how your forms work. The first way is to redirect your users to a ‘thank you’ page once they’ve clicked the submit button on your newsletter signup form. If you do this, you can create a new goal in Google Analytics using the ‘Sign Up’ template.

When you press next, select the goal type as ‘Destination’ and then type in your confirmation page as the destination value (e.g. /thank-you/).

The second option is to use event tracking on the submit button itself. To do this, you can add the following code to your newsletter signup submit button:

onClick="_gaq.push(['_trackEvent', 'Newsletter', 'Subscriber', '<?php echo $_SERVER['REQUEST_URI']; ?>']);"

An example of how this would look within the submit button code would be as follows:

<input id="contact-submit" class="button" type="submit" value="Submit" onClick="_gaq.push(['_trackEvent', 'Newsletter', 'Subscriber', '<?php echo $_SERVER['REQUEST_URI']; ?>']);">

You can then set up a conversion goal within Google Analytics that is similar to the affiliate and RSS goal, except you will want to change the event category field to ‘Newsletter’.

Contact Form Submissions With Contact Form 7

If you use the Contact Form 7 plugin for WordPress then you can easily add the event tracking code within the ‘Additional Settings’ box at the bottom of your contact form settings page. You will need to use the on_sent_ok hook for this plugin, which adds in the event tracking code for you. Here’s an example of what the code would look like:

on_sent_ok: "_gaq.push(['_trackEvent', 'Contact Form', 'Submit']);"

Tracking File Downloads

Another frequent conversion metric used within blog sites is to track the number of file downloads from posts. For example, this could be an eBook PDF. This is done in the same way that I have outlined for the affiliate link example; however, there will be a slight difference with the tracking label. Due to the fact that these download links will often be within your articles, it isn’t always possible to add PHP to your article body (especially when using WordPress. This will mean that you need to write in the URL label manually, for example:

onClick="_gaq.push(['_trackEvent', 'Downloads', 'WordPress eBook', '/wordpress-tips/']);"

You can then set up your conversion goal within Google Analytics to track all of the downloads from the site. You can even be more specific about your conversion goals and only look at specific file downloads. Using the WordPress eBook example above, we could track WordPress eBook downloads by inputting the following to our event goal fields:

Social Media Shares

Another great metric to keep track of is the number of times your blog content has been shared across social media websites. This can be done in a similar way to the affiliate link example above, but social interaction tracking uses ‘_trackSocial‘. Each social network manages the tracking codes slightly differently, but you can view a full list of all supported networks that integrate with Google Analytics and implement the tracking on your social sharing buttons for each.

By default, Google+ already integrates with Google Analytics using _trackSocial, but once you have set up the rest of your social sharing buttons, you will be able to get a full breakdown of shares across your content.

Track Embedded YouTube Video Plays, Pauses and Buffers

Considering that I regularly create tutorial videos on my YouTube channel and embed them within posts on the site, it made sense to start tracking things like video plays as a conversion metric. I was looking around for quite some time on how to do this in a way that wasn’t overly time-consuming and came across an awesome post from Luna Metrics.

All you need to do to set up YouTube video tracking is add the following code to the head section of your webpages:

<scriptsrc="//code.jquery.com/jquery-1.7.2.js"></script>
<script type="text/javascript" src="http://www.lunametrics.com/js/lunametrics-youtube.js"></script>

It’s really that simple. If you like, you can download the JS script and add it locally, rather than downloading it from Luna Metrics server each time.

Tracking Search Engine Keyword Rankings

Another awesome way to make use of Google Analytics event tracking is to take a look at your search engine rankings directly within Google Analytics. This can be used to measure conversions from keywords ranking in specific positions, which is perfect for blog owners. I found out how to do this within a post by Justin Cutroni, and all you need to do is add the following JS code to your site:

if (document.referrer.match(/google.com/gi) &&document.referrer.match(/cd/gi)) {
varmyString = document.referrer;
var r = myString.match(/cd=(.*?)&/);
var rank = parseInt(r[1]);
var kw = myString.match(/q=(.*?)&/);
 
if (kw[1].length > 0) {
varkeyWord = decodeURI(kw[1]);
} else {
keyWord = "(not provided)";
}
 
var p = document.location.pathname;
_gaq.push(['_trackEvent', 'RankTracker', keyWord, p, rank, true]);

The Tracking Options Are Endless

You can pretty much track any kind of conversion metric within Google Analytics using the methods shown above, so get creative! I will be showing you how to set up some custom conversion reports and dashboards within Google Analytics within the next few weeks so make sure you check back on the blog.

Visited 2 times, 1 visit(s) today

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.