DEV Community

Cover image for Google Consent Mode v2 on WordPress: Site Kit, GTM and CMP Integration
IntelligenceX
IntelligenceX

Posted on

Google Consent Mode v2 on WordPress: Site Kit, GTM and CMP Integration

WordPress websites frequently load Google Analytics, Google Ads and third-party tracking scripts through plugins, themes and Google Tag Manager.

When visitors reject analytics or advertising cookies, supported Google tags need to respond to their consent choices.

Google Consent Mode v2 provides the consent signals that control this behaviour.

The difficult part is not adding another plugin. It is ensuring that only one coordinated implementation manages the consent state.

1. Understand the consent signals

The four main signals are:

Signal Controls
analytics_storage Analytics cookie storage
ad_storage Advertising cookie storage
ad_user_data Sending user data to Google for advertising
ad_personalization Personalised advertising

Other supported signals include functionality, personalisation and security storage.

Reference: Google Consent Mode overview.

2. Audit the existing WordPress tag stack

Before implementation, identify where scripts are injected.

Check:

  • Site Kit.
  • Google Tag Manager.
  • Theme header and footer scripts.
  • GA4 plugins.
  • Google Ads integrations.
  • Existing CMP plugins.
  • WooCommerce tracking integrations.
  • Page-builder custom code.

A duplicate GTM container or multiple consent managers can produce inconsistent results.

3. Option A: Google Site Kit

Site Kit provides a Consent Mode setting under:

Site Kit → Settings → Admin Settings

When enabled, Site Kit adds the necessary consent tag with default preferences.

Site Kit also checks for WP Consent API.

Important distinction:

  • WP Consent API standardises communication between compatible plugins.
  • A CMP collects the actual visitor preference.
  • Site Kit manages its Consent Mode implementation.

Site Kit warns that enabling a second CMP-specific Consent Mode implementation can cause conflicts.

Official documentation: Site Kit Consent Mode.

4. Option B: Google Tag Manager

For GTM-based websites, use the Consent Initialization - All Pages trigger for consent-management tags.

The correct order matters:

  1. Establish consent defaults.
  2. Load the relevant Google tags.
  3. Collect visitor preferences.
  4. Update consent states.
  5. Restore saved preferences on later visits.

For custom GTM templates, use:

  • setDefaultConsentState
  • updateConsentState

Avoid relying on Custom HTML callbacks with ordinary gtag() commands to manage consent inside a custom template.

Reference: GTM consent mode support.

5. Option C: A WordPress CMP

A CMP can manage the banner, visitor preferences and Google consent updates.

Check for:

  • Consent Mode v2 support.
  • Default states before tag execution.
  • Consent updates after interaction.
  • Preference persistence.
  • Regional configuration.
  • Script blocking.
  • WP Consent API support.

ConsentX WordPress integration

ConsentX's published WordPress plugin information describes:

  • Google Consent Mode v2.
  • Denied-by-default signals before tags load.
  • Updates after visitor choices.
  • Pre-consent blocking for supported scripts, pixels and iframes.
  • WP Consent API support.
  • Local consent records.
  • Regional banner behaviour.

Installation:

  1. Go to Plugins → Add New.
  2. Search for ConsentX.
  3. Install and activate it.
  4. Review ConsentX settings.
  5. Configure banner and regional preferences.
  6. Test in a private browser session.
  7. Verify consent states using Tag Assistant.

Resources: WordPress plugin | ConsentX integration guide.

Do not independently activate Site Kit's Consent Mode and ConsentX's consent integration without checking compatibility. Choose one coordinated owner for Google consent signals.

6. Manual implementation example

For a direct gtag.js implementation:

gtag("consent", "default", {
  analytics_storage: "denied",
  ad_storage: "denied",
  ad_user_data: "denied",
  ad_personalization: "denied"
});
Enter fullscreen mode Exit fullscreen mode

After a visitor grants analytics consent:

gtag("consent", "update", {
  analytics_storage: "granted",
  ad_storage: "denied",
  ad_user_data: "denied",
  ad_personalization: "denied"
});
Enter fullscreen mode Exit fullscreen mode

These are examples, not universal legal defaults.

Your implementation must persist preferences, apply regional rules and update consent when users change their choices.

7. Debugging checklist

Use Google Tag Assistant.

Check:

  1. Is the default consent state present?
  2. Does it appear before tags use consent?
  3. Does Reject update the correct signals?
  4. Does Accept update only the selected categories?
  5. Are duplicate Google tags present?
  6. Does the consent state persist across pages?
  7. Are third-party scripts separately controlled?

Also test pages using WooCommerce, forms, embedded videos and other external integrations.

8. Common WordPress problems

Two banners appear: Review multiple CMP plugins and theme-level banners.

Consent Mode is missing: Check caching, script optimisation and the live page source.

Site Kit conflicts with CMP: Ensure only one integration manages Google consent signals.

Tags fire too early: Check the order of consent defaults and GTM triggers.

Third-party scripts still run: Google Consent Mode does not automatically block all non-Google scripts.

Final checklist

  • One coordinated consent implementation.
  • Correct defaults before Google tags.
  • Separate mapping for all four main signals.
  • Correct updates after user interaction.
  • Persisted visitor preferences.
  • No duplicate GTM containers.
  • Tag Assistant verification.
  • Testing across important WordPress templates.

Google Consent Mode v2 is not a complete privacy-compliance solution. It is a technical mechanism for communicating consent to supported Google tags.

The best WordPress implementation is the one where plugins, scripts and consent preferences work together without competing with each other.

Top comments (0)