Consent & cookies
Optimeleon is suppress-only: until a visitor grants analytics consent, nothing is written to their device and no analytics leaves the page. Wire your consent banner to it in one call.
Optimeleon is suppress-only. Until a visitor grants analytics consent, it sends no analytics events, builds no visitor id, and writes one entry to the device: a per-tab note of which version the tab was shown. This is the default on every page and it does not branch on the visitor's country.
Variants still serve before consent, so the visitor sees the optimized page. Only the measurement waits.
Two technical signals can reach Optimeleon before consent, and neither carries a visitor id: the one-off check sent when you open your site with the install test link, and a notice when your site serves a copy of the Optimeleon script instead of loading it from us.
The consent API
window.optimeleon('consent', { analytics: true, marketing: true }); // grant
window.optimeleon('consent', { analytics: false, marketing: false }); // withdrawwindow.optimeleon(…) is available immediately. The inline bootstrap installs a queue, so calls made before the bundle finishes loading are replayed in order. Call it on every page load with the visitor's stored choice, as early as your CMP knows it, not only when the banner is clicked. Calling it again later, when the visitor changes their mind, is honoured at any point in the page's life.
| Category | Effect |
|---|---|
analytics | The one that matters. true starts capture, enables first-party cookie persistence, and links the session to a lasting profile keyed to a random id. false suppresses capture again and forgets the identity. |
marketing | Recorded only. It drives no cookie, storage or tracking behavior and is not attached to analytics events. Your own code can read it from optimeleon('consent') or the consent event hooks. |
- Pass a boolean per category. Unknown categories and non-boolean values are ignored, so forwarding extra categories from your CMP is safe.
- Omitting a category leaves it unchanged.
- Repeating an identical signal is a no-op, with no double counting and no churn.
What a grant and a withdrawal do
| analytics: true | analytics: false | |
|---|---|---|
| Capture | Begins | Suppressed, and anything not yet sent is dropped |
| Persistence | First-party cookies + localStorage | After a decline, only the per-tab note of the version shown. After a withdrawal, nothing until the next page load writes the note again. |
| Visitor identity | Linked to a lasting random id | Reset and forgotten |
| Cookies | Written, apex-scoped | Cleared |
| Variant assignment | Seed and assignment persisted | Persisted copies cleared |
| Variant on screen | Unchanged | Unchanged |
Returning visitors
A visitor who consented on an earlier visit still has Optimeleon's identity in their browser. Optimeleon does not treat that as consent on its own. On every page it waits for your CMP's answer before it records anything, and in the meantime only reads what it stored earlier, so the visitor keeps the version they saw.
| Your CMP | What happens |
|---|---|
| Confirms consent | Capture starts from the beginning of that page. |
| Reports a decline or withdrawal | Nothing from that page is sent, and the stored identity is removed. A grant that arrives within the same 3-second wait keeps the visitor's id, which covers a consent tool that reports a 'denied' default before the stored choice. A grant after that counts the page once, under a new visitor id. |
| Says nothing within 3 seconds | Optimeleon continues with the visitor's earlier consent. |
The last row is why the stored choice has to reach Optimeleon on every page load. A CMP that only reports when the banner is clicked makes Optimeleon wait out those 3 seconds on every page, for every returning visitor.
Mapping your CMP's categories
Optimeleon's storage falls under analytics / statistics in standard taxonomies.
| CMP | Map to analytics |
|---|---|
| OneTrust | Performance / Analytics Cookies (commonly C0002) |
| Cookiebot | Statistics |
| Sourcepoint / TCF | Measurement (for example Purposes 7 to 10, per your configuration) |
| Google Consent Mode | analytics_storage |
Example: Cookiebot
window.addEventListener('CookiebotOnConsentReady', function () {
window.optimeleon('consent', {
analytics: Cookiebot.consent.statistics,
marketing: Cookiebot.consent.marketing,
});
});Example: Google Consent Mode
// Wherever you already react to a consent update:
window.optimeleon('consent', { analytics: analyticsStorageGranted === 'granted' });optimeleon('config', { consent: 'analytics' }) / 'anonymous' form. Both are supported and they mean the same thing. Use whichever reads better inside your CMP callback.If your cookie tool blocks scripts automatically
Some cookie tools block scripts on their own, without you marking them up. Cookiebot does this when its script tag carries data-blockingmode="auto". Usercentrics, OneTrust and consentmanager call it auto-blocking, and TrustArc does it in Strict Mode. In that mode the tool can block Optimeleon for every visitor who declines cookies or has not chosen yet. Your page still loads, but those visitors only ever see the original version.
Optimeleon does not need to be blocked: it sends nothing and stores nothing identifying until the visitor grants analytics consent. So tell your cookie tool to let it load:
- In Optimeleon, open Setup (or Settings → Script & tracking) and pick your cookie tool just above the tracking code.
- Copy the code again. Every Optimeleon
<script>tag now carries your tool's exemption. - Replace the code on your site. Then open a page in a private window, choose “necessary cookies only”, and check that it still loads.
| Cookie tool | Added to each Optimeleon script tag |
|---|---|
| Cookiebot | data-cookieconsent="ignore" |
| Usercentrics | data-uc-allowed="true" |
| OneTrust | data-ot-ignore |
| consentmanager | data-cmp-ab="1" |
| TrustArc | data-ta-type="ignore" |
Using a tool that is not listed, such as CookieYes or Osano? Set it to always allow scripts from edge.optimeleon.com. Automatic blocking can also catch your own site's code, so if parts of your page stop working after a visitor declines, check which of your own scripts the tool blocks before looking at Optimeleon.
Cookie and storage reference
Register these in your CMP. Match by exact name, except __opti_cap_assign and __opti_route_cache, whose runtime keys carry your project's edge token as a suffix. Register those two by prefix, as __opti_cap_assign* and __opti_route_cache*.
Before consent: one entry, strictly necessary
Before consent Optimeleon writes exactly one entry. No cookies, no localStorage, no technical checks.
| Key | Type | Purpose | Lifetime |
|---|---|---|---|
__opti_cap_assign* | sessionStorage | Remembers which version this tab was shown for each campaign, so the visitor keeps it for the whole visit and a conversion later in the tab credits the right version. Holds the campaign, the version, the measurement group and when it was first shown. No name or email, and no visitor id unless you use identify (see below). After consent it also carries what is needed to credit later events to that version. | Until the tab closes |
Why it is strictly necessary. The version a visitor sees is decided fresh on every full page load unless something remembers the last decision. Without this entry, a visitor who has not answered your banner, or who declined, would see a different version on every reload: a confusing page for them, and a contaminated result for you. It is the minimum that prevents that, and before consent it is used for nothing else.
A withdrawal erases it along with everything else. A plain decline does not, so the visitor keeps a stable page for the rest of the visit.
After analytics consent: statistics
Every key below is written only after an analytics grant, except the momentary cookie check noted in its row, and is cleared when consent is withdrawn. Two of the lifetimes are your settings: the cookie and storage duration (365 days by default) and the session timeout (30 minutes by default), both in Settings → General.
| Key | Type | Purpose | Lifetime |
|---|---|---|---|
__opti_vid | Cookie | Recognises one visitor across your subdomains. A random id, not a profile. | Your cookie and storage duration (365 days by default) |
__opti_arm | Cookie | Lets a conversion completed on another of your subdomains still count for the variant the visitor was shown. | Your session timeout (30 minutes by default), renewed while the visit continues |
__opti_visitor | localStorage | Remembers which version a returning visitor should see. | Your cookie and storage duration (365 days by default), counted from the latest visit |
__opti_assignment | localStorage | Records which variant and campaign the visitor belongs to. | Your cookie and storage duration, counted from the latest visit to that campaign's page |
__opti_cap_vid | localStorage | The visitor's analytics id, a random code grouping their activity. | Your cookie and storage duration (365 days by default), counted from the first visit |
__opti_cap_sid | sessionStorage | Identifies a single visit. A new one starts after your session timeout without activity, and always 24 hours after the visit began. | Until the tab closes |
__opti_cap_seen | sessionStorage | Visit clock for the session above: when the visitor was last active and when the visit began, so the script knows when a visit has ended. Two timestamps, no identity. | Until the tab closes |
__opti_route_cache* | sessionStorage | Remembers for this tab the version decided for each campaign page already opened, with its content changes, so returning to one without a full page load renders instantly. Holds page content, version labels and a signed record of each decision that includes the visitor's version-assignment seed. No name or email. Before consent the same cache is held in memory and never written to the device. | Until the tab closes |
__opti_dprobe | Cookie | Finds your top-level domain while Optimeleon sets or removes its own cookies. Holds only the value 1. Removing an old cookie can run before a returning visitor has answered your banner. | Removed immediately |
Shopify checkout adds two
| Key | Type | Purpose | Lifetime |
|---|---|---|---|
__opti_px_sid | sessionStorage | Groups checkout activity for a shopper who lands directly on checkout, for example from an email link. Set only after consent. | Until the tab closes |
__opti_px_fwd | localStorage | Holds the checkout identifiers of the shopper's last ten purchases, so refreshing a thank-you page does not count a purchase twice. Set only after consent. | No set expiry |
Opening your site with a debug or preview parameter, or through a preview link, writes a few more keys in that browser. They exist for testing, and an ordinary visit never writes them. See Preview & debug.
Test your integration
- Open a campaign page in a fresh private window and decline analytics. In DevTools → Application there should be no Optimeleon cookie and no
localStoragekey. The onlysessionStoragekey is__opti_cap_assign:…, once a variant has been served. Reload a few times: the variant must not change. - Accept analytics. The
__opti_vidcookie appears on your top-level domain, along with the keys in the statistics table above. - Reload. In the browser console,
optimeleon('consent')should reportresolved: truealmost at once. If that takes about 3 seconds, your CMP is not passing on the stored choice at page load. - Withdraw. The cookie is removed, every key in the statistics table is cleared, and so is the per-tab note.
Cross-subdomain identity
The __opti_vid cookie is written at your apex domain, so a visitor recognised on www.example.com is the same visitor on shop.example.com. __opti_arm carries the served variant across that boundary for a short window, which is what lets a purchase completed on another subdomain be credited to the variant that earned it.
Every subdomain involved still has to be on your tracking allowlist.
What Optimeleon never does
- No IP storage. A visitor's IP is used momentarily to estimate a rough city, then dropped.
- No personal profiles. Everything ties to a random id, never a name or an email.
- No third-party ad tracking. No advertising cookies, no outside ad-network trackers. Data goes only to Optimeleon's own collector at
edge.optimeleon.com, and is never sold or shared with ad networks or data brokers. - On Shopify, a purchase is recorded with its amount, currency and products, never the order number, the checkout token, or any customer detail from your admin.
Retention and visitor rights
Analytics is deleted 12 months after it is recorded, plus up to one further month to complete a late deletion request, and never beyond 13 months. That policy is fixed.
What sits in the visitor's browser lasts as long as your cookie and storage duration: 365 days by default, and anything from one day to a year in Settings → General. The storage table above says what each entry counts from. Shortening the duration also applies to what is already stored: entries past the new limit are deleted on that visitor's next page view. A visitor can clear them, or withdraw consent, at any time to remove them immediately.
If a visitor asks to see or delete their data, send us their visitor id and we will export or erase their records. Deleting a project removes all of its data.
