Skip to documentation content
CookieBeam

Regional rules and geo-targeting

Show different banner behavior per country or region, with rules, priorities, fallbacks, and legal-framework presets.

Last updated:

Regional rules let one banner behave differently depending on where the visitor is. A typical setup shows an opt-in banner to EU visitors, an opt-out banner to California, and nothing at all where no rule applies.

You manage rules on the banner's Regional settings page: Dashboard → Banners → your banner → Regional settings. If automatic or disabled mode is active, click Customize rules to begin. After changing rules, click Save Settings on that page, then Publish from the banner header; rule changes only reach visitors on publish.

How a visitor is matched

The CDN edge determines the visitor's country and region and passes them to the banner script. The matcher in the runtime then evaluates your rules:

  1. Rules are checked against the visitor's country (ISO code, case-insensitive). A rule can also name specific regions (for example US states) and excluded regions.
  2. A rule that names regions only matches when the visitor's region matches one of them; a rule without regions matches the whole country.
  3. Region-exact matches win over country-only matches. Within the same tier, the rule with the highest priority number wins; ties go to the rule defined first.
  4. If no rule matches, the fallback settings apply. If the visitor's country could not be determined at all, the runtime fails closed: when the fallback is already a visible opt-in banner it is kept as-is, but any other fallback (hidden, opt-out, or notice) is replaced by a visible opt-in banner that grants nothing. This prevents a lenient fallback from accidentally applying to visitors who may be in an opt-in jurisdiction.

The same matcher runs in the full banner runtime and in the lightweight CDN loader. The CDN copy is a generated ES5 twin of the canonical matcher, and a parity test keeps the two implementations in lockstep, so a rule you test in preview behaves identically at the edge.

Rule anatomy

Each regional rule carries these fields:

FieldTypeDescription
countriesstring[]ISO 3166-1 alpha-2 country codes (e.g. DE, US)
regionsstring[]?ISO 3166-2 subdivision codes (e.g. US-CA, CA-QC). When present, the rule only matches visitors in these subdivisions
excludeRegionsstring[]?Subdivisions to carve out from a country match. A rule for US with excludeRegions: ["US-CA"] skips California
prioritynumberHigher number = higher precedence. Drag rules in the dashboard to reorder
showBannerbooleanWhether the banner mounts for visitors in this region. See What hiding the banner grants
bannerMode'optIn' | 'optOut' | 'notice'Overrides the banner's base mode for this region
scopedCategoriesstring[]?Only these categories are subject to consent. Absent = all categories scoped. See scopedCategories vs defaultCategories
defaultCategoriesstring[]?Categories auto-granted on first load when the banner is hidden or in certain modes
defaultsConsentModeV2State?Per-key Consent Mode v2 defaults for this region. When provided, all 7 keys must be present
defaultsPolicy'explicit' | 'none' | 'inherit'How Consent Mode defaults interact with the base config. explicit uses exactly what the rule specifies; none sends no defaults; inherit falls through to the base
consentExpiryDaysnumber?Override the consent cookie lifetime for this region
translationOverridesRecord<locale, partial>?Per-language text overrides. See Translation and GUI overrides
guiOverridesobject?Button behavior overrides. See Translation and GUI overrides
privacySignalsobject?Override signal mode and categories for this region. See Privacy signals

What hiding the banner grants

