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โ
- In your GTM Workspace, navigate to Templates โ Tag Templates โ Search Gallery.
- Search for Consent Shield AI Consent Banner & Interceptor.
- Click Add to Workspace.
Step 2: Configure Consent Initialization Triggerโ
- Create a new Tag of type Consent Shield AI.
- Set the Trigger to Consent Initialization - All Pages.
- Enter your Site ID.
- 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.