Add to Google Add to Bloglines Add to Newsgator Add to Yahoo! Contact ROI Revolution Sign Up for the ROI Newsletter Unofficial Google Analytics Blog Feed Unofficial Google Analytics Blog
Unofficial Google Analytics Blog by ROI Revolution

Categories Search This Blog Blogroll Archive

| |

September 17, 2008

Installing Website Optimizer if you use Google Analytics

By Shawn Purtell, Google Analytics Support Tech

hands-geo.jpg 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.

urchin-vs-ga.jpg 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!

nerd-glasses.jpg
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. ecommerce-tree.jpg 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!

Posted by Shawn Purtell at 1:34 PM









Filed under: , ,

TrackBack

TrackBack URL for this entry:
/mt/mt-tb.cgi/322.

Comments

Hello,
one thing what i dont get is:
"Or maybe you have already noticed some strange things trying to use them together?"

what strange things happen? Is it really nessassary for me to change all thoses values? Or only If you want 100% diving into your analytics?

Bye
Bjorn

Posted by: Bjorn van der Neut at September 19, 2008 2:41 AM

@Bjorn:

I probably should have been more clear. By 'strange things', I really meant 'not working at all' or 'not reporting any conversions whatsoever', although I've seen many different kinds of problems arise from using incorrect code.

The whole reason you need to make these changes is that Google Website Optimizer actually uses Google Analytics cookies in order to work properly. If there is a conflict between the cookies Google Website Optimizer is using and the cookies that Google Analytics is using, you will often find that your experiments do not report correctly within Google Website Optimizer, if at all.

I absolutely recommend that you make code changes if you want the best data you can get. But don't take my word for it - you can find Google's official recommendation here concerning the use of ga.js. Also, there is a little help file from Google here that talks a little about _udn and _uhash, along with two other variables, but doesn't mention _setDomainName and _setAllowHash.

Hope that helps and thanks for reading!

Posted by: Shawn Purtell, Google Analytics Support Tech Author Profile Page at September 19, 2008 8:13 AM

I have also noticed that if you change the session timeout with GA, you also need to do that with the GWO tracking and conversion scripts.

Michael

Posted by: Michael Altman at September 19, 2008 9:55 AM

@Michael:

That's absolutely true. Changing the timeout will affect setup the same way as setting the domain name or changing the hash parameter. There is also another variable called _utcp which can affect setup, but the timeout and _utcp are used much less frequently that the others. Thanks for pointing this out!

Posted by: Shawn Purtell, Google Analytics Support Tech Author Profile Page at September 19, 2008 10:00 AM

Excellent post Shawn. Really helps in clarifying how to implement the integration of these two very powerful tools. I hadn't even realised that the GWO script could use the ga.js javascript function. Thanks again!

Posted by: EnjoyLifePlay.com - Secret Amazon Discounts at September 30, 2008 8:27 PM

Thanks for the compliment! This article ended up being more complicated than I originally intended, but there really are a lot of things to think about in order to make sure that the two codes work together correctly.

Posted by: Shawn Purtell, Google Analytics Support Tech Author Profile Page at October 1, 2008 7:48 AM

Nice Post. Thanks for sharing this information with us.

Posted by: SEO Services at October 10, 2008 4:52 AM

@SEO:

Thanks. I hope you found it useful.

Posted by: Shawn Purtell, Google Analytics Support Tech Author Profile Page at October 10, 2008 8:04 AM

Well written and helpful, as always, Shawn!

Look forward to seeing you guys again at Google HQ soon.

Chris

Posted by: Chris Goward at October 16, 2008 7:05 PM

@Chris:

Thanks for the compliment. We'll definitely see you there!

Posted by: Shawn Purtell, Google Analytics Support Tech Author Profile Page at October 17, 2008 7:40 AM

Isn't the _initData call needed before track call? Other samples that I saw include this call.

Another thing, this was working till I put in an adwords conversion script too in the goal page. This broke the website optimizer which is reporting no clicks. Any ideas?

Thanks,
Sanjay

Posted by: Sanjay Kanade at November 11, 2008 12:45 AM

@Sanjay:

._initData is now a depracated function that is no longer needed, although it won't hurt anything if it's there.

AdWords conversion tracker script should not interfere with Google Website Optimizer if everything is set up correctly. The two scripts do not share any variables or resources and should not affect each other in any way. It is possible that the position of your Google Analytics code will have an effect on your data, or that something else on the goal page is broken, causing the Google Website Optimizer code not to fire. Hope that helps!

Posted by: Shawn Purtell, Google Analytics Support Tech Author Profile Page at November 17, 2008 8:03 AM

Post Your Comments

Post a comment

Contacting ROI Revolution

Contact Us

Address:
3109 Poplarwood Ct.
Suite 219
Raleigh, NC 27604


Authorized Google Analytics Consultant

Google Analytics Certified Service and Support Consultant


Free Webinar!

Join a Live FREE Google Analytics Training Webinar
Register now to learn how to
turn Google Analytics into
pure profit! You'll learn how to use many of the key reports, a ten-step system for properly configuring Google Analytics on your website, and how to apply what you learn to the attainment of your online goals. Register for our free Google Analytics training webinar today.


Subscribe to the
ROI Revolution Google
Analytics Newsletter today

Free monthly email publication that contains valuable, practical tips, secrets, and much more! Subscribe to our free Google Analytics newsletter today.


Looking to Purchase
Urchin 5 Software or Fee
Based Support?

We are a Urchin software certified service and support partner! Buy Urchin 5 software, profile packs, load balancing modules, campaign tracking, or fee-based support today.