Conversation
Owner decision 2026-09-17: GA4 on every public site, with privacy copy changed to match. src/perimeter/analytics.py holds the measurement ID and the loader; render.page puts the loader and a footer opt-out on every page, and the build now also writes privacy.html. An empty ID removes all of it; the JSON artifacts never carry any. The loader does nothing unless served from chelseakr.github.io under /perimeter/ (so the file:// pages both accessibility gates read never reach Google), under Global Privacy Control or Do Not Track, or after the footer opt-out (localStorage perimeter:analytics-opt-out). Google signals and ad personalisation are off; Consent Mode v2 denies the ad signals everywhere and analytics storage in the EEA, UK and CH. The README's "these pages ship no script and this project takes no telemetry" and "no script shipped" now describe the loader. tests/test_analytics.py executes it in Node and deletes each guard as a negative control, asserting the deletion landed.
CodeQL's py/bad-tag-filter read the <script> regex in the test helper as an HTML filter that misses upper-case tags. The page is this build's own output, so plain slicing is exact and gives the scanner nothing to flag.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Adds Google Analytics 4 to https://chelseakr.github.io/perimeter/, following the owner decision of 2026-09-17: GA4 on every public site, with privacy pages and claims updated to match. The property is
G-8PD9WL8LN0. It already has 14-month retention, and Google signals is off in the property.Where the ID lives
src/perimeter/analytics.py,GA4_MEASUREMENT_ID = "G-8PD9WL8LN0".render.page()puts the loader in every page's<head>and the footer note and opt-out on every page.cli.build_sitenow also writesprivacy.html. Setting the constant to""removes the loader, the control and every reference to Google. The footer and the privacy page then say the site runs no analytics. A malformed ID fails the build. The committedsite/was rebuilt fromdata/raw/withmake site, andmake site-checkconfirms it is byte-identical to a fresh build. All five JSON artifacts are unchanged, and none of them carry any analytics.How it loads
There is one inline script per page:
location.hostname === "chelseakr.github.io"and the path starts with/perimeter/. Thefile://pages that both accessibility gates read, local builds and CI therefore never load GA.dataLayeror requesting gtag.js under GPC, under DNT"1"/"yes"(checkingnavigator,windowandmsDoNotTrack), or after an opt-out.analytics_storageis denied throughregionfor the EEA, GB and CH (32 codes), where Google gets cookieless pings, and granted elsewhere.configsetsallow_google_signals: falseandallow_ad_personalization_signals: false. gtag.js is appended async.perimeter:analytics-opt-out, a key that names the project because everychelseakr.github.iosite shares one origin. It also setsga-disable-<ID>for the current page.The footer says "Google Analytics" without the "4" on purpose.
tests/test_pages_html.pyholds every number in page prose to a count, and a product-name digit in every footer would have needed a blanket exemption for "4".CSP
No page sets a CSP, and GitHub Pages sends no headers, so no CSP change was needed.
Claims changed
privacy.html, built by the samepage()shell (disclaimer, nav, canonical, og tags) and linked from every footer. It covers what GA4 records, the_ga/_ga_…cookies, the EEA/UK/CH cookieless pings, that the ad features are off, Google LLC in the US, 14-month retention, the three ways to opt out, and GitHub as the host.tools/a11y.mjsandtools/a11y_browser/playwright.config.ts: comments that said the pages "ship no script" are updated. No behaviour changed.Tests
tests/test_analytics.py, 38 tests. It lifts the inline script out of the committed pages and runs it in Node against a stubbedwindow/navigator/document/localStorage:gtag/js?id=G-8PD9WL8LN0, with consent defaults (full region list),jsandconfigin order.file:, another host, a sibling project's path, the origin root, a/perimeter-fork/lookalike, GPC, all four DNT forms, and the opt-out flag.false, DNT"0"and blocked storage.ga-disable-…, and reports GPC/DNT or blocked storage.CI.make verifypasses: lock check, ruff lint+format, mypy strict, 1223 tests at 98.83% coverage, pip-audit, html-validate, axe in jsdom (4 pages, 0 violations), npm audit, and the Chromium axe + reflow gate (10 passed), which runs the loader for real onfile://and checks the revealed opt-out button. The determinism gate also passes.make site-checkpasses againstdata/raw/.A second commit replaces the test helper's
<script>regex with plain string slicing. The first push's CodeQL run flagged it aspy/bad-tag-filter(a tag regex reads as an HTML filter that misses<SCRIPT>).make verifypassed again after that change.Owner step in the property
In the web stream's Enhanced measurement settings, please check which options are on. The privacy page says GA records page views and, by default, scrolling and outbound clicks.
Note: GA's
_gacookie uses path/on the sharedchelseakr.github.ioorigin, so it has the same value on each sibling site's property. That matches the other sites (cookie_pathisn't set). The privacy page says the cookies are set on chelseakr.github.io.Prepared with AI assistance; reviewed before submission.