Setting flags for A/B testing on page being tested

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.
jtolentinoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

leakim971PluritechnicianCommented:
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
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ray PaseurCommented:
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.
0
Julian HansenCommented:
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?
0
Ray PaseurCommented:
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
0
jtolentinoAuthor 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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.