When a rule (or the fallback) sets showBanner: false and the visitor has no stored consent yet, the runtime writes a machine-generated record. The categories it grants depend on scopedCategories and defaultCategories:

  • All readOnly categories (always granted).
  • All non-readOnly categories that are not in scopedCategories (unscoped categories are treated as permanently granted for this rule's visitors).
  • Categories that are in scopedCategories and also appear in defaultCategories.

When scopedCategories is absent, every configured category is scoped. When defaultCategories is absent or empty, no scoped categories are auto-granted beyond readOnly.

Legacy banners: banners published before defaultCategories was introduced have no defaultCategories field in their payload. The runtime treats a missing field the same as an absent one on both the baseline and the regional rule, so a hidden rule on a legacy banner grants every category until you republish the banner (which adds the field).

The record is:

  • marked as a machine-written default (isDefaultState: true, collectedVia: 'hidden_autogrant'), so it is not counted as the visitor's first consent and does not log a consent_given event;
  • skipped entirely when the visitor already has a valid stored consent, so an existing choice is never overwritten by a hidden rule.

If you hide the banner with no scopedCategories and no defaultCategories, only readOnly categories are granted and every other category stays denied. If you hide the banner with no scopedCategories and defaultCategories listing every category, every category-gated tag is released for that visitor.

Two experiment guardrails can block the auto-grant: an applied experiment override that resolves to opt-in or notice, or a regional experiment override on an opt-in baseline. In either case, the hidden branch returns without granting categories and without mounting the banner. The guardrail does not make the visitor see the banner.

If a region should get only necessary storage without a consent prompt, hide the banner and leave defaultCategories empty (or absent). The visitor gets only readOnly categories.

CookieBeam ships preset rules for common frameworks. Applying a preset creates a rule pre-filled with that framework's regions, consent mode, banner text, and layout.

PresetRegionsModeKey behavior
GDPREU and EEA countriesOpt-inAll non-necessary blocked. Equal-weight accept/reject
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 toggles
US Opt-Out StatesCO, VA, CT, and other states with comprehensive lawsOpt-outOpt-out toggles for applicable rights
US Other StatesUS states without 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, marketing blocked. Separate from federal PIPEDA
PIPEDACanada (except Quebec)NoticeBanner shown for transparency; scripts not blocked
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.

Treat presets as starting points, not legal advice. They encode reasonable defaults for review with your own counsel; you can adjust every field of the resulting rule.

When you create a rule from a preset, the preset's text and layout are copied into the rule at creation time. Afterwards the rule is self-contained: later edits to the preset do not rewrite existing rules, and your per-rule customizations always win over the preset values.

scopedCategories vs defaultCategories

These are different mechanisms that serve different purposes:

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

defaultCategories controls which categories are auto-granted on first load. This matters when the rule hides the banner or uses notice mode: the visitor gets these categories plus the always-on readOnly categories.

A US opt-out rule might combine them: scopedCategories: ["marketing"] puts only marketing behind consent, while defaultCategories: ["analytics", "preferences"] ensures those run by default even if the banner is hidden.

When scopedCategories is absent, all configured categories are scoped. When defaultCategories is absent or empty, only readOnly categories are granted by default.

Translation and GUI overrides

Each rule can override the banner's text and button behavior for its region.

Translation overrides change button labels, descriptions, and section titles per language. The override precedence is:

  1. Your base banner translation
  2. The framework preset's text (captured when the rule was created from a preset)
  3. Your per-rule translationOverrides

For example, the CCPA preset replaces "Reject non-essential cookies" with "Do Not Sell or Share My Personal Information" in English. You can override this further on the rule.

Overrides are per-language: translationOverrides is a map from locale code to a partial translation object. You only need to supply the fields you want to change; unlisted fields fall through to the base translation.

GUI overrides control button behavior for the region:

OverrideWhat it controls
Do Not Sell linkWhether the "Do Not Sell or Share" link appears in the banner or floating button
Opt-out togglesWhich purpose toggles appear in the US opt-out panel
Floating settings buttonWhether the floating settings button appears for this region
reShowUntilChoiceWhether the banner reappears on every page load until the visitor makes an explicit choice

GUI overrides affect behavior, not appearance. Theme colors, layout, and typography are controlled by the banner's appearance settings.

Each rule can override the banner-level consent cookie lifetime with consentExpiryDays. When set, the consent cookie for visitors matched by this rule expires after the specified number of days instead of the banner's default.

Use this when different jurisdictions have different re-consent expectations. For example, the GDPR does not prescribe a fixed period (many organizations choose annual re-consent, but the obligation depends on your processing and your DPA's guidance); CCPA does not require re-consent at all. CookieBeam's built-in presets already set per-country lifetimes where regulators have published guidance, for instance 182 days in France, Ireland, Belgium and Italy, and 730 days in Spain. You might set:

  • A GDPR rule with consentExpiryDays: 365 (the default for most EU/EEA countries)
  • A CCPA rule with consentExpiryDays: 730 (or leave it unset to inherit the banner default)

The runtime checks consentExpiryDays at each page load. When the cookie is older than the allowed lifetime, it's treated as stale and the visitor is re-prompted. This is the same mechanism the banner-level cookie.expiresAfterDays uses; the regional override just narrows it for specific visitors.

Display timing

The displayTiming field on a rule (or the fallback) controls when the banner appears:

  • delayMs: wait this many milliseconds after page load before showing the banner. Useful in notice-mode regions where an immediate banner may feel intrusive.
  • scrollPx: show the banner after the visitor scrolls this many pixels. Useful for content-heavy sites where you want the visitor to engage before prompting.

If both are set, the banner shows after the first condition is met (delay or scroll, whichever comes first). If neither is set, the banner shows immediately on page load.

Display timing does not affect consent: the visitor's categories are determined by the consent model and any machine-written defaults at page load, regardless of when the banner renders. A 2-second delay means the visitor's first 2 seconds run under the default state (in opt-in: nothing non-necessary; in opt-out: everything enabled), not under a different consent policy.

Configuring the fallback

The fallback applies to every visitor whose location doesn't match any rule, including visitors whose country couldn't be determined. It has the same fields as a rule: showBanner, bannerMode, defaults, defaultCategories, scopedCategories, and privacySignals.

A common pattern: set the fallback to opt-in mode. Visitors from unknown or unrecognized locations get the strictest treatment, and you add specific rules for regions where opt-out or notice mode is appropriate.

To configure the fallback: on the Regional settings page, scroll past the rule list to the Fallback section. The fallback always exists; you can't delete it, only change its settings.

Precedence summary

For rule selection: region-exact match, then country-only match, then fallback; priority order breaking ties at each step.

For banner text and layout, the effective result for a matched visitor is:

  1. your base banner translation and layout,
  2. overridden by the framework preset captured in the rule,
  3. overridden by your per-rule customizations.

Verify a rule end to end

  1. On the Regional settings page, click Customize rules if it is shown, add your rule (or apply a preset), set its regions, consent mode, and visibility, and click Save Settings.
  2. Click Publish in the banner header so the new rules compile into the served bundle.
  3. Open your site in a clean browser profile (no stored consent) from the target region; or use your CDN edge's geo-override / the banner preview with a simulated region; and confirm: the right banner variant shows (or doesn't), and the consent record it writes carries the expected categories and collectedVia provenance.
  4. If behavior looks stale, re-check that you published after saving; the edge cache serves the last published bundle, not the saved draft.

Next steps

AltStyle によって変換されたページ (->オリジナル) /