Skip to documentation content

Regions and regimes

How CookieBeam adapts consent mode, banner text, buttons, and behavior per visitor location using regional rules and legal-framework presets.

Last updated:

Privacy laws differ by jurisdiction. The GDPR requires opt-in consent before non-essential cookies run. California's CCPA lets them run but gives visitors the right to opt out. Canada's PIPEDA requires notice but not necessarily a blocking gate. A single banner configuration can't satisfy all of them at once.

Regional rules solve this. Each rule targets a set of countries or subdivisions and overrides the banner's base behavior for visitors geolocated there: consent mode, button labels, which categories need consent, cookie lifetime, and privacy-signal handling. CookieBeam ships framework presets that encode the common requirements of major laws, and you can customize or extend them.

How matching works

When a visitor loads the page, the CDN loader resolves their location from a geo lookup and walks the rule list:

  1. For each rule, check whether the visitor's ISO 3166-1 country code is in the rule's countries list.
  2. If the rule also specifies regions (ISO 3166-2 subdivision codes like US-CA), check that the visitor's subdivision matches. Rules with excludeRegions carve out specific subdivisions from a broader country match.
  3. Rules that match the visitor's subdivision are collected separately from country-only rules. Among subdivision matches, the highest-priority rule wins (higher number = higher priority). If there are no subdivision matches, the highest-priority country-only rule wins. A subdivision match always beats a country-only match, regardless of priority.
  4. If no rule matches, the fallback applies. The fallback is a separate object (regionalSettings.fallback), not a rule with no countries.

The match runs once. The CDN loader passes the result to the core runtime, which reads it without re-matching. This means the geo lookup and the rule walk happen before the banner shows, and the core runtime doesn't need network access to determine the regime.

Framework presets

Framework presets are built-in templates that encode a law's recommended consent mode, button text, Consent Mode defaults, and UI behavior. When you enable regional rules in the dashboard, CookieBeam offers these presets as starting points.

PresetJurisdictionsModeKey behavior
GDPREU and EEA countriesOpt-inAll non-necessary categories blocked until consent. Equal-weight accept/reject buttons
UK GDPRUnited KingdomOpt-inSame as GDPR, separate rule for post-Brexit scope
CCPA/CPRACalifornia (US-CA)Opt-out"Do Not Sell or Share" link, sale/sharing and targeted-advertising opt-out toggles
US Opt-Out StatesColorado, Virginia, Connecticut, and other US states with comprehensive privacy lawsOpt-outOpt-out toggles for applicable rights. Covers states as laws take effect
US Other StatesUS states without a comprehensive privacy lawOpt-outLighter opt-out with no specific toggle requirements
LGPDBrazilOpt-inPortuguese button text, opt-in gate
Quebec Law 25Quebec (CA-QC)MixedFrench text; analytics on before the choice (visitor can switch it off), marketing blocked. Separate from federal PIPEDA
PIPEDACanada (except Quebec)NoticeBanner shown for transparency; scripts run without blocking
PIPLChinaOpt-inConsent required before processing
APPIJapanNoticeInformational banner with Japanese text; scripts run without blocking
PDPA ThailandThailandMixedAnalytics on before the choice; marketing blocked. Thai-language overrides
PDPA SingaporeSingaporeMixedAnalytics on before the choice; marketing blocked

Additional presets cover India (DPDP), South Africa (POPIA), Kenya (DPA), South Korea (PIPA), Indonesia (PDP), Brunei (PDPO), and Laos (EDPL). New presets are added as laws take effect.

Each preset includes localized button text for common languages. The override precedence is: base translation, then the framework preset's overrides, then any per-rule overrides you add. See Configure regional rules for how to customize preset text.

What a rule controls

A regional rule can override most of the banner's base configuration. The main fields:

mode sets whether the rule runs as opt-in or opt-out. bannerMode adds a third option: notice, where the banner appears for transparency but doesn't gate scripts. See Consent modes for how each mode affects the visitor experience and the consent record.

Scoped categories

scopedCategories limits which categories the rule puts behind consent. When present, only the listed categories appear in the consent UI and are subject to consent logic. Unlisted non-readOnly categories are treated as always granted for visitors matched by this rule.

