Skip to content

Add verified PostHog readership analytics - #34

Merged
jacobra19 merged 1 commit into
masterfrom
codex/posthog-readership-analytics
Sep 21, 2026
Merged

jacobra19 merged 1 commit into
masterfrom
codex/posthog-readership-analytics

Conversation

@jacobra19

Copy link
Copy Markdown
Owner

Implements the analytics integration for #32. The production site currently delivers Vercel Analytics events but blocks Google Analytics collection through its CSP; this adds direct browser-to-PostHog readership tracking while retaining both existing trackers until replacement production data is verified.

Changes

  • Capture one pageview on initial load and each pathname navigation, referral/UTM attribution, outbound clicks, 30 seconds of visible article time, and 50%/90% article scroll milestones.
  • Exclude development, preview, localhost, and opted-out author traffic. Disable replay and automatic interaction capture; strip query strings and hashes from captured URLs.
  • Allow the PostHog ingestion origin in the existing CSP, without Vercel Functions or rewrites. GA repair and HTTP-header hardening remain scoped to Fix CSP so Google Analytics requests are not blocked in production #20 and Move CSP and security hardening to HTTP response headers #21.
  • Add browser tests, a production CSP/network audit script, documented event definitions and author opt-out, and reproducible queries for the six-view readership dashboard.

The checked-in phc_ token is the public browser ingestion token, not a personal API key.

Validation

  • yarn validate:content and yarn build passed.
  • yarn test:e2e: 12 passed, 10 intentionally skipped (desktop-only checks and opt-in live ingestion).
  • Explicit live-ingestion test passed: six labeled QA events arrived in PostHog with the expected page paths, article title, scroll thresholds, engagement duration, outbound destination, and replay disabled. Dashboard queries exclude these QA events.
  • Production browser audit confirmed Vercel collection returned HTTP 200 and GA collection was blocked by the existing CSP.

Rollout

Ingestion was verified using the production build in an isolated browser; this change has not yet been deployed. After merge/deployment, follow docs/analytics.md to verify the deployed CSP and event delivery, then compare readership data before consolidating trackers. Keep #32 open until that production verification is complete.

@vercel

vercel Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
yakov-dev Ready Ready Preview Sep 21, 2026 9:01pm UTC

@jacobra19
jacobra19 merged commit c2cf377 into master Sep 21, 2026
4 checks passed

This branch was successfully deployed

1 active deployment
Preview — 44d2f177 Deployed Sep 21, 2026 by vercel[bot]
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