Setting flags for A/B testing on page being tested

jtolentino
jtolentino used Ask the Experts™
on
Dear experts,

I'm doing some A/B testing on our company's store. We have some logic (written in JavaScript) that creates a visitor ID for new visitors (as a cookie), but this is loaded asynchronously after being pushed as Google Analytics (via _gaq.push). The value of this visitor ID (a number) is used in the A/B test, where odd numbered IDs go to page A and even numbered IDs to page B.

Occasionally however, a new user will land on the page being A/B tested. The dilemma is Google Analytics is not loaded yet, as is our JavaScript which sets the visitor ID, so we always end up with a zero result which goes to page B. Looking at the overall picture, we'll have more in page B due to this problem.

At the moment, the solution I've thought of involves checking with PHP if the visitor ID cookie exists. If it doesn't I'll have some sort of intermediate page whose sole purpose is just to set the visitor ID and then return the user back to the page they requested. It will all happen very quickly, but it produces a slightly annoying flicker

Do you see a more elegant solution to this or am I just going overboard with the annoying flicker?

Thanks in advance.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Multitechnician
Top Expert 2014
Commented:
what about forgetting javascript for this part?
https://code.google.com/p/php-ga/

Additionaly, I see two articles at the end of the page
Most Valuable Expert 2011
Top Expert 2016

Commented:
Create two Google Analytics accounts?  Or maybe use jQuery document.ready() to keep the timing straight.  You can also set the cookie in the PHP script.

The point of cookies is to carry stateful information from request to request, so it's almost implicit in the design that new clients would be easy to identify since they would not have any cookie.  Maybe there is a third state you want to design into consideration in addition to A/B.
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
The dilemma is Google Analytics is not loaded yet, as is our JavaScript which sets the visitor ID
I am confused though - if you put your code in a document ready function why would GA not be loaded yet?
Most Valuable Expert 2011
Top Expert 2016
Commented:
Actually now that I have read the comment from @leakim971 I would try that solution first.  It looks like it would give you 100% control and would be easily extensible for other test cases.  You could ditch the GA JS entirely!

Best regards, ~Ray

Author

Commented:
Thanks for the responses.

@leakim971: This looks quite promising. We actually need the data from Google's __utmz cookie (the cookie that stores information on how you got to the site). I haven't seen any mention of it, but we've identified some things that would simplify the task at hand.

@Ray_Paseur: Yes, we've actually started by trying to set to cookie in PHP. What we did was to generate the visitor ID independently, then just add logic later that gets the visitor's source information.

@julianH: We do the A/B test splitting on the server-side, so the page (and Google Analytics) doesn't load yet.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial