Google Tag Manager Integration
Time: ~15 minutes Requires: GTM container with publish access
There are two ways to use ConsentForge with GTM:
- Script tag in GTM — Add the ConsentForge script via a Custom HTML tag (simplest)
- GTM Template — Use the ConsentForge GTM template for full Consent Mode v2 support (recommended)
Option 1: Script Tag via Custom HTML Tag
Step 1: Create a new tag
In GTM, go to Tags → New → Custom HTML.
Step 2: Add the script
<script
src="https://cdn.consentforge.com/consentforge.min.js"
data-token="YOUR_EMBED_TOKEN"
defer
></script>
Step 3: Set trigger to "Consent Initialization - All Pages"
This fires the tag on page load, before other tags run.
Step 4: Publish
Submit and publish your container.
Option 2: GTM Template (with Consent Mode v2)
Step 1: Add the ConsentForge template
- In GTM, go to Templates → Search Gallery
- Search for "ConsentForge"
- Click Add to workspace
Step 2: Create a Consent Initialization tag
- Go to Tags → New
- Choose the ConsentForge template
- Enter your Embed Token
- Set trigger: Consent Initialization - All Pages
Step 3: Update existing tags to use consent triggers
For each tag that needs consent (GA4, Ads, Meta):
- Open the tag
- Go to Advanced Settings → Consent Settings
- Set required consent types (e.g.
analytics_storagefor GA4)
Step 4: Test in GTM Preview
Open GTM Preview mode, visit your site. Confirm:
- ConsentForge tag fires first
- GA4 and other tags only fire after consent is given
gtm.consent_updateevent appears in the dataLayer after user accepts
Step 5: Publish
Submit and publish your container.
Verifying Consent Mode
After setup, open DevTools Console and type:
google_tag_manager['GTM-XXXXX'].getConsentState()
You should see consent mode values update after the user accepts/rejects.