Skip to content

Built-in Cookie Consent Banner & Edge Geo-Targeting

Native cookie consent suite with Cloudflare edge geo-targeting, early Google Consent Mode v2, granular preferences modal, and visual theming.

Cookie Consent Suite & Edge Geo-Targeting Built-in

Section titled “Cookie Consent Suite & Edge Geo-Targeting ”

WP Zbridge includes a cookie consent banner built for Cloudflare Zaraz and Google Consent Mode v2, with no external libraries. Its script and styles are about 5 KB gzipped. Whether your setup meets the privacy laws that apply to you depends on your configuration; check with your own advisor.


European privacy rules (GDPR, UK GDPR, Swiss FADP and the ePrivacy Directive) generally require consent before setting tracking cookies. If your store only needs a banner for European visitors, EU-only targeting hides it elsewhere.

With EU-only targeting enabled, WP Zbridge decides in the visitor’s browser whether to show the banner:

  • Country lookup: The banner script reads the visitor’s country from Cloudflare’s /cdn-cgi/trace endpoint on your own domain. The result is kept for the browser session.
  • Works with page caching: The decision is never made on the server, so a cached page cannot carry one visitor’s result to another.
  • EU/EEA/UK/CH Detection: Covers 32 European jurisdictions:
    • 27 EU member states (AT, BE, BG, HR, CY, CZ, DK, EE, FI, FR, DE, GR, HU, IE, IT, LV, LT, LU, MT, NL, PL, PT, RO, SK, SI, ES, SE)
    • 3 EEA/EFTA nations (IS, LI, NO)
    • United Kingdom (GB) and Switzerland (CH)
  • Non-EU Auto-Grant: Visitors outside Europe are granted consent and do not see the banner.
  • Safe Fallback: If the country cannot be determined (lookup blocked, slower than 1.5 seconds, or the site is not proxied by Cloudflare), the banner is shown.

Section titled “2. Early Google Consent Mode v2 Initialization”

Google requires Consent Mode v2 for all traffic from the EEA to support Google Ads conversion tracking and Google Analytics 4 remarketing.

WP Zbridge injects the default consent state at <head> priority 1 (wp_head priority 1) before any tracking tags or scripts can run:

<!-- Injected synchronously in <head> at priority 1 -->
<script id="wp-zbridge-gcm-default">
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
// Inspects existing wp_zaraz_consent cookie immediately
// Defaults to denied with wait_for_update for first-time visitors
gtag('consent', 'default', {
'ad_storage': 'denied',
'ad_user_data': 'denied',
'ad_personalization': 'denied',
'analytics_storage': 'denied',
'functionality_storage': 'denied',
'security_storage': 'granted',
'wait_for_update': 500
});
</script>

When a returning visitor has an existing wp_zaraz_consent cookie, the early <head> script synchronously parses it and applies their saved consent choices immediately. This prevents “consent flashing” where tags are briefly denied and then re-granted.


Visitors can choose which categories of cookies and tracking they allow in a preferences dialog.

Strictly Necessary

Required for core site functions, user authentication, and WooCommerce cart sessions. Permanently enabled and locked.

Analytics

Controls traffic measurement, Google Analytics 4, and visitor interaction statistics.

Marketing

Controls conversion pixels and remarketing (Meta, Google Ads, TikTok, Snapchat, Pinterest, Bing, LinkedIn).

Functional

Passed to Google Consent Mode as functionality_storage and in the wp_zaraz_consent_updated event, so your own scripts can respect it. No Zaraz tool is assigned to it.

  • Uses proper ARIA attributes (role="dialog", aria-modal="true", aria-labelledby).
  • Moves keyboard focus to the dialog’s close button when it opens.
  • Pressing the Escape key closes the preferences modal without layout shift or page jumps.

4. Dual-Engine Synchronization & Custom Events

Section titled “4. Dual-Engine Synchronization & Custom Events”

When a visitor accepts, rejects, or customizes their settings, WP Zbridge synchronizes both tracking engines simultaneously:

  1. Google Consent Mode v2: Calls gtag('consent', 'update', { ... }) with updated parameters for ad_storage, ad_user_data, ad_personalization, analytics_storage, and functionality_storage.
  2. Cloudflare Zaraz: Calls window.wpZbridgeConsent.update(analytics, marketing), which sends google_consent_update to Zaraz and grants or denies the Zaraz consent purposes (wpzan for analytics, wpzmk for marketing). See Zaraz Native Consent Bridge.
  3. Developer Custom Event: Dispatches a standard browser custom event:
window.addEventListener('wp_zaraz_consent_updated', function(event) {
console.log('Consent updated:', event.detail);
// event.detail: { necessary: true, analytics: bool, marketing: bool, functional: bool, version: 1, timestamp: ... }
});

Customize the appearance to match your brand without editing PHP template files:

  • Theme Modes:
    • Auto: Automatically matches the visitor’s device preference (Dark or Light mode via prefers-color-scheme).
    • Light: Enforces clean light styling with high-contrast text.
    • Dark: Enforces dark slate background with crisp white typography.
  • Layout Styles: Choose between a floating card (bottom_floating), full-width bottom bar (bottom_bar), or centered modal dialog (modal).
  • CSS Custom Properties: Override CSS variables in your theme stylesheet:
:root {
--wpz-bg: #18181b; /* Banner background */
--wpz-text: #f4f4f5; /* Body text color */
--wpz-primary: #0284c7; /* Accent button color */
--wpz-radius: 8px; /* Border radius */
--wpz-font-family: inherit; /* Typography stack */
}

Cookie Banner Customizer & Live Preview


  • Privacy Policy Page: Select any published WordPress page from the dropdown menu, or specify a custom URL for external policy documents.
  • Custom Link Text: Customize the anchor text displayed in the banner description (e.g., “Privacy Policy” or “Cookie Policy”).
  • Cookie Lifetime: Configure how long visitor consent is preserved before re-prompting (choose from 30, 90, 180, or 365 days).
  • Floating Reopen Trigger: European privacy laws require that visitors can revoke or change consent at any time. WP Zbridge provides a persistent floating “Privacy” button with a cookie icon in the bottom-left or bottom-right corner.

Check which cookies, browser storage and third-party sites your homepage actually uses, so your banner categories and privacy policy match.

  1. Accept all cookies in your own cookie banner, so tools that wait for consent run.
  2. Go to Zbridge > Privacy & Consent and find Cookie & Tracker Scanner.
  3. Click Scan Site for Cookies & Trackers.

How it works:

  • In your browser: Your homepage loads in a hidden frame. After a few seconds WP Zbridge reads the names (never the values) of the cookies, localStorage and sessionStorage keys that are set, and the third-party sites the page contacted.
  • On the server: WP Zbridge fetches the homepage and adds the cookies it sets in its HTTP response, including HttpOnly cookies your browser’s scripts can’t read.
  • Grouping: Names are matched by prefix and sites by domain against a list of known providers (WordPress, WooCommerce, Cloudflare, Zaraz and its tools, Google, Meta, TikTok, Pinterest, Microsoft, LinkedIn, YouTube, Google Fonts, Gravatar and others). Anything else is listed as Not recognised, so you can check which plugin or theme adds it.

The report says how your own consent choice in that browser affects the results. Cookies left from earlier visits in your browser are included.