Skip to main content

One-Time Consent Events

Overview​

note

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 nameFires when…
pageSessionConsentGrantedAll*The consumer presses Accept All on the banner (GDPR / default-no-consent banner types).

*See details below.
pageSessionConsentGrantedAnalyticsAnalytics consent is granted by the consumer for the first time this page load.
pageSessionConsentGrantedAdsAdvertising consent is granted by the consumer for the first time this page load.
pageSessionConsentGrantedPersonalizationPersonalization consent is granted by the consumer for the first time this page load.
pageSessionConsentGrantedTargetednotOptedOut is granted by the consumer (by turning Advertising on) for the first time this page load.
pageSessionConsentRejectedAnalyticsAnalytics consent is rejected by the consumer for the first time this page load.
pageSessionConsentRejectedAdsAdvertising consent is rejected by the consumer for the first time this page load.
pageSessionConsentRejectedPersonalizationPersonalization consent is rejected by the consumer for the first time this page load.
pageSessionConsentRejectedTargetedThe consumer opts out of sale/sharing for the first time this page load.
info

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 type whose default state is already fully rejected (the default-no-consent / GDPR-style banner), so pressing it doesn't change anything and there's nothing to signal. Banner types whose default isn't already rejected (e.g. the default-consent / opt-out banner) 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 or flipping a preference toggle). 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 pageSessionConsentGrantedAnalytics once and pageSessionConsentRejectedAnalytics once.)
  • Accept All emits only pageSessionConsentGrantedAll (not the individual per-category grant events) — see the callout under Events above.
  • Advertising controls the opt-out. There is no separate Targeted Advertising toggle. For organizations that sell, share, or use personal data for targeted advertising, turning Advertising off also opts the consumer out, so you'll receive both pageSessionConsentRejectedAds and pageSessionConsentRejectedTargeted. Turning Advertising on fires pageSessionConsentGrantedTargeted too, unless the consumer has already opted out (for example, with a GPC signal or in the Privacy Center), since that opt-out stays in place.

Integration Examples​

<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.detail is optional.
  • These events complement, but do not replace, consentChanged. Use consentChanged when 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.