Analytics & Digital Marketing Tips

Website Optimizer Tips for Tracking Complex Conversions

Website Optimizer Tips for Tracking Complex Conversions

December 18, 2008           Google Analytics, Conversion Testing

You don’t need to have a separate page to track Website Optimizer conversions

We’ve learned that many people struggle with how to setup conversion tracking in Google Website Optimizer for videos, product demos, ajax forms, multiple forms on a page, or other pages that either have multiple desired actions or don’t have any clear actions. We’ve provided three solutions for tracking these complex conversions using GWO’s Javascript code to either track the time on page, link clicks, or form submissions as a conversion.

Conversion Tracking for Videos & Demos

Want to know how well your videos or product demos are working? You can test the effectiveness of one video style versus another style of video using the time on page as a conversion goal. For example, if the two videos you are testing are say 2 minutes long you can set the conversion to be counted when they reach the full 2 minutes. Or maybe count a conversion at the point where the meat of the video wraps up (say at 75% of the way through the video at the 1 minute and 30 second mark). This type of conversion tracking is a great way to be able to utilize Google Website Optimizer to determine which video your users respond better to.

Google Website Optimizer Javascript Code for tracking time on page
To use this method you will need to add the code below, in place of the Conversion code provided in the Website Optimizer tool. This new code should be pasted into the page after your tracking script, and immediately before the </body> closing tag. You’ll need to update the _uacct and urchinTracker variables with your own account numbers (they’ll be the same numbers that appear in your tracking script on the same page).

