CookieFirst
Integrates CookieFirst consent management with walkerOS by listening for CookieFirst events and translating consent categories to walkerOS consent groups.
Installation
npm install @walkeros/web-source-cmp-cookiefirst
import { startFlow } from '@walkeros/collector';
import { sourceCookieFirst } from '@walkeros/web-source-cmp-cookiefirst';
await startFlow({
sources: {
consent: {
code: sourceCookieFirst,
},
},
});
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 |
|---|---|---|---|
categoryMap | Record<string, string> | Map the CMP's consent categories (keys) to walkerOS consent groups (values). | |
globalName | string | Custom name for the CookieFirst global on window. Default: 'CookieFirst'. |
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 categoryMap remaps performance to statistics instead of analytics
{
"necessary": true,
"functional": false,
"performance": true,
"advertising": false
}{
"settings": {
"categoryMap": {
"performance": "statistics"
}
}
}elb("walker consent", {
"functional": true,
"statistics": true,
"marketing": false
})cf_init detection
CMP detected via cf_init CustomEvent (primary detection path)
{
"necessary": true,
"functional": false,
"performance": false,
"advertising": true
}elb("walker consent", {
"functional": true,
"analytics": false,
"marketing": true
})Full consent
CookieFirst reports all categories granted and the source forwards a walker consent command with all groups true.
{
"necessary": true,
"functional": true,
"performance": true,
"advertising": true
}elb("walker consent", {
"functional": true,
"analytics": true,
"marketing": true
})Partial consent
A partial CookieFirst grant maps analytics and marketing to false in the emitted walker consent command.
{
"necessary": true,
"functional": true,
"performance": false,
"advertising": false
}elb("walker consent", {
"functional": true,
"analytics": false,
"marketing": false
})How it works
-
Initialization: Checks if CookieFirst is already loaded and processes existing consent state from
window.CookieFirst.consent. -
cf_init event: Listens for the
cf_initwindow event and readswindow.CookieFirst.consenteach time it fires. -
cf_consent event: Listens for the
cf_consentwindow event and processes the consent state in itsdetail. -
Consent mapping: Translates CookieFirst categories to walkerOS consent groups and calls
elb('walker consent', state).
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 to functional), the source uses OR logic: if ANY
source category is true, the target group is true.
With the default mapping, functional is granted whenever CookieFirst reports
necessary: true, even if the visitor denied the functional category.
Categories missing from categoryMap are reported under their CookieFirst
name. The source reports nothing while window.CookieFirst.consent is null,
that is until the visitor has made a choice.
Custom mapping example
await startFlow({
sources: {
consent: {
code: sourceCookieFirst,
config: {
settings: {
categoryMap: {
performance: 'statistics', // Use 'statistics' instead of 'analytics'
},
},
},
},
},
});