Google Tag Manager

CookieBoss pushes consent events to the GTM dataLayer so you can fire tags only when the visitor has given consent.

Quick setup: Import our GTM template

Skip the manual configuration below by importing our pre-built container template. It includes all the triggers, variables, and an example GA4 tag.

  1. Download GTM Template
  2. In GTM, go to Admin > Import Container
  3. Choose the downloaded file
  4. Select Merge and Rename conflicting tags, triggers, and variables
  5. Review the imported items and click Confirm
  6. Update the example GA4 tag with your Measurement ID (G-XXXXXXXXXX)
  7. Preview, test, and Publish

What's in the template?

The template includes 3 custom event triggers (cookieboss_consent_update, cookieboss_consent_accept_all, cookieboss_consent_reject_all), 3 data layer variables for consent categories, and an example GA4 configuration tag. You still need to add firing conditions to your own tags — see the manual steps below for guidance.

Prerequisites

  • GTM enabled in your CookieBoss banner settings
  • The CookieBoss script loaded before the GTM container script

How it works

When a visitor interacts with the consent banner, CookieBoss pushes three types of events to window.dataLayer:

EventWhen
cookieboss_consent_updateEvery consent change
cookieboss_consent_accept_allVisitor accepts all categories
cookieboss_consent_reject_allVisitor rejects all optional categories

Each event includes the full consent state:

dataLayer payload json
{
"event": "cookieboss_consent_update",
"cookieboss": {
  "siteId": "01KHJTD0CZG42333Z4P3F6X7Z4",
  "consent": {
    "necessary": true,
    "analytics": true,
    "marketing": false,
    "functional": true
  }
}
}

Step 1: Create Data Layer Variables

In GTM, go to Variables > New > Data Layer Variable and create these variables:

Variable nameData Layer Variable Name
CB - Analytics Consentcookieboss.consent.analytics
CB - Marketing Consentcookieboss.consent.marketing
CB - Functional Consentcookieboss.consent.functional

Step 2: Create a Custom Event Trigger

Go to Triggers > New > Custom Event:

  • Event name: cookieboss_consent_update
  • This trigger fires on: All Custom Events

Name it CB - Consent Update.

Step 3: Add Firing Conditions to Tags

For each tag that requires consent, add a firing condition:

Example: Google Analytics tag

  • Trigger: CB - Consent Update
  • Condition: CB - Analytics Consent equals true

Example: Meta Pixel tag

  • Trigger: CB - Consent Update
  • Condition: CB - Marketing Consent equals true

Step 4: Handle returning visitors

For visitors who already gave consent on a previous visit, CookieBoss fires cookieboss_consent_update automatically on page load with their stored preferences. Your GTM triggers will fire accordingly — no extra configuration needed.

Combine with Google Consent Mode

For Google tags specifically, use Google Consent Mode V2 instead of manual GTM triggers. It handles consent-aware data collection automatically, including conversion modeling for non-consenting visitors.