=== ZDAnalytics Connector (GA4 + GTM) === Contributors: zdapps Tags: google analytics, ga4, google tag manager, gtm, cookie consent Requires at least: 5.5 Tested up to: 6.9 Requires PHP: 7.4 Stable tag: 1.8.10 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html Consent-friendly GA4 + GTM connector for WordPress (opt-in, cache-safe, no theme edits). == Description == ZDAnalytics Connector helps you connect **Google Analytics 4 (GA4)** and/or **Google Tag Manager (GTM)** to your WordPress site without editing theme files. **Key features** * Simple settings page (Settings → ZDAnalytics Connector) * Supports GA4 Measurement ID (G-XXXXXXXXXX) and GTM Container ID (GTM-XXXXXXX) * Consent-friendly: when enabled, the plugin waits for consent before loading Google scripts * Cache-friendly: consent checking happens in the browser, so it works with full-page caches (LiteSpeed, server cache, CDN, etc.) * Optional: do not load tracking for logged-in users == External services == This plugin connects to external services provided by Google: 1) **Google Analytics 4** * What it is used for: Website analytics/measurement. * What data is sent: When loaded, Google scripts may collect usage data (e.g., page views, events, device/browser information) as configured in your Google Analytics property. * When it is sent: When tracking is enabled and (if configured) the user has consented. * Terms: https://policies.google.com/terms * Privacy: https://policies.google.com/privacy 2) **Google Tag Manager** * What it is used for: Tag management (loading additional tags you configure in GTM). * What data is sent: Data collection depends on the tags you configure inside your GTM container. * When it is sent: When tracking is enabled and (if configured) the user has consented. * Terms: https://policies.google.com/terms * Privacy: https://policies.google.com/privacy == Installation == 1. Upload the plugin zip and activate it. 2. Go to **Settings → ZDAnalytics Connector**. 3. Enter your GA4 Measurement ID and/or GTM Container ID. 4. (Optional) Enable consent requirement and set the consent cookie name used by your cookie banner plugin. == Frequently Asked Questions == = Does this plugin track users by default? = No. You can disable tracking entirely using **Enable tracking (opt-in)**. If **Require consent before tracking** is enabled, the plugin will not load Google scripts until consent is detected. = How does consent detection work? = If **Require consent before tracking** is enabled, the plugin checks the configured **Consent cookie name** (default: `cookie_notice_accepted`) for a value such as `true`, `1`, `yes`, or `accepted`. If the cookie name is empty, developers can use the `zdac_user_has_consented` filter to integrate with custom consent logic. = Does this plugin provide a cookie banner? = No. Use any cookie/consent plugin you prefer and configure the cookie name in this plugin. = I use page caching (LiteSpeed/hosting cache/CDN). Will this work? = Yes. This plugin uses a small local loader script that checks consent in the browser and only then loads Google scripts, so it is compatible with full-page caching. = Should I use both GA4 and GTM at the same time? = You can, but avoid double-counting: if you load GA4 via GTM, you usually do not need to also set the GA4 Measurement ID in this plugin. == Upgrade Notice == = 1.8.9 = * Added Basic/Advanced tabs in settings (simpler setup with optional advanced parameters). * Improved automatic consent key detection and clearer admin feedback. * Bundled required JS assets inside the plugin ZIP (admin + consent loader). = 1.8.8 = * Added consent storage source (Cookie / Local Storage). * Added consent value list with safer matching for common consent plugins. * Added admin helper to auto-detect cookies/localStorage keys from the current browser. = 1.8.7.1 = Hotfix: Fixes a PHP parse error and ensures the cache-friendly consent loader runs correctly. = 1.8.7 = Switches tracking loading to a cache-friendly consent loader. If you require consent, verify your consent cookie name (default: cookie_notice_accepted). == Changelog == = 1.8.10 = * Improve admin field labels and inline help text. * Improve plugin metadata for better discoverability. = 1.8.9 = * Added Basic/Advanced settings tabs and improved automatic consent detection. * Bundled JS assets (admin + consent loader) in the plugin package. = 1.8.8 = * Added consent storage source (Cookie / Local Storage) and consent accepted values list. * Added admin helper to detect cookies/localStorage keys from the current browser. = 1.8.7.1 = * Hotfix: fixed a PHP syntax error that could cause a fatal error on activation. = 1.8.7 = * Added cache-friendly, consent-aware loader that injects GA4/GTM only after consent is detected (works with full-page caches like LiteSpeed). * Added settings: Enable tracking (opt-in) and Consent cookie name (`cookie_notice_accepted` by default). * Improved consent detection (cookie-based with filter fallback) and prevented noscript GTM output when consent is required. = 1.8.5 = * Improved sanitization (register_setting with sanitize_callback) and consent-first tracking behavior. * Enqueued scripts properly (no direct echo of script tags).