WPConsent Documentation

Documentation, Reference Materials, and Tutorials for WPConsent

Google Tag Manager Template

The GTM template mentioned in this article is currently pending approval in the GTM Community Template Gallery. We’ll update this article once it’s available.

Overview

This guide walks you through connecting WPConsent to Google Tag Manager (GTM) for full Google Consent Mode v2 compliance. When properly configured, WPConsent will communicate user consent preferences to GTM, ensuring your analytics and advertising tags respect user choices.

Prerequisites

  • WPConsent plugin installed and activated
  • A Google Tag Manager account with a container for your website

Before configuring GTM, scan your site to identify all cookies and scripts:

  1. Go to WPConsent → Scanner in your WordPress admin
  2. Click Run Scanner to analyze your website
  3. Review the detected cookies and categorize them appropriately (Essential, Statistics, Marketing)

  1. Go to WPConsent → Settings
  2. Find the Google Consent Mode option and enable it (it is enabled by default)
  3. Save your settings
  • Set default consent states on page load
  • Update consent signals when users make choices
  • Push consent preferences to the GTM dataLayer

Step 3: Add the WPConsent Template in GTM

  1. Log in to https://tagmanager.google.com
  2. Select your container
  3. Go to Templates → Tag Templates → Search Gallery
  4. Search for “WPConsent”
  5. Click to add the template to your workspace

Step 4: Create the WPConsent Tag

  1. Go to Tags → New
  2. Click Tag Configuration and select WPConsent – WordPress Privacy Compliance Made Easy
  3. Configure your default consent states:
    • Ad Storage: Denied (recommended default)
    • Analytics Storage: Denied (recommended default)
    • Ad User Data: Denied (recommended default)
    • Ad Personalization: Denied (recommended default)
  4. (Optional) Add region-specific settings if needed (e.g., grant by default in non-EU regions)
  5. Under Advanced Settings, configure:
    • Redact Ads Data: Enable if you want to strip ad identifiers when consent is denied
    • URL Passthrough: Enable to preserve campaign attribution via URL parameters
    • Wait for Update: Leave at 500ms (default)

Step 5: Set the Trigger

  1. Click Triggering
  2. Select Consent Initialization – All Pages
  3. (This is critical — the consent tag must fire before any other tags)
  4. Save the tag

Step 6: Configure Your Other Tags

For tags that require consent (Google Analytics, Google Ads, etc.):

  1. Open the tag configuration
  2. Under Advanced Settings → Consent Settings, select Require additional consent for tag to fire
  3. Add the appropriate consent types:
    • For analytics tags: analytics_storage
    • For advertising tags: ad_storage, ad_user_data, ad_personalization

Step 7: Preview and Publish

  1. Click Preview to test your configuration
  2. Visit your website and verify:
    • The consent banner appears
    • Accepting consent fires the appropriate tags
    • Declining consent blocks the tags
  3. Once verified, click Submit to publish your changes

How It Works

When a visitor interacts with your consent banner:

  1. WPConsent saves preferences to a cookie (wpconsent_preferences)
  2. The preferences are pushed to the GTM dataLayer
  3. The WPConsent GTM template reads these preferences and updates Google Consent Mode
  4. Your tags fire (or don’t) based on the consent state The template also listens for consent changes, so if a user updates their preferences later, tags will respond accordingly.
Was this article helpful?