Skip to content

Add Google Analytics (GA4) and a Privacy section on About - #30

Merged
ehcrea merged 1 commit into
mainfrom
claude/project-thread-0gjj7t
Nov 23, 2026
Merged

ehcrea merged 1 commit into
mainfrom
claude/project-thread-0gjj7t

Conversation

@ehcrea

@ehcrea ehcrea commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Requested by Eren · project thread

Same change in all 8 calculator repos.

What

  • GA4 measurement ID G-0SRRQJ1BBN (new property "ehcrea calculators", one web stream for https://ehcrea.github.io), loaded from a snippet at the end of the app script.
  • Loads only on ehcrea.github.io (not localhost or file), and not when the browser sends Do Not Track or Global Privacy Control, or when the visitor turned it off on About (localStorage["ehcrea.analytics"] = "off").
  • Sends origin + path only. ?query and #hash are left out because they can hold saved inputs and share links. Google signals and ad personalisation are off. Page views are sent on load and when the app moves to another calculator page. "Page changes based on browser history events" is turned off in the stream settings, so pages aren't counted twice.
  • About gets a "Privacy" section with an on/off button, in EN/DE/NL/TR/ES.
  • PWA: the gtag request is cross-origin and the service worker ignores it, so offline it just fails quietly. sw.js rebuilt.

Tested

  • Repo tests and build-sw.js --check pass.
  • Playwright, with the site served as ehcrea.github.io: the privacy note shows on About, gtag is requested, the dataLayer holds the clean URL, and there are no page errors.

Generated by Claude Code

- Loads GA4 (G-0SRRQJ1BBN, shared "ehcrea calculators" property) only on
  ehcrea.github.io; skipped with Do Not Track / Global Privacy Control or when
  the visitor turns it off on About (localStorage "ehcrea.analytics").
- Reports origin + path only (no ?query or #hash, which can hold inputs);
  Google signals and ad personalisation off. Page views sent on load and on
  history changes between calculator pages.
- About: "Privacy" section with an on/off switch, EN/DE/NL/TR/ES.
- Offline: the gtag request just fails; the service worker ignores it.
- sw.js rebuilt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DtSyM6ecWfzSkE6fxd3dp3
@ehcrea
ehcrea merged commit 62f35c0 into main Nov 23, 2026
2 checks passed
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