Rich-text Reply

Set Cookie Expiration API

clement_cy_au 04-11-19

Set Cookie Expiration API

In the developer doc, it quoted:

" You must call "setCookieExpiration" prior to loading the Optimizely snippet.". Just wonder if the window.optimizely is not yet defined, how the api will work? 


BTW, I have tried to use 

window['optimizely'] = window['optimizely'] || [];

window['optimizely'].push(["setCookieExpiration", 365]);

to set in the chrome console where our site has optimizelyEndUserId cookie. But the expiration days of the cookie does not changed.

Re: Set Cookie Expiration API

I am in OptimizelyX, the code which I tried is
"type": "cookieExpiration",
"cookieExpirationDays": 365
JasonDahlin 04-11-19

Re: Set Cookie Expiration API

To do as described here:


You will need to declare optimizely in your code and push the attributes to it before the snippet loads.

I do not do this myself, but your webpage will contain code that looks something like the following.


window.optimizely = window.optimizely || [];
	"type": "cookieExpiration",
	"cookieExpirationDays": 365
<script src="//"></script>

As this is not something I have had cause to do yet, please let us know if this works

--Jason Dahlin
Analytics and Testing Guru Smiley Happy

Experimentation Hero

Re: Set Cookie Expiration API

Tks. Will get our IT and see whether they can do this.