Categories and purposes
How consent categories, services, and US opt-out purposes are modeled, and what each visitor action records.
Last updated:
CookieBeam organizes everything a visitor can consent to into categories. Categories are the unit the banner displays, the unit the blocking engine enforces, and the unit stored on the consent record.
The category model
Your banner configuration defines a set of categories. Each category carries an enabled flag and can be marked readOnly:
- A
readOnlycategory is always on. It appears in the preference panel but cannot be toggled off, and it is included in every recorded choice, including "accept necessary" and any custom selection. Strictly necessary storage belongs here. - Every other category is optional. The visitor can grant or deny it, and in opt-out mode categories with
enabled: trueare pre-selected until the visitor says otherwise.
The scanner classifies what it finds into necessary, analytics, marketing, preferences, or unknown (see Auto-scanner). You shape the banner's category list yourself in the designer's Categories section (Dashboard → Banners → your banner → Design); the inventory informs that work but does not write it. Inventory → Services proposes services from the scan, each with a suggested category, and tells you when one needs a category your banner doesn't offer yet (see Service proposals). Accepting a proposal never adds the category for you.
CategoryConfig reference
Each category in the runtime configuration follows this shape:
{
enabled: boolean, // default state in opt-out mode; ignored in opt-in
readOnly: boolean, // if true, visitor can't toggle it off
services?: { // optional per-vendor toggles inside the category
[serviceName: string]: {
label: string,
onAccept?: () => void,
onReject?: () => void,
cookies?: AutoClearCookieEntry[],
}
},
autoClear?: { // auto-remove storage when this category is denied
cookies?: AutoClearCookieEntry[],
localStorage?: string[],
sessionStorage?: string[],
reloadPage?: boolean,
}
}
The enabled flag only matters in opt-out mode, where it determines whether the category starts pre-selected. In opt-in mode every non-readOnly category starts denied regardless of enabled. In notice mode all categories are active from the start: enabled has no effect because the banner informs rather than gates.
How enabled and readOnly interact with the consent model
| Mode | readOnly categories | Non-readOnly with enabled: true | Non-readOnly with enabled: false |
|---|---|---|---|
| Opt-in | Always on | Denied until visitor accepts | Denied until visitor accepts |
| Opt-out | Always on | Pre-selected; visitor can opt out | Denied until visitor accepts |
| Notice | Always on | Active (informational) | Active (informational) |
Services: per-vendor toggles
Within a category you can record consent at service granularity. When services are configured, the preferences panel shows individual toggles for each vendor inside the parent category. The stored consent state keeps a map of category names to the individual services the visitor selected, so "analytics on, but only for these vendors" is representable.
Each service has:
label- the display name shown in the preferences panel.onAccept/onReject- optional callbacks that fire when this specific service is accepted or rejected.cookies- optional auto-clear entries scoped to this service. These work the same way as category-level auto-clear (see below).
A visitor who accepts a category but denies a specific service within it still has the category consent recorded, but the service is marked denied in the services map. Your code should check both the category and the service when gating a vendor's tag.
Auto-clearing storage on rejection
When a visitor rejects a category (or a service), CookieBeam can automatically remove the cookies and storage entries that category set. This is the autoClear configuration.
Cookie entries accept either a string name or a regex pattern:
// Exact name, with optional domain and path
{ name: "_ga", domain: ".example.com", path: "/" }
// Regex pattern (matches _ga, _ga_*, _gat_*)
{ name: /^_ga/ }
If you omit domain, the runtime tries the host domain and common parent-domain variants. If you omit path, it defaults to /.
localStorage and sessionStorage entries are exact key names. CookieBeam removes them when the category is denied.
reloadPage: when true, the page reloads after clearing this category's storage. Use this when a third-party script has already initialized state in memory that can't be cleaned up without a fresh page load. Default is false.
Auto-clear runs when:
- The visitor saves a custom selection that denies the category.
- The visitor clicks "Accept necessary" and the category isn't readOnly.
- A privacy signal (GPC) strips the category from the defaults.
It does not run on the initial page load for a visitor who never had the category, only on transitions from accepted to denied.
What each visitor action records
Every choice resolves to a category set and an acceptType:
| Action | Categories recorded | acceptType |
|---|---|---|
| Accept all | Every category in the configuration | all |
| Accept necessary | Only the readOnly categories | necessary |
| Save custom selection | readOnly categories plus the visitor's selection | custom |
A custom selection always keeps the readOnly categories, and category names that no longer exist in the configuration are dropped rather than stored.
The stored consent record
Each visitor's state is stored as a canonical record (schema version 2) containing the accepted categories and services, the acceptType, first and most recent consent timestamps, the banner language, a consent identifier and a configuration revision so you can prove which banner version the visitor saw. The schema also defines an optional jurisdictions field, but the browser runtime does not populate it; a record written by the banner does not tell you which regional rule matched, so do not rely on the field being present.
The record also carries provenance flags your auditors will ask about:
collectedVia: how the row was produced: an explicit banner or preferences choice, the API, or a machine-written default (default_optin,default_optout,default_notice,hidden_autogrant).isDefaultState: the record is a machine-written default, not an explicit visitor choice.isPending: on its own, an opt-in visitor has not decided yet and nothing non-necessary is granted. With Google Consent Mode on,isPendingis also set on machine-written opt-out, notice and hidden-region defaults (isDefaultState: truewithcollectedViadefault_optout,default_noticeorhidden_autogrant) so the GTM template does not restore them at Consent Initialization. Those defaults do grant theircategories. Code that reads the cookie directly (including a server-side GTM variable) should classify the record withcollectedViaandisDefaultState, or callCookieBeam.getUserPreferences()/CookieBeam.acceptedCategory(), rather than treatisPendingalone as "no consent".gpcRespected: a privacy signal shaped this record (see Privacy signals).
US opt-out purposes
For visitors under US opt-out frameworks, the preferences panel exposes per-purpose choices: sale or sharing of personal data, targeted advertising, and sensitive data. These are recorded as purposeChoices on the consent log, distinct from the category list. The data model also reserves a profiling purpose for future use; it is defined in the schema but not yet exposed in the preferences panel UI.
Which toggles appear depends on the regional rule's optOutToggles configuration: saleSharing, targetedAdvertising, and sensitiveData can each be independently enabled or disabled per rule. The framework presets configure these automatically; for example, the CCPA preset enables sale/sharing and targeted advertising toggles.
purposeChoices is populated only when a US visitor actively opens the opt-out panel and confirms it. It is deliberately null for:
- machine-written default records (auto-grants in opt-out or notice mode), and
- visitors under opt-in frameworks such as the GDPR presets, who never see the panel.
A null value on those rows is expected behavior, not missing data.
Note what analytics does with this: the dashboard's purpose opt-in/opt-out view (see Consent analytics) aggregates the consent categories (analytics, marketing, preferences) stored in consent_given. It does not aggregate the US purposeChoices field, so per-purpose opt-out rates for sale/sharing, targeted advertising, and sensitive data are not reported there today; the stored purposeChoices rows are available in the consent log data itself.
Revision and re-consent
The runtime configuration carries a revision number. When you bump it, visitors whose stored consent was recorded against a lower revision are treated as if they have no consent: the banner shows again and they must make a new choice.
Use revision bumps when you make a material change to what a category means, such as adding a new vendor to the marketing category or changing which cookies a category covers. Don't bump revision for cosmetic changes like button color or wording updates.
The revision is stored on the consent record, so you can audit which configuration version each visitor consented to.
Scoped categories
Regional rules can narrow which categories require consent for visitors in a specific jurisdiction. The scopedCategories field on a rule lists the category IDs that are shown in the consent UI and subject to consent logic. Unlisted non-readOnly categories are treated as permanently granted for visitors matched by that rule.
This is useful when a jurisdiction's law only covers certain types of processing. For example, a rule for a region that only regulates marketing tracking could scope to ["marketing"], letting analytics and preferences run without consent for visitors there.
An empty scopedCategories array means only readOnly categories are in scope, which is equivalent to hiding the banner. See Regional rules for how this interacts with rule matching.
Adding and removing categories
Add categories in Dashboard → Banners → your banner → Design → Categories. Each category needs an ID (a short, stable string like analytics or social_media) and a display name.
Adding a category doesn't affect existing consent records. Visitors who already consented continue with their stored choice; the new category is denied until they update their preferences. If you want to prompt visitors again, bump the revision number (see above).
Removing a category doesn't break existing records, but stored category names that no longer exist in the configuration are silently dropped when the runtime reads the cookie. Scripts gated to the removed category stop running: the runtime does not recognize the category, so it treats consent as denied. Move scripts to another category before removing the old one.
Renaming a category is a remove-and-add: the runtime matches by ID, not display name. If you change a category's ID, existing consent records don't carry over. Change the display name instead when the underlying meaning stays the same.
How categories map to integrations
Categories are the bridge between your consent UI and the integration layer. Each integration reads category consent and translates it into its own signal format.
Google Consent Mode v2
CookieBeam maps the default categories to Google's 7 consent keys:
| Category | Consent Mode keys |
|---|---|
necessary | security_storage (always granted) |
analytics | analytics_storage |
marketing | ad_storage, ad_user_data, ad_personalization |
preferences | functionality_storage, personalization_storage |
When a visitor accepts a category, the mapped keys become granted. The mapping above covers the default categories; custom categories do not map to Consent Mode keys automatically. See Consent Mode v2.
IAB TCF
When TCF is enabled, category acceptance also updates the TC string's purpose bits. Accepting marketing grants advertising-related TCF purposes; accepting analytics grants measurement purposes. The exact mapping depends on your banner configuration and is shown in the dashboard under TCF settings. See IAB TCF.
IAB GPP
For US visitors, category consent feeds into the GPP section fields. A rejected marketing category sets the sale-of-data and targeted-advertising fields to opted out in the visitor's GPP section. The US opt-out purposes (purposeChoices) map directly to section-specific fields. See IAB GPP.
Publish and verify category changes
- Edit the banner's Categories section and click Save in the designer.
- Click Publish in the banner header and complete the publish dialog.
- Open the served banner in a clean browser profile. Open its preferences panel and confirm the expected categories, services, and locked
readOnlychoices. - Save a custom selection and verify that the stored consent state contains the expected category and service selections.
Checking categories in your code
The Browser API provides methods for reading category consent at runtime:
// Check whether a specific category is accepted
CookieBeam.acceptedCategory('analytics'); // true or false
// Check whether a specific service within a category is accepted
CookieBeam.acceptedService('Google Analytics', 'analytics');
// Get the full consent state
const prefs = CookieBeam.getUserPreferences();
// prefs.acceptedCategories: string[]
// prefs.rejectedCategories: string[]
// prefs.acceptedServices : Record<string, string[]>
// prefs.rejectedServices : Record<string, string[]>
For server-side checks, read the consent cookie directly and parse the categories object. See Read consent on your server for language-specific examples.