Skip to content

Send wait_for_update and ads_data_redaction with the Consent Mode default - #32

Open
amulero wants to merge 1 commit into
mainfrom
feature/consent-mode-defaults
Open

amulero wants to merge 1 commit into
mainfrom
feature/consent-mode-defaults

Conversation

@amulero

@amulero amulero commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Send the Google Consent Mode settings recommended by Google with the default consent state: wait_for_update and ads_data_redaction on by default, and url_passthrough available but off. First PR of block 2 (Consent Mode v2).

Findings

Issue Status
Google tags don't wait for the visitor's decision: a page view sent before it is measured as denied Fixed here (wait_for_update, 500 ms)
Ad click identifiers (gclid) reach Google Ads while ads storage is denied Fixed here (ads_data_redaction)
No way to keep the ad click identifier across pages without cookies Available, off by default (url_passthrough)
On the test site, a Cookiebot tag still running inside the site's GTM container overrides some Consent Mode signals (e.g. sets url_passthrough back to false) Site configuration, not the plugin
functionality_storage, personalization_storage and security_storage signals Later, together with a "Preferences" category

Changes

Consent Mode default

  • CookieNotice::get_consent_mode_settings() returns the three settings, each with a filter: frcn_cookie_notice_consent_mode_wait_for_update (default 500, 0 disables it), frcn_cookie_notice_consent_mode_ads_data_redaction (default true) and frcn_cookie_notice_consent_mode_url_passthrough (default false). No admin settings.
  • The wp_head default script adds wait_for_update to the state and calls gtag('set', 'ads_data_redaction', true) / gtag('set', 'url_passthrough', true) when enabled.
  • wait_for_update is added last, after an add-on's state (frcnCookieNoticeConsentModeState, e.g. FrontConsent PRO's per-category state) and the stale-consent check, so it is kept in every case.

CSP fallback

The same settings are localized as frcnCookieNotice.consentMode and applied by setConsentModeDefault(), used when a Content Security Policy blocks the inline script. A page cached before this change (without consentMode) sends the default exactly as before.

Assets and documentation

  • Regenerated the minified JavaScript using npm run build.
  • Documented the settings and filters in readme.md.

Tests

  • New CookieNoticeConsentModeSettingsTest (4 PHP tests) and tests/js/consent-mode-defaults.test.js (5 JS tests): defaults, filters, negative wait ignored, localized settings, add-on state keeping wait_for_update, and the old behavior without the localized settings. The 4 PHP tests and 3 of the JS tests fail without the change.
  • CI checks run locally: composer validate, composer lint, composer phpstan, PHPUnit (145/145) and npm run test:js (54/54). FrontConsent PRO's tests also pass against this branch (116/116, JS 7/7).
  • Manual test on a local WooCommerce site with WP Rocket and GTM4WP:
    • New visitor, Analytics-only visitor (with PRO) and accepted visitor (free only): the default state carries wait_for_update: 500 and ads_data_redaction and reaches the dataLayer before gtm.js; Google reports the default as set in time (wasSetLate: false) and GA4 hits carry gcs=G100 while denied.
    • WP Rocket cached page: the default script includes the settings, is not delayed and prints before the GTM loader.
    • Content Security Policy blocking the inline default script: the JS fallback sends the same default with the settings.
  • Isolated test page (Google tag loaded directly with a test Google Ads ID, without the site's GTM container), each setting on vs off:
    • url_passthrough on: clicking an internal link adds gclid to it; off: the link is unchanged.
    • ads_data_redaction on: the Google Ads request carries gclid=0; off: the real gclid is sent.
    • wait_for_update with the visitor accepting after 300 ms: the page view waits and is sent as granted (gcs=G111); without it, it is sent before the decision as denied (gcs=G100).

Scope

No version bump or changelog changes.

🤖 Generated with Claude Code

…ault

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant