Hoppa till dokumentationens innehåll

Cross-domain consent

Share a visitor's choice across your subdomains, and carry it between separate domains with Cross-Domain Consent Sync.

Senast uppdaterad:

A visitor's choice is stored in a first-party consent cookie (cb_cookie by default). Browsers only send a cookie to the site that set it. So by default, a choice made on www.example.com is not visible on shop.example.com, and never visible on example.org.

There are two different cases:

CaseExampleHow
Subdomains of one domainwww.example.com and shop.example.comSet the consent cookie's domain. Works on every plan.
Separate domainsexample.com and example.orgSee Separate domains below.
  1. Open the banner and choose Banner settings.
  2. In the Consent section, find Consent cookie.
  3. In Domain, enter your registrable domain, for example example.com. Leave it empty (Automatic) to keep the cookie on the current host only.
  4. Save the settings, then Publish the banner.
  5. Make sure every subdomain loads the same banner, and that each subdomain is listed in the banner's authorized domains (Banner domains).

The runtime then writes the consent cookie with that domain, and the browser sends it to every subdomain. A choice made on one subdomain applies on the others.

Things to check:

  • Use the same banner on every subdomain. Every subdomain reads the same consent cookie against the same categories.
  • The domain must match the site. A browser ignores a cookie set for a domain the page is not part of. If the cookie does not appear on a subdomain, check the spelling of the domain.
  • Earlier choices stay on their original host. A visitor who chose before the change has a cookie on that host only. Other subdomains do not see that earlier choice.

The consent cookie's Domain attribute controls where the browser sends it. The rules follow RFC 6265:

SettingCookie domain attributeAvailable on
Automatic (empty)Not setOnly the exact host that set it
example.com.example.comexample.com, www.example.com, shop.example.com, and every other subdomain

A cookie set without a domain attribute is a host-only cookie; the browser sends it only to the exact host, not subdomains. Setting the domain to the registrable domain (the eTLD+1, like example.com) makes it a domain cookie that covers every subdomain.

You can't set a domain cookie for a public suffix like co.uk or github.io. The browser silently rejects it, and the cookie is lost.

Revision across subdomains

When subdomains share a cookie, the consent state and revision stay consistent. A visitor who consented on www.example.com with revision 5 shows the same state on shop.example.com. If you bump the revision (triggering re-consent), the banner appears on whichever subdomain the visitor hits first; and once they choose, the updated cookie covers all subdomains again.

Categories must match across subdomains. If www and shop load different banners with different categories, the cookie's category list may not align with what the second banner expects. Always use the same banner configuration on every subdomain that shares the cookie.

Separate domains

Browsers keep each site's storage apart, so example.org can never read a cookie set by example.com. CookieBeam carries the choice across when the visitor follows a link from one of the banner's domains to another. Nothing else is shared between the two sites.

Turn it on

  1. Add both domains to the same banner in Banner domains. The Cross-Domain Consent Sync switch appears once the banner has two or more domains. It is included in the Business plan and above.
  2. Turn the switch on.
  3. Publish the banner. The published banner script only carries choices after a publish made with the switch on.
  4. Load the banner script as early as possible in the page's <head>, before other scripts, as you already do for blocking.

