Skip to content

fix(consent): Cookie settings reopen + immediate GA4 withdrawal - #894

Merged
unjica merged 5 commits into
developfrom
fix/ga-consent-withdrawal
Oct 30, 2026
Merged

unjica merged 5 commits into
developfrom
fix/ga-consent-withdrawal

Conversation

@unjica

@unjica unjica commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

Base branch: fix/ga-spa-page-view (stacked on #893 because both touch GoogleAnalytics.tsx; GitHub retargets to develop once #893 merges).

Summary

P0 from the Phase 1 analytics audit: after Accept there was no way to withdraw consent (banner gone, /cookies had no control) and _ga cookies stayed; even a reject would only unmount the component while gtag.js kept running.

  • New Cookie settings button (cookie-settings-button.tsx) in the footer (Company column) and in /cookies → "Your choices". It dispatches tt-cookie-settings-open; CookieConsent reopens the existing banner (also when the choice is accepted; Cancel keeps the current choice).
  • On reject / withdrawal (lib/google-analytics-consent.ts, called from GoogleAnalytics.tsx): window['ga-disable-G-VL5GTNNCHH'] = true, gtag('consent','update',{analytics_storage:'denied'}), delete _ga / _ga_* on host + parent domains. No reload.
  • Re-accept on the same page clears ga-disable and grants storage again.
  • Accepted visitors are not affected on load (cookies are only cleared when the stored choice is not accepted).
  • /cookies copy: one added sentence: "You can change or withdraw your choice at any time. Withdrawing stops Google Analytics immediately and deletes its cookies."

How to test

  • pnpm lint ✅; dashboard vitest ✅ 75 files / 452 tests (new: google-analytics-consent.test.ts, cookie-consent.test.tsx, footer + GoogleAnalytics withdrawal cases); next build ✅.
  • Local consent audit (Phase 1 script against next start, GA /collect intercepted locally): Accept → Cookie settings → Reject: _ga cookies [], 0 hits on the next navigation. Reject → Accept without reload still sends 1 page_view.
  • Note: hits that gtag had already queued before the withdrawal (an Enhanced-measurement history page_view + scroll) can still be flushed at the moment of withdrawal; they were collected while consent was granted. Nothing is collected after.

Checklist

  • Tests pass (dashboard) · [x] Lint · [x] Build (dashboard) · [x] CHANGELOG [Unreleased] · [x] No breaking changes

Security / privacy

Strengthens GDPR consent withdrawal. No new cookies, no new data collected.

@unjica
unjica changed the base branch from fix/ga-spa-page-view to develop October 30, 2026 11:09
@unjica
unjica merged commit f8c6ccf into develop Oct 30, 2026
7 checks passed
unjica pushed a commit that referenced this pull request Oct 30, 2026
@unjica unjica mentioned this pull request Oct 30, 2026
1 of 6 tasks
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.

2 participants