Analytics Config
Google Analytics, PostHog, and built-in enhanced analytics.
File: config/analytics.config.ts
The config is almost entirely driven by env vars — add a key, the corresponding tracker turns on. Remove the key, it goes silent.
Providers
Google Analytics 4
- Go to analytics.google.com → Admin → create a Property
- Add a Data Stream for your site → copy the Measurement ID (
G-XXXXXXXXXX) - Add to
.env.local:
NEXT_PUBLIC_GA_MEASUREMENT_ID=G-XXXXXXXXXXRestart the dev server. The GA script auto-loads in <head>.

PostHog
- Sign up at posthog.com → create a project
- Project Settings → Project API Key (starts with
phc_) - Add to
.env.local:
NEXT_PUBLIC_POSTHOG_KEY=phc_...
NEXT_PUBLIC_POSTHOG_HOST=https://app.posthog.com
# (or https://eu.posthog.com for EU region)
Google Search Console verification
For SEO validation:
NEXT_PUBLIC_GOOGLE_VERIFICATION=your-verification-tokenThe site adds the meta tag automatically.
Built-in "enhanced" analytics
When the analytics feature flag is true (default), the app also writes analytics events to your own Supabase database — no third party involved. Tracked:
- Device type, browser, OS
- Country (from IP, no personal data)
- Page views
- Per-project views
- Custom events
Results show up in /admin/analytics:

This is independent of GA / PostHog — use it when you want fast, local, non-cookie analytics.
Turn it off by setting analytics: false in features.config.ts.
Mixing them
All three (GA, PostHog, enhanced) can run at the same time. Each one is useful for different things:
| Tool | Best for |
|---|---|
| GA4 | SEO reporting, traffic sources |
| PostHog | Funnels, session replay, feature flags |
| Built-in | Fast admin dashboards, historical DB-backed data |
See also
- Analytics — what events the built-in system tracks