Rich-text Reply

Setting cookie for testing purposes

jencajenca 09-29-14

Setting cookie for testing purposes



I am having great issues to test Optimizely and I would love some help!


1) I have set the target URL to our staging environment (not public link, naturally) and turned on the experiment. I have no audiences set and variation A is on 100% but the test is still not running.

2) I changed to our public URL, test still on 100%, set audiences for browser width > 1024 px (responsive site, only targeting large desktops with this test) AND test cookie (which I have set in my Chrome browser). Turn on test, runs in my browser but also in a browser without the test cookie set.


Testing my experiments (outside of preview links) are a real bother. Am I doing something wrong or is Optimizely full of bugs? 


(If somebody from Optimizely would like to have a look at this, the experiment ID is 1771981523).


Thanks! //Jenny



Amanda 09-29-14

Re: Setting cookie for testing purposes

@jencajenca - It sounds like you are doing everything right in terms of testing your experiment. Using a test cookie is a method that I use all the time myself. 


I tried to look at your experiment URL but was unable to access it. Is this your testing site? I have also posted some tips below (although I'm sure you've already looked into them). 


  • For your question #1, I would recommend double checking that the correct snippet is on this staging domain. 
  • For your question #2, your test cookie targeting conditions look correct. The experiment should *only* run if this cookie is present. Can you confirm that the cookies were cleared before your secondary test? I would recommend using an incognito window etc. 


If you've checked the 2 bullets above and are still seeing issues, please let me know and we can do a deeper dive into the problem. 



jencajenca 09-30-14

Re: Setting cookie for testing purposes

Hi Amanda!

And thanks for your reply, Amanda! You know, I looked into this a bit more today and actually realized that the cookie works fine but we received a line of code from Optimizely earlier regarding checking the size of the window and I believe this line is what is causing my trouble:


jQuery(window).width() > 1024


Is there some kind of timing issue regarding this, such as the window size not being known at the time of Optimizely loading (in head), or similar?


Yes, as I mentioned earlier, the address is our staging environment (and also, would you mind removing the link, perhaps you can edit it to "---" in your response, I always prefer to be incognito, company-wise). In the editor address on the same test, you can see our public address (I prefer to not write it, for the same reason as above).


Btw, the script is loaded correctly on both sites.


Best regards,


Amanda 10-01-14

Re: Setting cookie for testing purposes

Can you try using standard JavaScript instead of jQuery? For example,  window.innerWidth > 1024

jencajenca 10-09-14

Re: Setting cookie for testing purposes

Hi Amanda!

The new line of code seems to work and I think it also takes a little time (like 10 min) for everything to upload to Optimizely, which also made me think that my test was buggier than it actually was.


Thanks for your help, tomorrow I will turn the test on!