Skip to documentation content

Google Tag Manager data layer

Read CookieBeam consent state and use the data-layer events emitted by the core runtime.

The core runtime publishes window.CookieBeamGTM for scripts and GTM templates. For installation, see Install with Google Tag Manager.

The window.CookieBeamGTM bridge

MethodReturns or action
getConsent(){ categories, consentId, timestamp, isValid }
hasConsent(category)Whether one category is accepted
getConsentDetails()Booleans for necessary, preferences, analytics, and marketing; functionality and statistics remain aliases
updateConsent(categories)Accept one category, an array, 'all', or 'necessary'
isBannerVisible()Whether the consent or preferences view is visible
showBanner()Open the consent banner
showPreferences()Open preferences
getConfig()The running mode, auto-show value, revision, and GTM-enabled value

Check the bridge after the banner bundle has loaded:

window.CookieBeamGTM
window.CookieBeamGTM?.getConsent()
window.CookieBeamGTM?.getConsentDetails()

dataLayer events

When Google Consent Mode processes a valid consent change, the runtime pushes cookie_consent_update. It also pushes category events for accepted groups:

  • cookie_consent_marketing
  • cookie_consent_statistics
  • cookie_consent_preferences

The live core runtime does not currently subscribe the GTM bridge to modal lifecycle events. Do not create triggers for cookiebeam_modal_shown or cookiebeam_modal_hidden; those events are not emitted by the shipped core path.

Inspect the current entries with:

window.dataLayer?.filter((entry) => entry && typeof entry === 'object' && entry.event)

Test with a clean browser profile. Make a consent choice and confirm the expected consent event appears before relying on it as a GTM trigger.

If window.CookieBeamGTM is undefined, confirm that the banner bundle loaded successfully before checking GTM triggers. If the bridge exists but no consent event appears, confirm the visitor produced a valid consent change.