Skip to content

Add cookieless analytics, kept out of the repository - #38

Merged
Cyanoxide merged 1 commit into
mainfrom
add-analytics
Jul 30, 2026
Merged

Add cookieless analytics, kept out of the repository#38
Cyanoxide merged 1 commit into
mainfrom
add-analytics

Conversation

@Cyanoxide

Copy link
Copy Markdown
Owner

Traffic and referrer stats, using Umami rather than Google Analytics: it
sets no cookies, so no consent banner is needed. Matches the setup on
jamiepates.com.

Nothing here reaches a fork

The website ID is read from frontend/.env.production.local, which is
gitignored, and the script is injected at runtime only when that ID is
present
. With no ID the guard makes the branch unreachable and the bundler
drops it, so a fork has no script tag, no request, and not even the tracker's
URL in the build — verified by grepping dist/.

.env.production.local rather than .env.local because Vite reads it for
vite build and never for vite dev, so working locally cannot put localhost
traffic in the stats.

.env.example is committed so the setup is discoverable, and so anyone
forking has an obvious place for their own ID.

Also

The .gitignore env block listed five specific files with no glob, leaving
.env.production and similar committable. Replaced with a glob and an
exception for the template.

Testing

npm run build clean, and dist/ contains no trace of the tracker without an
ID. The equivalent change on jamiepates.com was verified end to end in a
browser: tag injected, page view accepted by Umami, no duplicates.

Before this does anything

Create frontend/.env.production.local with a website ID from the Umami
dashboard — a separate one from the other sites, or the stats merge — then
rebuild and upload. Until then the site behaves exactly as it does today.

🤖 Generated with Claude Code

https://claude.ai/code/session_013yxFHbQB5DPVd9cRZNW3A9

Umami rather than Google Analytics: it sets no cookies, so the site needs no
consent banner, which GA4 would have required.

The website ID is read from .env.production.local, which is gitignored, and
the script is injected at runtime only when that ID is present. A fork
therefore gets nothing at all — with no ID the guard makes the whole branch
unreachable and the bundler drops it, so even the tracker's URL is absent
from the build.

Vite reads .env.production.local for `vite build` and never for `vite dev`,
so working locally cannot put localhost traffic in the stats.

The env block in .gitignore listed five specific files with no glob, which
left .env.production and the like committable. Replaced with a glob and an
exception for the template.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013yxFHbQB5DPVd9cRZNW3A9
@Cyanoxide
Cyanoxide merged commit 338c7c6 into main Jul 30, 2026
1 check passed
@Cyanoxide
Cyanoxide deleted the add-analytics branch July 30, 2026 16:45
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.

1 participant