<script>
if(typeof(urchinTracker)!=’function’)document.write(‘<sc’+’ript src=”‘+
‘http’+(document.location.protocol==’
https:’?’s://ssl’:’://www’)+
‘.google-analytics.com/urchin.js’+'”></sc’+’ript>’)
</script>

<script>
setTimeout(‘_uacct = “UA-xxxxxx-x”;urchinTracker(“/xxxxxxxxx/goal”);’, 60000);
</script>

To modify the amount of time that should elapse before a conversion is counted, change the 60000 figure above. This figure represent milliseconds, so 60000 equals 60 seconds.

Google Website Optimizer Conversion Tracking for Link Clicks

If you don’t have one specific conversion page because more than one link destination page (i.e. action) from a page can count as a conversion than this is a great technique to use.

Code for Tracking Links as a Conversion
First, put this code below right after the <body> tag:

<script>
if(typeof(urchinTracker)!=’function’)document.write(‘<sc’+’ript src=”‘+’http’+document.location.protocol==’
‘)”>https:’?’s://ssl’:’://www’)+’.google-analytics.com/urchin.js’+'”>’)
<!–
function ConversionCount()
{
_uacct = ‘UA-XXXXXXX-X’;
urchinTracker(“/XXXXXXXXXXX/goal”);
return true;
}
// –>
</script>

Next, put this code on every link you want to track. Your link would look like this:

<a href=http://www.yahoo.com/” onclick=”return ConversionCount();”>You text link</a>

Google Website Optimizer Conversion Tracking for Ajax Forms

If you don’t have one separate conversion page due to the use of Ajax forms that submit to the same page or have multiple forms that submit to multiple destinations you can use this technique to track the specific forms actions that you want to count as a conversion.

Javascript Code to track a form that submits to the same page like an ajax form use this code on the onsubmit:

<form action=”/cart.html” method=”post” onsubmit=”return ConversionCount()”>

Questions?
Leave a comment here or ask a question on our Google Website Optimizer Group on LinkedIn

 

  • Thanks a bunch! This is just what I needed 🙂

  • This was a good read unfortunately I still don’t get it! Where am I suopposed to add the code etc? where do I get the code from?

  • Google Website Optimizer was the best investment I ever made. Google Website Optimizer is worth much more than I paid. Best. Product. Ever!

  • Anonymous

    Conversion Tracking for Videos & Demos are quite impressive

  • Hey Kayden, great tutorial! Thanks for the share!

  • Jan

    Hi Kayden,

    can you please explain how do you track link clicks in GWO?
    1; can I track more than 1 link as a goal in GWO, if so how?
    2; what do I put into the confirmation page field in GWO?
    3, can I track outbounds links too?

    Regards

    Jan

  • Hi Jan,

    It is important to note that this article was written 2.5 years ago.  As such, the syntax used in this document is now outdated.  When you setup a new experiment in GWO, it will provide the most current, asynchronous version, of the code.

    1) You can track as many link clicks as you like, if they satisfy your definition of a conversion.  Each of those links should have an onclick attribute added to the ‘a’ tag that fires the GWO conversion/goal _trackPageview.  In the NEW version of the code, it would look something like:
    <a href=”my-file.pdf” target=”_blank” onclick=”_gaq.push([‘gwo._trackPageview’, ‘/xxxxxxxxxx/goal’]);”>Download My File</a>

    Note: Replace those x’s with your actual experiment ID.

    In this case, you would use this same /goal URL on the gwo Tracker to track the conversion.  A helpful article to read is http://www.blastam.com/index.php/2011/04/how-to-track-downloads-in-google-analytics/ which explains more on how to track file downloads or other links via the onclick attribute.  If you are not opening your links in a new window/tab, some browsers will fail to track properly.

    2) In the setup of GWO, you can put in anything.  It doesn’t matter.  You will, however have to perform an offline validation in order to start your test.  The same is true for any other URL.  It doesn’t matter what you put into the GWO setup.  It all works based on cookies and _trackPageview’s

    3) Yes, see example above in #1.  To make things easy, add a target=”_blank” to the ‘a’ tag.

    Hope that helps!

    Joe

  • Hi Jan,

    It is important to note that this article was written 2.5 years ago. As such, the syntax used in this document is now outdated. When you setup a new experiment in GWO, it will provide the most current, asynchronous version, of the code.

    1) You can track as many link clicks as you like, if they satisfy your definition of a conversion. Each of those links should have an onclick attribute added to the ‘a’ tag that fires the GWO conversion/goal _trackPageview. In the NEW version of the code, it would look something like:
    <a href=”my-file.pdf” target=”_blank” onclick=”_gaq.push([‘gwo._trackPageview’, ‘/xxxxxxxxxx/goal’]);”>Download My File</a>

    Note: Replace those x’s with your actual experiment ID.

    In this case, you would use this same /goal URL on the gwo Tracker to track the conversion. A helpful article to read is http://www.blastam.com/index.php/2011/04/how-to-track-downloads-in-google-analytics/ which explains more on how to track file downloads or other links via the onclick attribute. If you are not opening your links in a new window/tab, some browsers will fail to track properly.

    2) In the setup of GWO, you can put in anything. It doesn’t matter. You will, however have to perform an offline validation in order to start your test. The same is true for any other URL. It doesn’t matter what you put into the GWO setup. It all works based on cookies and _trackPageview’s

    3) Yes, see example above in #1. To make things easy, add a target=”_blank” to the ‘a’ tag.

    Hope that helps!

    Joe

  • Jan

    Hi Joe, thanks, very helpful. By the way, downloaded the .pdf you attached, but couldn’t open it. Receiving an error message: it’s either not supported file or it wasn’t correctly decoded. Can you please have a look at it? Thanks…Jan

  • Hi Jan,

    The .pdf file was just an example of a link and the syntax of using an onclick to track it; not an actual file. 🙂

  • Jan

    Sorry, didn’t realize.

  • Jan

    Joe, didn’t you miss the code in the point 1 as you finished your sentence with ‘In the NEW version of the code, it would look something like:’, but the code is missing. Thanks again.

  • Sorry about that.  Take another look at the comment.  For some reason, the code adjusted itself and it wasn’t showing the ‘a’ tag code (but instead rendering it as a link).

 

Analytics Blog

We're here to help with tips and insight on the following topics:

Subscribe to RSS


Optimize your website and marketing campaigns

Get a constant flow of Google Analytics help and digital marketing tips, case studies and more from Google Certified Partner Blast Analytics & Marketing.




Connect with Blast Analytics & Marketing