From b2e86d1052f8743818472e2343ce8f33ad2833c9 Mon Sep 17 00:00:00 2001 From: Nurul Sundarani Date: Thu, 18 Jun 2026 21:57:52 +0530 Subject: [PATCH 1/3] fix(analytics): use Google Consent Mode v2 with a CookieYes consent bridge MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CookieYes's auto-blocker does not re-activate type="text/plain" gated scripts in this account (confirmed: Tolt was dead too; consent recorded analytics:yes but scripts stayed inert), so the gated GTM never executed and GA4 got no data. Switch to Consent Mode v2, which does not depend on script re-activation: - load GTM normally (no type="text/plain" gate); - default all consent types to "denied" inline before GTM, so no cookies/device storage pre-consent (only anonymous cookieless pings) — ePrivacy-compliant; - bridge CookieYes -> Google consent in code via CookieYes's JS API (cookieyes_consent_update event + getCkyConsent()), firing gtag('consent','update',...) on accept. No CookieYes dashboard access needed. Co-Authored-By: Claude Opus 4.8 --- .../ui/src/components/google-tag-manager.tsx | 93 +++++++++++-------- 1 file changed, 56 insertions(+), 37 deletions(-) diff --git a/packages/ui/src/components/google-tag-manager.tsx b/packages/ui/src/components/google-tag-manager.tsx index b98bad5ce8..362f7d9ada 100644 --- a/packages/ui/src/components/google-tag-manager.tsx +++ b/packages/ui/src/components/google-tag-manager.tsx @@ -1,26 +1,22 @@ /** - * Consent-gated Google Tag Manager loader. + * Google Tag Manager loader with Google Consent Mode v2. * - * Split into two parts on purpose: + * GTM loads normally — it is NOT gated as a `type="text/plain"` script (CookieYes + * does not re-activate blocked scripts in this account, so gating left GTM inert + * and GA4 got no data). Compliance is handled by Consent Mode instead: * - * 1. An inline bootstrap that always runs. It only initialises `dataLayer` - * (a plain in-memory array) and pushes the page section + GTM start event. - * This sets no cookies and makes no network requests, so it is safe to run - * before consent. - * 2. The GTM library itself, loaded as an EXTERNAL `src` script tagged for - * CookieYes' analytics category. CookieYes only reliably re-activates - * external `src` scripts after consent — an inline `type="text/plain"` GTM - * bootstrap is left inert and never executes, so it must NOT be used here. - * This mirrors the working external-`src` pattern used for Tolt/PromptWatch. - * See https://www.cookieyes.com/documentation/implement-prior-consent-using-cookieyes/ + * - All consent types default to "denied", inline and synchronously, BEFORE GTM + * runs. GA4 sets no cookies and only sends anonymous cookieless pings until the + * visitor consents — no device storage pre-consent (ePrivacy satisfied). + * - A small bridge maps CookieYes consent to Google's consent signal via + * CookieYes's JS API (`cookieyes_consent_update` event + `getCkyConsent()`), + * firing `gtag('consent','update',...)` on accept. This needs NO CookieYes + * dashboard configuration — it works purely from the consent events CookieYes + * already emits. See + * https://www.cookieyes.com/documentation/implementing-google-consent-mode-using-cookieyes/ * - * Nothing contacts Google until CookieYes activates the external script once the - * visitor grants analytics consent (GDPR/ePrivacy compliant). No `