One-Time Consent Events
Overview
These events support a narrow use case. Setting them up is not required for a normal CMP installation — the
standard consentChanged integration (and Consent Mode setup) already covers
typical tag management. They're an optional tool for certain advanced, custom tag-management setups.
In addition to the consentChanged event, our CMP emits a set of
one-time-per-page-load browser events that each correspond to a specific consent action. Unlike consentChanged
— which carries the current consent state in its event.detail payload and can fire several times per page load —
these events are signals: they have a distinct event name per consent action and fire at most once per page load.
This is useful when your integration can react to an event by name but can't (easily) inspect a payload — most
commonly a Google Tag Manager or other tag-manager trigger. The intended use is reacting to a new, specific consent
change that differs from the consumer's initial on-page consent defaults: your tag manager should already have read
those defaults correctly when it initialized (via the standard consentChanged / Consent Mode setup), so these
one-time events are how you respond when the consumer later grants — or opts out of — a consent that the on-page
defaults didn't already cover, and that you aren't able to react to with the standard consentChanged setup.
- Event target:
window - Event type:
CustomEvent bubbles:true- Fires: at most once per page load, and only in response to a user action
The current consent settings are also attached to event.detail (the same shape as the
consentChanged payload) for convenience, but you don't need to read
it — the event name alone tells you what happened.
Events
| Event name | Fires when… |
|---|---|
pageSessionConsentGrantedAll* | The consumer presses Accept All on the banner (GDPR / default-no-consent variants). *See details below. |
pageSessionConsentGrantedAnalytics | Analytics consent is granted by the consumer for the first time this page load. |
pageSessionConsentGrantedAds | Advertising consent is granted by the consumer for the first time this page load. |
pageSessionConsentGrantedPersonalization | Personalization consent is granted by the consumer for the first time this page load. |
pageSessionConsentGrantedTargeted | Targeted Advertising is granted (consumer is not opted out) for the first time this page load. |
pageSessionConsentRejectedAnalytics | Analytics consent is rejected by the consumer for the first time this page load. |
pageSessionConsentRejectedAds | Advertising consent is rejected by the consumer for the first time this page load. |
pageSessionConsentRejectedPersonalization | Personalization consent is rejected by the consumer for the first time this page load. |
pageSessionConsentRejectedTargeted | Targeted Advertising is rejected (consumer opts out) for the first time this page load. |
pageSessionConsentGrantedAll is an aggregate signal for the Accept All action. When the consumer presses Accept
All, this is the only grant event emitted — the individual per-category grant events (pageSessionConsentGrantedAnalytics,
etc.) are not also fired. If you need to know that a specific consent was granted, listen for both
pageSessionConsentGrantedAll and that consent's per-category event.
There is intentionally no RejectedAll event. A Reject All button is only shown on the banner variant whose
default state is already fully rejected (the default-no-consent / GDPR-style variant), so pressing it doesn't change
anything and there's nothing to signal. Variants whose default isn't already rejected (e.g. the default-consent /
opt-out variant) have no Reject All button — consumers reject individual categories with the preference toggles so rejections are always reported per consent
category.
Behavior
These events are deliberately narrower than consentChanged. Keep the following in mind:
- User actions only. They fire only when the consumer makes a choice (pressing Accept All / Reject All, flipping a preference toggle, or using the one-click opt-out link). They do not fire for automatic state changes such as the initial regional defaulting on page load, reading a previously-saved consent cookie, or an automatic opt-out applied from a GPC signal or a stored US opt-out. This is what makes them a reliable trigger for "the consumer just changed their mind," as opposed to "the page initialized."
- At most once per page load. Each event fires the first time its action occurs and not again, even if the
consumer toggles the same consent off and back on. (Granting analytics, then rejecting it, then granting it again
fires
pageSessionConsentGrantedAnalyticsonce andpageSessionConsentRejectedAnalyticsonce.) - Accept All emits only
pageSessionConsentGrantedAll(not the individual per-category grant events) — see the callout under Events above. - Linked Advertising / Targeted Advertising. When these toggles are linked, turning Advertising off also turns off
Targeted Advertising (and the one-click opt-out link turns off both). In those cases you'll receive both
pageSessionConsentRejectedAdsandpageSessionConsentRejectedTargeted.
Integration Examples
React to a specific consent being granted
<script>
// Fires at most once, the first time the consumer grants advertising consent this page load.
window.addEventListener('pageSessionConsentGrantedAds', () => {
// e.g. load an advertising tag that GTM can't gate on the consentChanged payload.
loadAdvertisingTag();
});
</script>
React to the first overall grant on the page
<script>
// Fires once when the consumer presses "Accept All".
window.addEventListener('pageSessionConsentGrantedAll', () => {
reevaluatePageScripts();
});
</script>
Bridge to Google Tag Manager
If you manage tags in GTM, you can forward any of these events into the data layer and trigger off them with a Custom Event trigger:
<script>
window.addEventListener('pageSessionConsentGrantedAnalytics', () => {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({ event: 'pageSessionConsentGrantedAnalytics' });
});
</script>
Implementation Notes
- Attach listeners as early as possible so you don't miss an event dispatched during banner interaction.
- The event name is the source of truth; reading
event.detailis optional. - These events complement, but do not replace,
consentChanged. UseconsentChangedwhen you need the full, current consent state (including the initial/default state); use these one-time events when you need a named signal for a specific consumer-driven consent change.