Prusak.com

Serving up my thoughts since 2004

Google Website Optimizer and Analytics Bugfix

A few weeks ago Shawn Purtell from ROI Revolution wrote an excellent article on combining GWO with GA. If you haven’t read his article – please do so now. This posting describes a bug fix for his code, but you really should first read his article to fully understand how to use it.

I just found a bug in his code and am providing a fix for it. Under some circumstances, his code will provide the wrong combination number for the combination that is being displayed. Different combinations can be given the same combination number.

Please note: If you only have a single section on your page, Shawn’s code works fine as is.

To properly use the new getcombo function, you need to pass in a parameter. The parameter is a string with the number of variations in each section, seperated by dashes.

For example, if the first section has three variations, the second section has four variations and the third section has two variations you’d call the function as such:
getcombo(‘3-4-2‘);

If the first section has five variations and the second section has two variations, you’d call the function as such:
getcombo(‘5-2‘);

The javascript code with the bug fix can be -> downloaded here. <-

In order to allow a simple replacement of Shawn’s version, getcombo does not require a parameter. If you do not pass in any parameter, the function uses the same calculations as Shawn’s version, which did not require a parameter.

In order to get a better idea of how the bug can effect the combination number you get, I created a page that shows the different results you get from the old and the new versions of getcombo(). It lists all of the possible combinations for an experiment with two sections and between two and four variations for each section.

You can see the test page here.

Please note: The page is actually running each version of getcombo() to product the results. You can view the page source to see the javascript I wrote to test the two versions. 

 Please let me know if you have any questions.

– Ophir

3 Comments

  1. I would like to know how to use the getcombo function when i have a few GWO tests running at once?

  2. Eli,
    the getcombo function will return the combo information for the first experiment in the cookie. If you are running multiple GWO tests that were hit upon, the utmx cookie will contain this information and grabbing the first may return the combo information for the wrong experiment.

    Example of google utmx cookie with 2 tests. The experiment id has been hidden and replaced by “xxxxxtest1” and “xxxxxtest2” in the below example. “test1” was an experiment where I visited Variation 1 and “test2” was an experiment where I visited Variation 2:
    __utmx
    53881888.0000103110xxxxxtest1:2:1.0000097245xxxxxtest2:1:2

    In order to grab the correct combo, you need to pass into the function the experiment id that you are looking for combo information for. You also need to split the cookie on “.” to split up the different experiments – then you can split the data on “:”. I am not very good with javascript but the below function works for me. NOTE: It will NOT work if your multivariate experiment also has multiple sections having variations (it will only work if you have one section with multiple variations). For the multi-section/multi-variation to work, the code that fixed the bug in the getcombo function would have to be adapted to this function and you’d have to pass into this function both an experiment id and the number of variations you have in each section. I hope this helps someone but please use this at your own risk and please excuse my lack of Javascript knowledge – hopefully a real javascript programmer can pull this all together & post a better function that works for all scenarios.

    function multiexperiment_combo(experimentid)
    {
    if (document.cookie.indexOf(“__utmx=”) != -1)
    {
    var utmx_cookie_value = readCookie(‘__utmx’);
    var cookie_data_array = utmx_cookie_value.split(‘.’);
    for(i=0; i0)
    {
    return combination_id;
    }else
    return 0;
    }
    }
    }

    }
    }

    To use this function, follow all installation instructions for using the getcombo function. Then modify gwo_analytics_integration.js and add this new function. On your Test page where you would normally call the getcombo function – just call multiexperiment_combo(“xxxxxtest1”); function instead. Replace “xxxxxtest1” with your actual experiment id given by google when you set up your experiment. If you don’t know your experiment id, look at your conversion page code snippet given by google for the line that looks like this:

    urchinTracker(“/xxxxxtest1/goal”);

  3. Hello,
    thank you for this script, it seems to be very cool 🙂
    Does it work with the new GATC : GA.JS ?
    Best Regards,
    Y

Leave a Reply to J Cancel reply

Your email address will not be published.

*

© 2024 Prusak.com

Theme by Anders NorenUp ↑