Basically, we want to A/B test 2 different page layout headers. There are some structural differences (it's not just switching out the CSS).
I've been able to get this much working: our Zend Framework (server side PHP) looks for a certain boolean variable to decide which HTML file to use as the layout (the original or the variation). This binary switch works beautifully. Each different layout is able to load nicely.
I just haven't been able to get the 0 or 1 from your GWO utmx("combination") function.
When during the page load is the result of that function available? For me, it seems like it always returns 0 regardless of when I call it. Or, when does the __utmx cookie get set? I could simply refresh the page after that is set. Is there a callback for the utmx() function?
I've tried multiple strategies, but my most recent plan was this:
In PHP code, check the __utmx cookie to get the assigned variation number. Save that to a custom cookie. Decide which layout to render based on that number. Then, in the javascript, after page load, it simply checks for the presence of the custom cookie, and if it's absent, it simply refreshes the page immediately (prompting the server-side code to look at the __utmx cookie as described above). That way, on a user's 2nd visit onward, my custom cookie already exists (containing the value of the variation) and can tell the server-side code which layout to use. On the user's first visit, right after GWO assigns the 0 or 1 for the variation, I'd use javascript to refresh the page so that my server-side code could read the __utmx cookie.
I haven't figured out when/how the __utmx cookie gets set though (or when utmx("combination") will work).
A/B test with Google Web optimizer; what cookie tells me visitor got A or B hasn't helped.
Server side code:
$cookieNameForThisExperiment = 'gwo_variation_header-and-navbar'; //This is for Google Website Optimizer split testing of the header-and-navbar
$variation1 = 'variation1';
if (!isset($_COOKIE[$cookieNameForThisExperiment]) && isset($_COOKIE["__utmx"])) {
$utmx = explode(':', $_COOKIE["__utmx"]);
$variation = $utmx[2]; //Careful: this will not work if there are multiple Google experiments running simultaneously and might not even work for testing more than "original" vs 1 "variation". http://productforums.google.com/forum/#!category-topic/websiteoptimizer/technical-questions/kilJ7lJU2NY
$variationName = 'original';
if ($variation == 1) {
$variationName = $variation1;
}
Extrabux_Cookie::setCookie($cookieNameForThisExperiment, $variationName, time() + (60 * 60 * 24 * 30));
}
if (isset($_COOKIE[$cookieNameForThisExperiment]) && $_COOKIE[$cookieNameForThisExperiment] == $variation1) {
$this->_helper->layout()->setLayout('main_new'); //Use new layout only in this variation.
} //Otherwise, continue using the original layout.