The availability of features may depend on your plan type. Contact your Customer Success Manager if you have any questions.
Dev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubDev CommunityOptimizely AcademySubmit a ticketLog In
API Reference

Cookie expiration

Specify the number of days before the Optimizely Web Experimentation visitor cookies is set to expire.

Specify the number of days before the Optimizely Web Experimentation visitor cookies is set to expire. You must call setCookieExpiration prior to loading the Web Experimentation snippet. The minimum number of days that can be set is 90 (approximately three months). For more information on how Web Experimentation uses cookies, see Cookies and localStorage in the Optimizely Web Experimentation snippet.

Syntax

window["optimizely"].push(cookieExpiration);

Parameters

Parameter and TypeChild AttributeDescription
cookieExpiration
CookieExpirationObject
N/AAn object with the type field set to cookieExpiration. The other fields are the function arguments. Required.
type
object
Child attribute of type CookieDomainObject.The argument indicating that you are using the cookieExpiration function. Required.
cookieExpirationDays
integer
Child attribute of type CookieDomainObject.The cookie expiration defined in days.

Example call

window["optimizely"].push({
  "type": "cookieExpiration",
  "cookieExpirationDays": 365
});
📘

Note

Some Web Experimentation cookies are reset every time a visitor comes to the site, which means the expiration period set with this API call is used each time the cookie is set. You can also use the API to enable or disable the extend cookie lifetime function.