The feature is not available for banners that use IAB TCF or per-purpose consent. Their published script does not carry choices.

  1. A visitor makes a choice on example.com, then presses a link to example.org.
  2. The banner script on example.com asks CookieBeam for a one-time code and adds it to the end of the link (#cb_xdc=…). The code is valid for two minutes and can be used once.
  3. On example.org, the banner script removes the code from the address bar as soon as it runs, exchanges it with CookieBeam for the choice, and stores that choice in example.org's own consent cookie. The banner does not ask again.

What travels with the visitor: the chosen categories and services, the consent revision, when the choice was first made, when it was last changed, the US opt-out choices and the display language. Any custom data you store in the consent cookie and anything from your site's other cookies are not carried. The carried dates are rounded down to the day, so the two cookies cannot be matched to each other by an exact time.

What CookieBeam receives: when the visitor presses such a link, the choice above and the visitor's IP address (to bind the code to their network). CookieBeam stores the choice and a keyed hash of the network, never the address or the code itself, and deletes them when the code is used or at the latest a day after it expired.

Which choice wins

  • The newer choice wins. If the visitor already chose on example.org more recently, example.org keeps its own choice.
  • A choice that was itself carried from another site is only known to the day. When the two choices being compared fall on the same day and either one was carried, CookieBeam cannot tell which came last, so the site keeps only what both choices allow: the categories and services both accepted, every US opt-out either one made, and the privacy signal if either respected it. A carried accept therefore never overrides a refusal made the same day, and a carried refusal always narrows the stored choice.
  • A withdrawal travels the same way. If the visitor rejects analytics on example.org and then follows a link back to example.com, example.com stops analytics and clears the cookies the banner is set to clear for that category.
  • A carried choice keeps its original date (rounded down to the day), so moving between your sites never extends how long consent lasts. A choice in its last day may therefore already count as expired on the receiving site; it still replaces what that site had, and the banner asks again.
  • If you changed the banner's consent revision and the receiving site already serves the new revision, a choice made under the old revision is not carried, and the visitor is asked again.

What is not carried

  • Visiting the other site any other way: typing the address, a bookmark, a search result, an email link. The visitor keeps whatever that site stored, and is asked if it has nothing.
  • Links that already end in a #section, links with rel="noreferrer", download or a referrerpolicy attribute, and links that are not https.
  • "Open in new tab" from the browser's right-click menu.
  • Links opened in a new tab (middle-click, Ctrl/Cmd-click, target="_blank") when CookieBeam has not answered by the time the click completes. The code is requested when the visitor presses the link, so a fast answer carries the choice and a slow one does not.
  • Navigation your own code triggers (window.location, form submissions).
  • Subdomains of a configured domain that are not themselves configured (shop.example.org when only example.org is listed). The www. form of a configured domain counts as that domain. For subdomains, use the shared cookie domain instead (above).

Protections, and when they stop an accept from carrying

To stop a third party from planting an "accept" in a visitor's browser, a carried choice that accepts anything beyond strictly necessary cookies is only applied when both of these hold:

  • the visitor arrived on the receiving site from a page on the sending site (the browser's referrer says so), and
  • the visitor is on the same network as when the code was issued.

A carried choice that only rejects or withdraws does not need either check, because it can only make your site more restrictive. Like any carried choice, it is applied only when it is newer than the choice the site already has. A US opt-out the visitor made on a site is kept on that site even when a carried choice does not mention it.

So an accept is not carried, and the visitor is asked again, when:

  • your sending site sends Referrer-Policy: no-referrer or same-origin;
  • the visitor's connection changes network between the two requests. In Safari with iCloud Private Relay this can happen often. On a dual-stack connection it can happen if one request uses IPv6 and the other IPv4.

By browser

BrowserAccept carried on a linkWithdrawal carried on a link
Chrome, Edge and other Chromium browsersYesYes
FirefoxYesYes
Safari (macOS, iOS, iPadOS)Yes, except when iCloud Private Relay sends the two requests from different networksYes

All three need nothing from third-party cookies or storage, so the browser's tracking protection settings do not affect it.

If the CookieBeam service cannot be reached, the link still opens (after at most about one second), and the other site asks as usual.

What this means in practice

If your business spans example.com and shop.example.org, a visitor who accepts on one domain and navigates to the other sees the banner again. The second domain writes its own consent cookie, and the visitor makes a separate choice. The two consent records are independent.

This is the same behavior every first-party cookie has: browsers don't share cookies between different registrable domains. The Cross-Domain Consent Sync feature above bridges this gap for link-based navigations; other navigation methods (typing the URL, bookmarks, search results) still result in separate consent.

Alternatives for separate domains today

  • Same registrable domain: if you can put both sites under the same registrable domain (www.example.com and shop.example.com), use the subdomain sharing method above instead.
  • Server-side relay: your server can read the consent cookie on one domain, pass the consent state to the other domain (for example, as a query parameter in a redirect), and write the cookie there. This requires custom code and works only for navigations your server controls.
  • Accept the double prompt: for many sites, asking on each domain is acceptable. The visitor's choice on each domain is independent, and both are valid consent records.

When separate domains are involved and ad_storage is denied, Google's conversion tracking loses the ability to attribute conversions across the domain boundary. Consent Mode v2's urlPassthrough option helps: it tells Google tags to carry ad click identifiers (gclid, dclid) in the URL when navigating across domains, preserving attribution without cookies.

URL passthrough is off by default in CookieBeam. Enable it in Banner settings > Google Consent Mode > URL Passthrough. It works independently of the Cross-Domain Consent Sync switch: it is a Google tag feature, not a consent-sharing feature. It preserves ad attribution, not the visitor's consent state.

When a domain cookie is set, your server on any subdomain can read the consent cookie from the request. Parse it the same way on every subdomain. See Read consent on your server for the parsing logic.

If the cookie is host-only (no domain set), your server on a different subdomain won't see it. Set the domain before relying on server-side reads across subdomains.

Verify

Separate domains

  1. Open the first site in a private window and make a choice.
  2. Click a link on that page to the second site. The banner should not ask, and the address bar should not show #cb_xdc.
  3. On the second site, open the browser's developer tools and check the consent cookie: it lists the same categories.

Subdomains

  1. Open the first site in a private window and make a choice.
  2. In the browser's developer tools, open the cookies for the site and find the consent cookie. Check its Domain value; it should show .example.com (with the leading dot) if the domain is set.
  3. Open a second subdomain in the same window. The banner should not ask again, and the consent cookie should be the same one.
  4. In the second subdomain's DevTools, confirm the consent cookie is present with the same categories and revision.

If the banner asks again, check that the second subdomain loads the same banner, that the published bundle includes the new cookie setting, and that the cookie's domain covers both hosts.

Troubleshooting

The cookie shows the wrong domain. You might have published before saving the domain change, or the domain is misspelled. Check Banner settings > Consent cookie > Domain, save, and re-publish.

The cookie disappears on a subdomain. The browser may be rejecting it because the domain doesn't match the page's host. A cookie set for example.com won't appear on other.com. Check that both subdomains are under the same registrable domain.

A visitor sees the banner on every subdomain. The cookie was set as host-only (no domain configured). Set the domain to the registrable domain and re-publish. Existing host-only cookies from before the change won't be shared; those visitors will be asked again on other subdomains, and the new domain cookie replaces the old one.

The consent revision doesn't match. If www and shop load different published versions of the banner (different revisions), the visitor may be re-prompted on the subdomain with the higher revision. Publish all subdomains at the same time, or accept that a visitor may re-consent when they hit the updated subdomain.