Skip to content

Add Google Analytics 4 and Microsoft Clarity - #223

Draft
yomach wants to merge 3 commits into
mainfrom
analytics/ga4-clarity
Draft

Add Google Analytics 4 and Microsoft Clarity#223
yomach wants to merge 3 commits into
mainfrom
analytics/ga4-clarity

Conversation

@yomach

@yomach yomach commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • This site had no web analytics. Adds GA4 (Material's native analytics.provider: google hook) and a consent-gated Microsoft Clarity snippet (docs/js/clarity.js).
  • Adds a cookie consent banner (previously absent) with analytics, github, and a new clarity category (defaults unchecked — proper opt-in).

Why draft

G-REPLACE_WITH_NEW_MEASUREMENT_ID and REPLACE_WITH_CLARITY_PROJECT_ID are placeholders. This is one of 4 sibling PRs (documentation-website, qualibrate, quam, quarc) sharing one dedicated GA4-owning Google account and one Clarity account, both still to be created. Will move to Ready for Review once real IDs are in.

Note: site_url in mkdocs.yml is still commented out (pre-existing) — left untouched pending a separate decision on whether to set it.

Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com

https://claude.ai/code/session_01WBfKWmY9rLhRT6LuSAcgmj

Review response

Same finding surfaced on the sibling documentation-website PR (#386), extrapolated here since this PR used the identical cookies: pattern. Pulled Material's actual partials/consent.html template source to verify rather than assume:

  • github cookie removed. It's gated in the template behind config.repo_url containing github.com — confirmed via source, and confirmed via grep that none of the 4 sibling sites set repo_url. Functionally dead checkbox; dropped.
  • analytics switched to the expanded {name, checked: false} form. The template defaults plain-string cookie entries to checked="checked" (pre-opted-in) — fixed for a real, consistent opt-in default matching clarity.
  • Consent-change reactivity: confirmed via Material's docs (setup/ensuring-data-privacy/#cookie-consent) — "The page reloads when users modify consent choices." docs/js/clarity.js's script-eval-time __md_get("__consent") check is sufficient as written.

@CLAassistant

CLAassistant commented Jul 29, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

yomach and others added 3 commits July 29, 2026 19:12
This site had no web analytics. Adds GA4 (Material's native provider
hook) and a consent-gated Microsoft Clarity snippet, plus a cookie
consent banner (previously absent) covering both.

Placeholder IDs (G-REPLACE_WITH_NEW_MEASUREMENT_ID, Clarity project ID)
must be replaced once the new shared GA4/Clarity accounts are created.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WBfKWmY9rLhRT6LuSAcgmj
Both were commented out. site_url now matches the actual GitHub Pages
URL (qua-platform.github.io/quam), which also benefits GA4/canonical
link generation added in this branch.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WBfKWmY9rLhRT6LuSAcgmj
Verified against Material's actual consent.html template
(squidfunk/mkdocs-material): a plain-string cookie entry (e.g.
`analytics: Google Analytics`) always defaults to checked=true, and
the "github" category is only meaningful when repo_url is set to a
github.com URL — which none of the 4 sibling sites configure. Drops
the github entry and switches analytics to the expanded form with an
explicit checked: false, matching clarity's opt-in default.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WBfKWmY9rLhRT6LuSAcgmj
@yomach
yomach force-pushed the analytics/ga4-clarity branch from 209ad9c to 487d016 Compare July 29, 2026 16:13
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