• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 301
  • Last Modified:

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.
2 Solutions
what about forgetting javascript for this part?

Additionaly, I see two articles at the end of the page
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.
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?
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
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Build your data science skills into a career

Are you ready to take your data science career to the next step, or break into data science? With Springboard’s Data Science Career Track, you’ll master data science topics, have personalized career guidance, weekly calls with a data science expert, and a job guarantee.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now