@walkeros/web-source-cmp-cookiefirst
v2.0.1
Published
CookieFirst consent management source for walkerOS
Maintainers
Readme
@walkeros/web-source-cmp-cookiefirst
CookieFirst consent management source for walkerOS.
This source listens to CookieFirst CMP events and translates consent states to walkerOS consent commands.
Installation
npm install @walkeros/web-source-cmp-cookiefirstUsage
import { startFlow } from '@walkeros/collector';
import { sourceCookieFirst } from '@walkeros/web-source-cmp-cookiefirst';
await startFlow({
sources: {
consent: {
code: sourceCookieFirst,
},
},
destinations: {
gtag: {
code: destinationGtag,
config: {
consent: { analytics: true }, // Requires analytics consent
},
},
},
});Configuration
Settings
| Setting | Type | Default | Description |
| -------------- | ------------------------ | --------------- | ------------------------------------------------------ |
| categoryMap | Record<string, string> | See below | Maps CookieFirst categories to walkerOS consent groups |
| explicitOnly | boolean | true | Only process explicit consent (user made a choice) |
| globalName | string | 'CookieFirst' | Custom name for window.CookieFirst object |
Default Category Mapping
{
necessary: 'functional',
functional: 'functional',
performance: 'analytics',
advertising: 'marketing',
}When multiple CookieFirst categories map to the same walkerOS group (e.g., both
necessary and functional → functional), the source uses OR logic: if ANY
source category is true, the target group is true.
Custom Mapping Example
await startFlow({
sources: {
consent: {
code: sourceCookieFirst,
config: {
settings: {
categoryMap: {
performance: 'statistics', // Use 'statistics' instead of 'analytics'
},
explicitOnly: true,
},
},
},
},
});How It Works
Initialization: When the source loads, it checks if CookieFirst is already initialized and processes any existing consent state.
cf_init Event: Listens for the
cf_initevent fired when CookieFirst banner initializes.cf_consent Event: Listens for the
cf_consentevent fired when user changes their consent preferences.Consent Mapping: Translates CookieFirst categories to walkerOS consent groups and calls
elb('walker consent', state).
CookieFirst API Reference
Related
License
MIT
