Skip to main content

Cookie consent

On a page that embeds Flex experiences, your page owns consent. Pass your consent management platform's (CMP) choice through window.flexEmbedSdk, which embed.v1.js, flex-client.js and flex-ssr.js all put on the page. The examples use the withFlexEmbedSdk helper from Analytics events, because flex-ssr.js loads deferred and the SDK may not exist yet when your script runs.

One call reaches every experience on the page:

withFlexEmbedSdk((sdk) => {
// Default for every experience…
sdk.setCookieConsent('*', ['necessary', 'performance'])
// …and an override for one, by slug.
sdk.setCookieConsent('marketing-campaign', ['necessary'])
})

The categories are necessary, performance, functional, targeting and social. When several filters match, the most recently set one wins, and '*' always matches last. Consent set before an experience mounts is applied when it mounts. It is held in memory only, so call it on every page load, for example from your CMP's initialisation callback, and again whenever the visitor changes their choice. sdk.resetCookieCompliance() clears the stored filters for experiences added afterwards.

window.flexPlayer.cookieConsent is the API for code that runs inside a standalone experience, from its custom HTML. It doesn't exist on an Inline or SSR host page; use setCookieConsent there.

What Flex stores in the browser​

On Flex Inline and Flex SSR, Flex sets no persistent cookies. It does use web storage:

  • sessionStorage: ceros:last-opened-experience, so experience.open fires once per experience per tab. It is written once performance consent is present. Flex assumes that consent only when the experience does not require viewer consent for analytics; otherwise it waits for you to set it. When Flex cannot read the experience's setting, it writes the marker straight away. That happens for an experience last published before October 2026, which republishing fixes, for a static export, and for a Flex SSR embed without data-flex-manifest-url. Until the marker is written, experience.open fires on each page load of the experience. Some features (the presentation toolbar, interactions that remember their state) keep tab-scoped data there too.
  • With Ceros analytics enabled: a short-lived test cookie, set and removed immediately to report whether cookies are enabled.
  • With Ceros analytics enabled and performance consent given: localStorage key ceros_user_token, an anonymous visitor ID. Without that consent the ID is kept in memory for the page's lifetime.