javascripthtmlgoogle-analyticsgoogle-website-optimizer

Google website optimizer and sub-domain tracking


I am setting up an A/B test with Google's website optimizer.

I have a page:

wwww.example.com/landingpage

and some variations:

www.example.com/landingpage0
www.example.com/landingpage1
www.example.com/landingpage2

the conversion page is on:

www.subdomain.example.com/goal

Website Optimizer's wizard interface, is not accepting the goal page because it's on "a different domain" and apparently there's no way to proceed with the next step. However, if I "fake" the procedure, and specify

wwww.example.com/fakeGoalPage

the wizard will allow me to continue the set-up.

What I do next is to put the goal-page code in my real goal page, and hope that the test will work. My question is if this practice is correct or if you can suggest me a better way to solve this problem..

Thank you


Solution

  • By default, Google Website Optimizer sets its cookies on the current domain (document.domain). So, the cookies from www.example.com won't be available when they convert on subdomain.example.com. The solution to that is to follow the instructions from this help center: Customizing Google Website Optimizer code for multiple subdomains?

    Basically:

    First, you add the following line just before your control script:

     _udn = ".example.com"; 
    

    Then you change your tracking and conversion scripts to allow for cross domain cookies.

    Assuming you're using the async syntax, that means this goes before the gwo._trackPageview.

    _gaq.push(['gwo._setDomainName', '.example.com']); 
    

    (An alternative is to set your goal as a URL on example.com, create that page, and then place the conversion script as the only thing on that page, and include it as an iframe on the conversion page.)