Repository navigation
Add Google Analytics (GA4) for production hosts (#145) - #142
Conversation
Loads gtag (G-VZF5DR37YH) only for data.physioshark.org / physioshark.org, updates CSP, and records SPA navigations. Co-authored-by: Cursor <cursoragent@cursor.com>
The site's CSP only allows SvelteKit's nonce'd inline scripts, so the inline gtag snippet in <svelte:head> was blocked on data.physioshark.org: window.gtag never existed and no hits were sent. The command queue is now created in the component (first afterNavigate), before the allowed gtag.js script drains it. Checked on a production build served as data.physioshark.org: the only scripts are SvelteKit's nonce'd ones and gtag.js; on localhost GA isn't loaded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
One fix pushed in 03190d1: as written, GA would have sent nothing. The site's CSP ( The command queue ( Checked on a production build:
I didn't load it in a browser on the production host, so as not to send a test hit to the live property. The "GA Realtime shows hits" step in the test plan is still the real check after deploy. The rest looks good: hosts are limited to production, there are SPA page views, and the CSP and docs are updated. |
Summary
G-VZF5DR37YH(shared Physioshark stream) viaGoogleAnalytics.svelteonly when the request host isdata.physioshark.orgorphysioshark.orgpage_viewevents on navigation; update CSP for gtag / Analytics hostsTest plan
pnpm lintandpnpm checkpassCloses #145