Skip to main content


Optimizely Knowledge Base

CDN Cookie Creation

The changes introduced as part of ITP 2.1 and currently being tested in some other browsers specifically affect cookies created client-side in JavaScript via ‘document.cookie’, which is currently the only means for Optimizely X Web to manage the cookie-setting process.

To ensure the persistence of your cookies, including the `optimizelyEndUserId` cookie, manage the cookie creation process at another point in your stack.

Many major CDN providers allow you to configure cookie creation as part of the response with your hosted content. This provides an option for UI-based and managed implementation of server-side cookie creation in many cases. Instructions can be found below for how to implement this in Akamai, if you use a different provider please feel free to reach out to your account team for more information on on other providers.


Akamai provides the required cookie configuration options via the Property Manager. A JSON representation for creating the rule programmatically is also available.

To begin creating the cookie, create a new rule within the Akamai Project Configuration Settings to manage the cookie setting and updating process as part of your property’s responses.


This rule will need to contain two child rules: New Cookie and Refresh Cookie. The New Cookie child rule will manage creation of a new cookie for visitors who do not yet have an `optimizelyEndUserId` cookie set. The Refresh Cookie child rule will refresh the cookie expiration for visitors who return with an existing cookie.

Here is the required configuration:



These settings will create a new cookie that meets the requirements to enable functional parity with the cookie that Optimizely currently sets within our client-side execution. These behaviors are:

  • Named `optimizelyEndUserId`

  • Set to a unique value

  • Set to a duration of 180 days by default

  • Set on the top-level domain and base path of your choice

If you are leveraging Optimizely’s setCookieExpiration API to adjust your existing cookie expiration behavior, set the duration value as needed.