Usercentrics
Integrates Usercentrics consent management with walkerOS by listening for a configured window event and mapping category or service consent state to walkerOS consent groups.
Installation
npm install @walkeros/web-source-cmp-usercentrics
import { startFlow } from '@walkeros/collector';
import { sourceUsercentrics } from '@walkeros/web-source-cmp-usercentrics';
await startFlow({
sources: {
consent: {
code: sourceUsercentrics,
config: {
settings: {
eventName: 'ucEvent', // Must match your Usercentrics admin config
categoryMap: {
essential: 'functional',
functional: 'functional',
marketing: 'marketing',
},
},
},
},
},
});
Configuration
This source uses the standard source config wrapper (consent, data, env, id, ...). For the shared fields see source configuration. Package-specific fields live under config.settings and are listed below.
Settings
| Property | Type | Description | More |
|---|---|---|---|
eventName | string | Window event name to listen for, configured in the Usercentrics admin (Implementation > Data Layer & Events). Use 'UC_SDK_EVENT' for the built-in Browser SDK event. Default: 'ucEvent'. | |
categoryMap | Record<string, string> | Map the CMP's consent categories (keys) to walkerOS consent groups (values). | |
explicitOnly | boolean | Only process consent_status events where type is 'explicit'. Ignores implicit/default page-load events. Default: true. |
Mapping
This package does not define custom rule-level settings. For the standard rule fields (consent, condition, data, batch, name, policy) see mapping.
Examples
category map override
custom event name
full consent
minimal consent
How it works
-
Event listener: Registers a listener for the configured window event (default:
ucEvent). -
Group vs. service detection: Checks if
ucCategoryvalues are all booleans:- Group-level: Uses
ucCategoryas consent state (maps categories viacategoryMap) - Service-level: Extracts individual service booleans from
event.detail(normalized tolowercase_underscores) and appliescategoryMapto booleanucCategoryentries
- Group-level: Uses
-
Explicit filtering: By default, only processes events where
type === 'explicit'(user actively made a choice). SetexplicitOnly: falseto also process implicit/default consent. -
Consent command: Calls
elb('walker consent', state)with the mapped consent state.
Usercentrics setup
Configure a Window Event in your Usercentrics admin:
Implementation > Data Layer & Events > Window Event Name (e.g., ucEvent).

Alternatively, set eventName: 'UC_SDK_EVENT' to use the built-in Browser SDK
event (no admin configuration required).
Custom mapping example
await startFlow({
sources: {
consent: {
code: sourceUsercentrics,
config: {
settings: {
eventName: 'ucEvent',
categoryMap: {
essential: 'functional',
functional: 'functional',
marketing: 'marketing',
},
explicitOnly: true,
},
},
},
},
});
Timing considerations
The source should be initialized before the Usercentrics script loads to avoid
missing the initial consent event. When using explicitOnly: true (default),
this is not a concern since the implicit init event is filtered anyway. For
explicitOnly: false, ensure the consent source has no require constraints
so it initializes immediately.