Installing Website Optimizer if you use Google Analytics

 

 

Ok, so back when I declared that Google Website Optimizer and Google Analytics represented ‘A Perfect Marriage’, I was overlooking some of the early bumps the newlyweds would experience before they lived happily ever after.

That being said, there are some things to look out for if you are using Google Analytics and are considering Google Website Optimizer as your testing platform of choice. Or maybe you have already noticed some strange things trying to use them together?

Here are the things to look out for:
1. Are you using urchin.js or ga.js?
2a. Are you setting _udn=”something” (for urchin.js) or _setDomainName(‘something’) (for ga.js)?
2b. Are you setting _uhash=”off” (for urchin.js) or _setAllowHash(false) (for ga.js)?
3. If you are using urchin.js, are you tracking Ecommerce?

As long as you’ve got the above four things accounted for, everything should work fine. So I’m going to address each one in detail so that you know exactly what to do.

Before we get into the actual implementation, I’d like to go over the scripts that Google Website Optimizer and Google Analytics use, just so that we’re on the same page.

gwo-codes.jpg

For Google Website Optimizer
Google Website Optimizer uses up to four different scripts:

The Control Script (GWO-CS)
This is the longer Google Website Optimizer script that goes at the top of your test page. I’ve labeled it as script #1. I’ll refer to this as GWO-CS.

The Section Scripts (GWO-SS)
These scripts are only used for multivariate experiments. They go around sections of your pages that you are testing. We won’t be changing these at all. I’ve labeled this as #2 in the diagram.

The Test Page Tracking Script (GWO-TS)
This is the Google Website Optimizer script that goes at the bottom of your test page. I’ll refer to this as GWO-TS, and it is #3 in the digram.

The Conversion Script – also known as the Conversion Page Tracking Script (GWO-CONV)
This is the Google Website Optimizer script that goes at the bottom of your conversion page. I’ll refer to it as GWO-CONV, and it’s all by itself as #4 in the diagram.

The Google Analytics Tracking Code (GATC)
This is your Google Analytics code, including any modifications you may have made to it. There is an urhin.js version and a ga.js version. You will need to look at this code to see if you need to make changes to the Google Website Optimizer scripts.

Now that I’ve identified the scripts we are dealing with, let’s address each item on my list from the beginning of this article, and I’ll show you how to deal with each scenario.

 

1. Are you using urchin.js or ga.js?

If you are using urchin.js:

You can go ahead and move on to Item #2 as there is nothing more you need to do here. The only thing I would recommend is that you include the GWO-TS and GWO-CONV after the GATC script on the test and conversion page, respectively. Also, if you are using Ecommerce, see item 3.

If you are using ga.js:

In this case you will have some changes to make. Thankfully, they are pretty easy. First things first, make sure the GWO-TS comes after the GATC.

Then, change the GWO-TS so that it uses ga.js. If you’re original GWOTS looks like this:

Change it to:

Please note that these changes will only work if this code comes after the GATC with the ga.js call.

You’ll also have to change the GWO-CONV on your conversion page. It’s just like the GWO-TS, but you have to change the word ‘test’ to the word ‘goal’ in the _trackPageview function, like this:

Change it to:

That’s it! Now just check items 2a and 2b to make sure you don’t need to change the GWO-CS and you’ll be good to go!

2a. Are you setting _udn=”something” (for urchin.js) or _setDomainName(‘something’) (for ga.js)?
2b. Are you setting _uhash=”off” (for urchin.js) or _setAllowHash(false) (for ga.js)?

I’ve grouped these two together, because the solution for each is very similar. Regardless of whether you are using urchin.js or ga.js, you’ll need to watch out for the above lines of code. If one or both of these apply to your GATC, then you’ll need to add some code before the GWO-CS on your test page.

If you have either _udn=”none” or _udn=”domainname.com” in your GATC, or if you use pageTracker._setDomainName(‘something’), add the following bit of code before the GWO-CS:

You have to change “enter_value_here” to whatever your value for _udn or _setDomainName is. This will make sure the cookies for GWO and GA play nice with each other.

The same applies if you set _uhash=”off” or _setAllowHash(false). If you do either of these, use the following code:

Finally, if you have both of these things, you need to do both, like this:

Notice that regardless of whether you are using urchin.js or ga.js, you’ll use the urchin.js variables before the GWO-CS. This is true as of 9/18/2008, but will most likely change in the future.

If you are using ga.js, you may need to add a line or two to the newer GWO-TS and the GWO-CONV:

Basically, these values will need to match what’s being used in your GATC, only for optimizerTracker.

 

3. If you are using urchin.js, are you tracking Ecommerce?

I’m not going to go into too much detail, but I’ll try and cover the basics. To try and make it as simple as possible, in order for GWO to not interfere with Ecommerce tracking for urchin.js – everything needs to be in the following order:

1. Hidden GA Ecommerce form
2. GATC
3. __utmSetTrans() function.
4. GWO-CONV

If the GWO-CONV comes before the __utmSetTrans() function, then the transaction data gets sent to the wrong account number. If you’ve been having trouble with your Ecommerce data when trying to use GWO, having the wrong order is most likely the reason.

I hope you’ve found these tips helpful. Feel free to leave a comment if you’ve benefited from this advice or have any questions – I read all comments and try to respond promptly to each one. If you are still having trouble using Google Website Optimizer, feel free to contact us about our Support Plans, or consider attending one of our Online or In-Person training seminars. Our next live training is in Alexandria, Virginia on December 4th, 2008. Hope to see you there!

Share This Page

Posted by

Leave a Reply

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