This is how a US opt-out rule can require consent for marketing while leaving analytics always on: set scopedCategories to ["marketing"]. An EU opt-in rule typically scopes all non-necessary categories.

When scopedCategories is absent, all configured categories are scoped (the default behavior).

Default categories

defaultCategories lists the category IDs a visitor is auto-granted on first load. This matters when the rule hides the banner (a region where no consent interaction is needed): the visitor gets exactly these categories plus the always-on readOnly categories, and nothing else. When absent or empty, only readOnly categories are granted.

defaults sets the initial Google Consent Mode v2 state for visitors in this region. Each of the 7 Consent Mode keys (ad_storage, ad_user_data, ad_personalization, analytics_storage, functionality_storage, personalization_storage, security_storage) is set to granted or denied. See Google Consent Mode v2.

defaultsPolicy controls how these defaults interact with the base configuration: explicit uses exactly what the rule specifies, none sends no defaults, and inherit falls through to the base config.

Translation and GUI overrides

translationOverrides lets a rule change the banner's button labels, descriptions, and section titles per language. For example, the CCPA preset replaces "Reject non-essential cookies" with "Do Not Sell or Share My Personal Information" in English.

guiOverrides controls button behavior: whether the floating settings button appears, and whether an opt-out banner keeps re-showing until the visitor makes an explicit choice (reShowUntilChoice). The Do Not Sell link (showDoNotSellLink) and opt-out toggles (optOutToggles) are top-level rule fields, not part of guiOverrides.

Privacy signals

privacySignals overrides the global privacy-signal settings for this region. The mode field controls how Global Privacy Control affects consent: hard_optout removes the covered categories entirely, while preselect_deny unchecks them in the UI but lets the visitor override. categoriesToBlock lists which categories a privacy signal affects. See Privacy signals.

consentExpiryDays overrides the global consent cookie expiry for visitors matched by this rule. Some laws require shorter retention periods; this field lets you comply without changing the default for other regions.

The fallback

The fallback is a separate object (regionalSettings.fallback), not a rule with an empty countries list. It applies to every visitor whose location doesn't match any rule. It has the same fields as a rule: showBanner, bannerMode, defaults, defaultCategories, scopedCategories, and privacySignals. A rule with no countries matches nothing.

A common pattern: set the fallback to show an opt-in banner. Visitors from unknown or unrecognized locations get the strictest treatment, and you add opt-out rules for regions where that's appropriate.

If regional rules are disabled entirely, the banner uses its base mode setting for everyone. See Consent modes.

Priority and rule ordering

A rule that names the visitor's subdivision always wins over a country-only rule, regardless of priority. Within each group (subdivision rules or country-only rules), a higher priority number wins; equal-priority rules are decided by list order.

In the dashboard, you can drag rules to reorder them. The framework presets place subdivision-specific rules (like CCPA for US-CA) alongside broader country rules (like US Opt-Out States for US), and the subdivision rule always wins for a Californian even if the country rule has a higher priority.

Match-once architecture

The CDN loader performs the geo lookup and rule match before it hands control to the core runtime. The result is passed as environment.precomputedRegionalBehavior, and the core runtime reads it directly without re-matching. This design means:

  • The core runtime doesn't make a network request for geo data. All the information it needs is in the precomputed result.
  • The match logic lives in one place. The CDN uses a generated ES5 artifact compiled from the same source as core's matcher, and a parity test ensures they stay in sync.
  • The banner shows the correct regional behavior on the first render, with no flash of wrong content.

For standalone or development usage without the CDN loader, core includes its own fallback matcher that runs the same algorithm.

Regime groups

CookieBeam groups laws into regime families:

  • gdpr-family: GDPR, UK GDPR, LGPD, Quebec Law 25, PIPL, APPI, PDPA (Thailand and Singapore), and other opt-in regimes
  • us-optout: CCPA/CPRA, US opt-out states, US other states
  • notice: PIPEDA, Australia Privacy Act, NZ Privacy Act, India DPDP

These groups drive the experiment consent guard (which experiments are safe to run under a regime) and GPC-mandate detection (a us-optout regime is treated as mandating GPC). They don't currently appear in the dashboard's analytics views.

Next steps