chore(site): install the Web Analytics beacon by hand - #203
Merged
Conversation
… lines Copy-pasting the beacon URL from the comment was broken by the mid-URL line wrap; keep each URL and CSP directive on a single line. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Enabling Web Analytics with "automatic setup" on the codeindex.app zone does nothing for this site: that injection is done by the zone HTML rewriter, which never sees responses served by Cloudflare Pages. Confirmed empirically — the beacon was still absent from the live HTML minutes after the zone-level toggle, with cf-cache-status: DYNAMIC on every response. Switch the site to "Enable with JS Snippet installation" and add the tag to both deployed HTML entry points. The token is public by design (it ships in the page source of every site using Web Analytics), so it lives in the repo rather than in a build secret. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Follow-up to #201. The CSP was widened for a beacon that never arrived.
What happened
The
codeindex.appzone was set up in Web Analytics with automaticsetup — Cloudflare says it will inject the beacon into HTML at the edge.
It does not, for this site: that injection runs in the zone HTML rewriter,
which never sees responses served by Cloudflare Pages. Verified against
production — no
cloudflareinsightsanywhere in the live HTML minutesafter the toggle,
cf-cache-status: DYNAMICon every response.What changed
The site is now on "Enable with JS Snippet installation", and the tag is
in both deployed HTML entry points (
site/index.html,site/docs/index.html—site/og/og.htmlis a local prop page forrendering the OG image and is not part of the build).
The token in the snippet is public by design: it appears in the page source
of every site using Web Analytics and grants nothing. It is not a secret,
so it stays in the repo instead of becoming a build-time injection.
Test plan
npm run build— green;dist/index.htmlanddist/docs/index.htmlbothcarry the beacon.
browser console, and the Web Analytics dashboard starts counting.
🤖 Generated with Claude Code