consentChanged CMP Event Reference
Overview
Our CMP emits a browser CustomEvent named consentChanged on window whenever consent settings are emitted or updated.
- Event target:
window - Event type:
CustomEvent - Event name:
consentChanged - Event detail: consent settings object (
event.detail) bubbles:true
The event detail is a snapshot of the current consent state.
Payload
The CMP emits consent settings with these fields:
| Field | Type | Description |
|---|---|---|
clientId | string | Per-browser UUID used for consent record association |
implicit | boolean | true when consent is implicit; false after explicit user choice (including an opt-out from the Privacy Center) |
analyticsPermitted | boolean | Analytics consent signal |
personalizationPermitted | boolean | Personalization consent signal |
adsPermitted | boolean | Advertising consent signal |
essentialPermitted | boolean | Always true |
notOptedOut | boolean | true means consumer is not opted out of targeted advertising/data sale. false means the consumer is opted out. (in other words, this is a "true means permission" signal like the others) |
informationalConsentBannerDismissed | boolean | Set when the informational banner is dismissed |
Example payload:
{
"clientId": "550e8400-e29b-41d4-a716-446655440000",
"implicit": false,
"analyticsPermitted": true,
"personalizationPermitted": true,
"adsPermitted": false,
"essentialPermitted": true,
"notOptedOut": false,
"informationalConsentBannerDismissed": false
}
When It Is Emitted
consentChanged can fire multiple times per page load.
1. During Polaris bootstrap
On startup, Polaris emits initial (the regional default or the saved) consent state during initialization.
Notes:
- This can happen very early.
- Depending on script load order, listeners attached later might miss this first event.
2. When consent is updated
Any user action or code path that updates consent emits consentChanged by default, including but not limited to:
- Accept All / Reject All actions
- Individual preference toggle changes (analytics/personalization/ads/targeted)
- Opt-outs that are applied from the Privacy Center (
us_privacycookie) or GPC signal
3. Informational banner dismissal
When the informational banner is dismissed, CMP updates informationalConsentBannerDismissed and emits consentChanged.
Integration Example
<script>
window.addEventListener('consentChanged', (event) => {
const consent = event.detail || {};
// React to consent updates here.
// Example: enable/disable tags that are controlled outside of GTM, update in-page features, etc.
console.log('consentChanged', consent);
});
</script>
Implementation Notes
- Treat
event.detailas the source of truth for current consent state. - Do not assume the event fires only after user interaction.
- Do not assume only one event per page load.
- Attach listeners as early as possible if you must capture the first initialization emission.