Skip to main content

Google Tag Manager Integration

Time: ~15 minutes Requires: GTM container with publish access

There are two ways to use ConsentForge with GTM:

  1. Script tag in GTM — Add the ConsentForge script via a Custom HTML tag (simplest)
  2. 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>

This fires the tag on page load, before other tags run.

Step 4: Publish

Submit and publish your container.


Step 1: Add the ConsentForge template

  1. In GTM, go to Templates → Search Gallery
  2. Search for "ConsentForge"
  3. Click Add to workspace
  1. Go to Tags → New
  2. Choose the ConsentForge template
  3. Enter your Embed Token
  4. Set trigger: Consent Initialization - All Pages

For each tag that needs consent (GA4, Ads, Meta):

  1. Open the tag
  2. Go to Advanced Settings → Consent Settings
  3. Set required consent types (e.g. analytics_storage for 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_update event appears in the dataLayer after user accepts

Step 5: Publish

Submit and publish your container.


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.