---
title: "Consent identifier"
description: "Link a visitor's stored consent to your own records with an optional per-consent identifier."
url: "https://cookiebeam.com/docs/configure/consent-id"
lang: "en"
last_updated: "2026-11-25"
---

# Consent identifier

Link a visitor's stored consent to your own records with an optional per-consent identifier.

The consent identifier is an optional random value the runtime creates when a visitor makes a consent choice. It lets you match a consent event to records in your own systems without relying on a device fingerprint or a tracking cookie.

## The setting

The setting lives on each banner under **Banner settings > Consent** and has three positions:

| Position | Creates an identifier when... |
| -------- | --------------------------- |
| **Off** (default) | Never. The `consentId` field in the consent cookie holds the placeholder `anonymous`. |
| **After acceptance** | The visitor's choice accepts at least one optional category the visitor was asked about. Saving the preference panel with every toggle off is a refusal and creates no identifier. A category the visitor's region does not ask about does not count. |
| **After any choice** | Every explicit choice, including refusals and US opt-outs. On banners that serve an opt-in region, the dashboard shows a note that EDPB guidance (13 December 2023 letter) advises against a unique identifier on refusal. |

Under **After any choice**, closing the banner with the X button gets an identifier only in opt-in regions, where the close stores a necessary-only record. In notice and opt-out regions, the X button writes nothing to the consent cookie, so no identifier is created.

The setting is off by default. When it is off, or when a visitor's choice does not qualify, no identifier is created and `getCookie('consentId')` returns `undefined`.

The setting belongs to the banner. An A/B test arm always follows it.

## What the identifier is

The identifier is `cb1_` followed by 32 lowercase hexadecimal characters, derived from a random UUID. It is created only by the visitor's own action: a banner click, a preference-panel save or a call through your site's JavaScript API. It is never created at page load, never for a machine-applied default (such as an opt-out region's automatic grant), never from a GPC or DNT signal and never when a previously stored choice is reloaded.

The identifier is not a device identifier and not a visitor identifier. CookieBeam's own analytics, consent counters, unique-visitor counts and A/B testing never read it.

## Storage and lifetime

The identifier is stored in the `consentId` field of the consent cookie (`cb_cookie`) and shares the cookie's lifetime. Without an identifier the field holds `anonymous`.

CookieBeam does not store the identifier on its side today. Server-side storage of the identifier with the consent record, and delivery through webhooks, are planned follow-ups.

## Reading the identifier

| Method | Returns |
| ------ | ------- |
| `CookieBeam.getCookie('consentId')` | The identifier string, or `undefined` when none exists |
| `onConsent` / `onChange` / `onFirstConsent` callbacks | The consent state carries `consentId` (the identifier or `null`) |

**Dashboard-published banners:** the callbacks above are owned by the dashboard wrapper and are not passed to your code. Read the current identifier with `getCookie('consentId')` after a consent event.

**Self-hosted installs:** configure `onChange` on the `RuntimeConfig` to receive the identifier in the callback payload directly.

The `cookiebeam:consentUpdate` window event and `CookieBeamGTM.getConsent()` do not carry the identifier in this release. Exposure through the GTM bridge, server-side GTM, webhooks and receipts is planned as a follow-up.

## Changed and replaced identifiers

Repeating the same choice keeps the existing identifier. Changing the choice, for example switching a category on or off and saving, creates a new one.

**Self-hosted installs** that configure `onChange` on the `RuntimeConfig` receive the replaced identifier as `endsConsentId` in the callback, so your backend can link the old and new records.

**Dashboard-published banners** do not receive `endsConsentId` today. The dashboard wrapper owns the `onChange` callback and does not pass `endsConsentId` through, and no DOM event carries it. You can read the current identifier with `getCookie('consentId')` but cannot learn which identifier it replaced yet. Chaining support for dashboard banners is a planned follow-up.

Under **After acceptance**, a withdrawal that removes every optional category removes the identifier from the device before the callbacks run. The withdrawal callback sees no current identifier (`consentId` is `null`); on self-hosted installs, the removed identifier is still passed as `endsConsentId`.

## Switching the setting off or narrowing it

If the owner switches the setting off, or narrows it from **After any choice** to **After acceptance**, an identifier the current setting would not create stops being handed out at the next page load. The visitor's next choice then removes it.

## Matching a consent record to your own data

**Self-hosted installs:** when a visitor makes a choice, read the identifier from the `onChange` callback on your `RuntimeConfig` and store it alongside whatever internal reference you use (a session ID, an order number, a CRM key). If the choice replaces an earlier one, `endsConsentId` in the same callback tells you which identifier was retired, so you can chain the old and new records on your side.

**Dashboard-published banners:** after a consent event, call `getCookie('consentId')` to read the current identifier and store it alongside your own reference. Chaining to a replaced identifier is not yet available for dashboard banners.

Server-side storage on CookieBeam's consent record and webhook delivery are planned follow-ups. Once available, you will also be able to look up the identifier in the dashboard.
