From 7ff8bfcaece50e1b2846ca1fe5d7ab7a078a1a00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomek=20Wytr=C4=99bowicz?= Date: Fri, 1 Mar 2024 20:16:57 +0100 Subject: [PATCH 1/3] Add gtag consent mode v0 support --- README.md | 1 + docs/gtag-consent-mode.md | 7 +++++++ src/Google/GlobalSiteTag.php | 23 +++++++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 docs/gtag-consent-mode.md diff --git a/README.md b/README.md index 432bc1f8c6..caedd54643 100644 --- a/README.md +++ b/README.md @@ -184,6 +184,7 @@ npm run -- wp-env run tests-cli -- wp wc update - [Usage Tracking](./src/Tracking/README.md) - [Hooks defined or used in GLA](./src/Hooks/README.md) +- [gtag consent mode](./docs/gtag-consent-mode.md)



diff --git a/docs/gtag-consent-mode.md b/docs/gtag-consent-mode.md new file mode 100644 index 0000000000..eaddbfb941 --- /dev/null +++ b/docs/gtag-consent-mode.md @@ -0,0 +1,7 @@ +## Googla Analytics (gtag) Consent Mode + +Unless you're running the [Google Analytics Integration](https://woo.com/products/woocommerce-google-analytics/) extension for a more sophisticated configuration, Google Listings and Ads will add Google's `gtag` to help you track some customer behavior. + +To respect your customers' privacy, we set up the default state of [consent mode](https://support.google.com/analytics/answer/9976101). We set it to deny all the parameters for visitors from the EEA region. You can add an extension or CMP that delivers a banner or any other UI to let visitors update their consent in runtime. + +You can also customize your own default state configuration using the `woocommerce_gla_gtag_consent` filter providing any snippet that uses [Google's `gtag('consent', 'default', {…})` API ](https://developers.google.com/tag-platform/security/guides/consent?consentmode=advanced). diff --git a/src/Google/GlobalSiteTag.php b/src/Google/GlobalSiteTag.php index 20d7fc192c..522989b2e5 100644 --- a/src/Google/GlobalSiteTag.php +++ b/src/Google/GlobalSiteTag.php @@ -254,6 +254,10 @@ protected function display_global_site_tag( string $ads_conversion_id ) {