Rich-text Reply

Making an experiment permanent for a user and not affected by clearing cookies

bananaleaf5 04-08-15

Making an experiment permanent for a user and not affected by clearing cookies

[ Edited ]



We're building a new experience for our checkout process that isn't really compatible with the old process. As such, when a user comes to the site, we need to put them in one of the two variations, but that decision needs to be permanent for their user record.


is there a way to make this a permanent choice such that clearing the user session won't result in them seeing the different experiment?



MJBeisch 04-08-15

Re: Making an experiment permanent for a user and not affected by clearing cookies

Are you asking specifically about session state or clearing cookies in general? If it's the former, then Optimizely already ensures that a visitor is always placed into the same variation for an experiment. This is accomplished by saving what variations a user is bucketed into the Optimizely first-party cookie. Read about it here:


Of course, this relies on a user not clearing their cookies. If it's the latter and you're asking about the possibility of ensuring a user will always be bucketed into the same variation even if they clear their cookies... Well, it would theoretically be possible, but difficult.


You could maybe use the Optimizely Javascript API to scrape the Optimizely data state and then pass the variation ID back into your CMS so it could be stored server-side and then have that data associated with that user. Then, whenever a user visited the page you're testing, you have to check for the presence of that variation ID data and again use the Javascript API to force bucketing into that variation ID (if it was present). This is quite a bit complex and wouldn't be easy to provide a working code sample here. Also, you'd need some way of idetifying the user outside of using a cookie, which is how most CMSes operate anyway.

Matt Beischel - E-Commerce Optimization Specialist CohereOne

Level 2
Ehsan 04-10-15

Re: Making an experiment permanent for a user and not affected by clearing cookies

Hi bananaleaf5,


To build on Matt's response, the variation served will be as permanent as the cookies on the visitors browser.  There are a few ways a visitor can lose their cookies.


  • They clear them from their browser
  • They use a private or incognito browser
  • They go to your site through a different browser


So if the visitor is using a private or incognito window when they are first bucketed, those cookies will clear once they close that browser, but not before then.


The good news is that anything that would clear the Optimizely cookies would also clear a visitors cart.  And given the nature of the checkout processes it may be safe to assune that visitors will enter and exit the checkout process before doing anything that would clear the record.  In other words, they won't leave halfway through, lose their cookies and then come back at another time because their cart would be empty again.


If they complete a purchase, clear their cookies, and come back to site a week later to buy something else though, it is possible that they will have a different checkout experience.


Check out our KB article titled How Optimizely Works: Snippet order of execution, JavaScript evaluation timing, and cookies for more details.


Is that helpful?  Please let me know if you have any follow up questions.