Skip to content

Add optional Google Analytics 4 - #2

Merged
andyhsu10 merged 1 commit into
masterfrom
feat/google-analytics
Jun 10, 2026
Merged

Add optional Google Analytics 4#2
andyhsu10 merged 1 commit into
masterfrom
feat/google-analytics

Conversation

@andyhsu10

Copy link
Copy Markdown
Owner

Adds GA4 via Next's official @next/third-parties, gated behind an env var.

  • GA loads only when NEXT_PUBLIC_GA_ID is set — local dev and PR previews stay untracked.
  • Production deploy reads it from a GitHub Actions repo variable (vars.NEXT_PUBLIC_GA_ID), so the ID isn't hardcoded.
  • .env.example documents the variable.

Verified: build without the var injects no GA; build with NEXT_PUBLIC_GA_ID=G-… injects gtag. format/lint/test/build all pass.

To turn it on after merge

  1. Create a GA4 property → copy the Measurement ID (G-XXXXXXXXXX).
  2. Repo → Settings → Secrets and variables → Actions → Variables → New variable NEXT_PUBLIC_GA_ID = your ID.
  3. Re-run the deploy workflow (push to master or "Run workflow").

🤖 Generated with Claude Code

GA loads only when NEXT_PUBLIC_GA_ID is set, so local dev and PR previews
stay untracked. Production reads it from a GitHub Actions repo variable.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@andyhsu10
andyhsu10 merged commit 17c4b1e into master Jun 10, 2026
3 checks passed
@andyhsu10
andyhsu10 deleted the feat/google-analytics branch June 10, 2026 09:38
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