Skip to main content

Google Tag Manager (GTM) Integration Guide

Integrate Consent Shield AI with Google Tag Manager using official community templates, custom event triggers, and server-side tag filtering.


1. Web Container Installationโ€‹

Step 1: Install GTM Community Templateโ€‹

  1. In your GTM Workspace, navigate to Templates โ†’ Tag Templates โ†’ Search Gallery.
  2. Search for Consent Shield AI Consent Banner & Interceptor.
  3. Click Add to Workspace.
  1. Create a new Tag of type Consent Shield AI.
  2. Set the Trigger to Consent Initialization - All Pages.
  3. Enter your Site ID.
  4. Save and Publish your container.

2. GTM Custom Events & Triggersโ€‹

Consent Shield pushes real-time events to the dataLayer whenever consent changes:

// Dispatched on initial load and whenever preferences are updated
window.dataLayer.push({
event: 'consent_shield_update',
consent_categories: {
necessary: true,
functional: true,
analytics: false,
advertising: false
},
gpc_active: true
});

To fire tags (e.g., LinkedIn Insight Tag, Hotjar) only when consent is granted:

  • Create a Custom Event Trigger listening for consent_shield_update.
  • Add Trigger Exception: dataLayer.consent_categories.advertising !== true.

3. Server-Side GTM (sGTM) Forwardingโ€‹

When using Server-Side GTM:

  • Consent Shield attaches verified consent headers (x-consent-shield-state) to outgoing client HTTP requests.
  • Server clients inspect these headers before forwarding requests to Facebook CAPI, Google Analytics 4 Measurement Protocol, or Pinterest API.