Rich-text Reply

Dealing with disabled cookies

klarna 05-06-15

Dealing with disabled cookies

Hi, our application is hosted inside an IFrame that's hosted on a domain A, where as the IFrame content is loaded from our domain:


I know that Optimizely does use first party cookies but, in this case, these so called 'first party'  are only first party inrelation to the IFrame src rather than the browser URL, thus they are considered as 3rd party in the hosting website point of view.


With many browsers block 3rd party cookies by default, and the way optimizely behaves when cookies are disabled, this leads to a problem: a visitor that is rolled into the experiment sees a different variation on almost every page load.


What's the best way to prevent experiments to run for users that do not have cookies?



Level 2

JDahlinANF 05-06-15

Re: Dealing with disabled cookies

Have you tried an audience condition?

var cookieEnabled = (navigator.cookieEnabled) ? true : false;

if (typeof navigator.cookieEnabled == "undefined" && !cookieEnabled)
cookieEnabled = (document.cookie.indexOf("testcookie") != -1) ? true : false;
return (cookieEnabled);

This code should check to see if the browser has cookies enabled and, if so, try to create a session cookie then verify the cookie was created.


As a 3rd party, if a user has 3rd party cookies disabled, the testcookie should fail to be created and the function will return false.

klarna 05-07-15

Re: Dealing with disabled cookies

Thanks nap0elon, I was not aware of JS defined audiences and this was what I was looking for.
However, I do get a "You do not have the permission to add a condition of type: code" error.
Do you think it might be due to using the free plan?
Level 2

Re: Dealing with disabled cookies

Hi @klarna,


Yes, use of our Custom JavaScript audience condition is enabled on our paid Enterprise plan.  You can see a breakdown of features between the Starter and Enterprise Plans here, as well as information on how to connect with our Sales team to discuss an upgrade.  We'd love to help you leverage more of the tool!

Harrison Krat
Solutions Architect | Optimizely, Inc.