Configuration reference
Reference for CookieBeam's RuntimeConfig, covering the main configuration fields, their types, allowed values, and default behavior.
Ostatnia aktualizacja:
This page documents the main fields on the RuntimeConfig object that the CookieBeam runtime reads. Some internal or rarely used fields (such as purposeConsent and guiOptions.consentModal.tcfHideDescription) are omitted. Dashboard-managed banners build this configuration automatically when you publish. Self-hosted installs pass it to CookieBeam.run(config).
Fields are grouped by section. Each table lists the field name, its TypeScript type, the default value (if any), and what it controls. Cross-links point to the guide pages that explain each feature in depth.
Top-level fields
| Field | Type | Default | Description |
|---|---|---|---|
mode | 'opt-in' | 'opt-out' | 'opt-in' | Consent model. Opt-in: nothing non-necessary runs until the visitor accepts. Opt-out: categories pre-activated until the visitor opts out. See Consent model. |
revision | number | - | Configuration revision. A mismatch with the stored consent triggers re-consent. See Categories. |
autoShow | boolean | true | Whether the banner auto-shows on page load when the visitor has no valid consent. |
hideFromBots | boolean | true | Skip showing the banner to detected bots and crawlers. |
disablePageInteractionOnShow | boolean | false | Block page interaction (dim the background) while the consent modal is visible. |
manageScriptTags | boolean | true | Enable automatic script blocking. See Blocking. |
autoClearCookies | boolean | true | Auto-remove cookies and storage when a category is revoked. See Categories. |
consentIdMode | 'off' | 'accepted' | 'any-choice' | 'off' | Controls whether the runtime creates a per-consent identifier. off: the consentId field holds 'anonymous'. accepted: creates an identifier when the visitor accepts at least one optional category. any-choice: creates an identifier on every explicit choice, including refusals. See Consent identifier. |
writeOptInDefaultAtLoad | boolean | true | Write a default consent record on page load in opt-in mode. When false, opt-in visitors stay cookieless until they make a choice. |
cookie
Controls the consent cookie. See Cross-domain consent for subdomain sharing.
| Field | Type | Default | Description |
|---|---|---|---|
name | string | 'cb_cookie' | Cookie name. |
expiresAfterDays | number | 182 | Days until the cookie expires (~6 months). |
domain | string | '' | Cookie domain. Empty uses the current host (host-only cookie). Set to example.com for subdomain sharing. |
path | string | '/' | Cookie path. |
secure | boolean | true | Only send over HTTPS. |
sameSite | 'Strict' | 'Lax' | 'None' | 'Lax' | SameSite attribute. |
useLocalStorage | boolean | false | Store consent in localStorage instead of a cookie. |
storage
| Field | Type | Default | Description |
|---|---|---|---|
enabled | boolean | false | Enable localStorage fallback for contexts where cookies aren't available (iframes, SameSite restrictions). |
categories
A map of category ID to CategoryConfig. See Categories and purposes.
| Field | Type | Default | Description |
|---|---|---|---|
enabled | boolean | - | Default state in opt-out mode. Ignored in opt-in mode. |
readOnly | boolean | - | If true, the visitor can't toggle this category off. Used for strictly necessary storage. |
services | Record<string, ServiceConfig> | - | Optional per-vendor toggles within this category. |
autoClear | AutoClearConfig | - | Storage to remove when this category is revoked. |
ServiceConfig
| Field | Type | Description |
|---|---|---|
label | string | Display name in the preferences panel. |
onAccept | () => void | Callback when this service is accepted. |
onReject | () => void | Callback when this service is rejected. |
cookies | AutoClearCookieEntry[] | Cookies to clear when this service is revoked. |
AutoClearConfig
| Field | Type | Description |
|---|---|---|
cookies | AutoClearCookieEntry[] | Cookie entries to remove (exact name or regex). |
localStorage | string[] | localStorage keys to remove. |
sessionStorage | string[] | sessionStorage keys to remove. |
reloadPage | boolean | Reload the page after clearing. Default: false. |
AutoClearCookieEntry
Either { name: string, domain?: string, path?: string } for exact matching, or { name: RegExp } for pattern matching.
guiOptions
Controls the banner's layout and behavior. See Appearance.
consentModal
| Field | Type | Values | Description |
|---|---|---|---|
layout | ConsentModalLayout | box, box wide, box inline, cloud, cloud inline, bar, bar inline | Banner layout variant. |
position | ModalPosition | top left, top center, top right, middle left, middle center, middle right, bottom left, bottom center, bottom right | Where the banner appears. |
equalWeightButtons | boolean | - | Give primary and secondary buttons equal visual weight. |
flipButtons | boolean | - | Reverse button order (reject first). |
showAcceptNecessary | boolean | - | Show the "Accept necessary" button. Default: true. |
preferencesTrigger | string | button, footerLink | Where the preferences link appears. |
animation | AnimationConfig | - | Entrance animation. See below. |
preferencesModal
| Field | Type | Values | Description |
|---|---|---|---|
layout | string | box, side, side wide, bar | Preferences modal layout. |
position | string | left, right, center, top, bottom, and all 9 corner/edge positions | Where the preferences modal appears. |
equalWeightButtons | boolean | - | Equal visual weight for buttons. |
flipButtons | boolean | - | Reverse button order. |
showAcceptNecessary | boolean | - | Show the reject button. Default: true. |
controlStyle | string | toggle, checkbox | How consent choices render. Default: toggle. |
Other guiOptions fields
| Field | Type | Description |
|---|---|---|
showCloseButton | boolean | Show X button and enable Escape to dismiss. Default: false. |
floatingSettingsButton | FloatingSettingsConfig | Floating re-entry button after consent. See Appearance. |
darkMode | 'auto' | 'light' | 'dark' | Color scheme mode. Default: 'light'. |
logo | LogoConfig | Site logo in the banner. |
languageSwitcher | LanguageSwitcherConfig | Visitor-facing language menu. See Languages. |
AnimationConfig
| Field | Type | Description |
|---|---|---|
entrance | string | fade, slide-up, slide-down, scale, none. |
duration | number | Duration in milliseconds. |
respectPrefersReducedMotion | boolean | Honor prefers-reduced-motion. Default: true. |
language
Controls language detection and translation loading. See Languages.
| Field | Type | Default | Description |
|---|---|---|---|
default | string | 'en' | Fallback language code. |
autoDetect | string | 'browser' | Detection mode: browser, document, geo, none. |
translations | Record<string, TranslationData> | - | Inline translations keyed by language code. |
rtlLanguages | string[] | - | Language codes that render right-to-left. |
dynamicLanguages | string[] | - | Language codes fetchable on demand from CDN. |
cdnTranslationUrl | string | - | URL template with {lang} placeholder for CDN fetches. |
translationResolver | TranslationResolver | { type: 'inline' } | Custom resolver (URL template or function). |
consentMode
Google Consent Mode v2 integration. See Consent Mode v2.
| Field | Type | Default | Description |
|---|---|---|---|
enabled | boolean | false | Enable Consent Mode integration. |
setDefaultsOnLoad | boolean | true | Fire gtag('consent', 'default', ...) on page load. |
redactAdsData | boolean | false | Enable ad data redaction when ad_storage is denied. |
passiveAnalytics | boolean | false | When enabled, pushes a dataLayer marker (cookiebeam_cmp_mode: 'passive') when analytics_storage is denied. Does not grant analytics_storage. |
waitForUpdate | number | 2000 | Milliseconds to tell Google tags to wait for consent before firing. |
urlPassthrough | boolean | true | Pass ad click identifiers in URLs across domains. |
deferMachineDefaults | boolean | - | Defer machine-written default consent until explicit consent. |
tcf
IAB TCF 2.3 configuration. See IAB TCF.
| Field | Type | Default | Description |
|---|---|---|---|
enabled | boolean | false | Enable TCF framework. |
cmpId | number | 0 | CMP ID. The published banner script sets this to CookieBeam's registered ID (526); the runtime default is 0. |
cmpVersion | number | - | CMP implementation version. |
gvlUrl | string | - | Custom URL for the Global Vendor List JSON. |
vendorListVersion | number | - | Pin a specific GVL version. |
visitorOutsideScope | boolean | false | Skip TCF for this visitor (set by the banner from geo data). |
gpp
IAB GPP configuration. See IAB GPP.
| Field | Type | Default | Description |
|---|---|---|---|
enabled | boolean | false | Enable GPP framework. |
cmpId | number | - | Registered GPP CMP ID. |
sections | GppSectionName[] | - | Which GPP sections to include in the string. |
GppSectionName values
tcfeuv2, uspv1, usnat, usca, usva, usco, usct, usut, usfl, usmt, usor, ustx, usde, usia, usne, usnh, usnj, ustn, usmn, tcfcav1
gpc
GPC-specific configuration (self-hosted API). See Privacy signals.
When a gpc object is present in the config, the runtime honors the GPC signal by default. Set enabled: false to suppress it.
| Field | Type | Default | Description |
|---|---|---|---|
enabled | boolean | true (when the gpc object is present) | Whether to honor the GPC signal. The runtime honors GPC whenever this object exists, unless enabled is explicitly false. |
autoOptOutCategories | string[] | [] | Category IDs to auto-reject when GPC is detected. |
privacySignals
Dashboard-emitted privacy signal settings. An explicit gpc key takes precedence over the GPC fields here. See Privacy signals.
| Field | Type | Default | Description |
|---|---|---|---|
respectGpc | boolean | - | Honor GPC signal. |
respectDnt | boolean | - | Honor DNT signal. |
mode | string | - | 'hard_optout' or 'preselect_deny'. |
categoriesToBlock | string[] | - | Categories to strip when a signal is present. Empty means all non-readOnly. |
showToast | boolean | - | Show a toast when the signal is honored. |
toastDurationMs | number | 5000 | Toast display duration in milliseconds. |
scriptGating
Custom attribute names for manual script gating. See Blocking.
| Field | Type | Default | Description |
|---|---|---|---|
dataAttributeName | string | 'data-category' | Attribute that names the consent category. |
placeholderTypeValue | string | 'text/plain' | Script type value that prevents execution. |
srcAttributeName | string | 'data-src' | Attribute that holds the real script URL. |
Lifecycle callbacks
Callbacks on the RuntimeConfig fire at specific consent lifecycle events. See Events reference.
| Callback | Fires when |
|---|---|
onFirstConsent | The visitor makes their first explicit choice (not on defaults). |
onConsent | Any consent write: first consent, defaults, and subsequent changes. Does not fire on restored consent (return visits with a valid record). |
onChange | The visitor changes their consent (accepts or revokes a category). |
onModalShow | The consent or preferences modal becomes visible. |
onModalHide | A modal is dismissed. |
onModalReady | The modal has been created in the DOM and is ready to show. |
regionalSettings
Regional rule configuration. See Regional rules.
| Field | Type | Description |
|---|---|---|
enabled | boolean | Enable regional rules. |
fallback | object | Behavior when no rule matches. See Regional rules. |
rules | RegionalRule[] | The ordered list of regional rules. See Regional rules. |
gtm
Google Tag Manager loader integration.
| Field | Type | Default | Description |
|---|---|---|---|
enabled | boolean | false | Whether the banner was loaded through a GTM template. |
containerIds | string[] | - | GTM container IDs associated with this banner. |
experiment
A/B test configuration. Set automatically when a banner has an active experiment. Requires testId, variantId, and variantKey together; if any is missing the experiment config is dropped.
| Field | Type | Description |
|---|---|---|
testId | string | The experiment's identifier. Required. |
variantId | string | The assigned variant's identifier. Required. |
variantKey | string | The experiment variant key assigned to this visitor. Required. |
consentModelOverride | object | Optional override that changes the consent model for this variant. |
regionalOverride | object | Optional regional behavior override for this variant. |
See A/B testing.
environment
Loader-passed environment data. These fields are set by the CDN loader, not by the site owner.
| Field | Type | Description |
|---|---|---|
apiBaseUrl | string | Base URL for the CookieBeam API. |
cdnBaseUrl | string | Base URL for the CookieBeam CDN. |
cfCountry | string | ISO 3166-1 alpha-2 country code from the CDN edge. |
cfRegion | string | ISO 3166-2 subdivision code from the CDN edge. |
bannerId | string | Internal banner identifier. |
publicBannerId | string | Public-facing banner identifier. |
isGtmLoad | boolean | Whether the runtime was loaded via a GTM template. |
variantKey | string | A/B test variant from the loader (when an experiment is active). |
precomputedRegionalBehavior | object | Regional rule result pre-computed by the CDN loader to avoid re-matching. |