Counting a conversion when a link is clicked using Google Website Optimizer

We recently needed to test the effectiveness of a new landing page. This is a classic A/B test so we used Google Website Optimizer (GWO) to set up and manage the test. Using GWO the way to implement this test is to add the Control script to original (A) page; the Tracking script to both the test pages (A and B); and the Tracking script for the Goal page. When the visitor clicks on the link (or button) for the Goal page, a conversion is counted.
conversioncount1
Pretty straightforward stuff. Unfortunately in our case we were testing a new landing page and whilst we were able to add the Tracking code to the test pages, we weren’t able to add the tracking code to the Goal page.

So how can we implement the test without adding the Tracking script to the Goal page? Or, in other words, how can a you count a conversion when a link (or button) is clicked?

The trick is to add a Javascript function to the test pages which contains the tracking script for a goal in a onclick event. Thus when a visitor clicks on the call-to-action (which sends the visiter to the Goal page) the goal is counted by GWO.
conversioncount2

The script and usage for this is as follows:

<script type="text/javascript">
function ConversionCount() {
	var pageTracker=_gat._getTracker("UA-xxxxxxx-x");
	pageTracker._trackPageview("/yyyyyyyyyy/goal");
	return true;
}
</script>

<a href="goal.html" onclick="return ConversionCount()">Goal</a>

This method can also be used in situations where you need to count conversions on another domain, or where you want to track conversions such as the download of a PDF or a form submission.

Leave a Reply