Skip to content

ConsentModeMapping

type ConsentModeMapping = Partial<Record<GtagConsentKey, ConsentModeRule | null>>;

Defined in: types.ts:112

Custom mapping from Tickbox category IDs to Google Consent Mode v2 keys.

Merged shallowly with the built-in defaults, so any keys you don’t override keep their defaults. Pass null for a key to remove it from the gtag('consent','update', ...) call entirely.

Example

defineConsent({
categories: {
necessary: { required: true },
advertising: { vendors: [...], default: false }, // not 'marketing'
stats: { vendors: ['plausible'] }, // not 'analytics'
},
consentMode: {
ad_storage: { category: 'advertising' },
ad_user_data: { category: 'advertising' },
ad_personalization: { category: 'advertising' },
analytics_storage: { category: 'stats' },
},
})