Analytics tell you what people actually do in your app. In this repo, analytics are provider-agnostic — the app sends the same events to one or multiple providers without changing any feature code.
What You Get Out of the Box
The analytics system is already wired up with:- An analytics provider loaded at the app root
- Shared event helpers:
trackAnalyticsEvent(),trackAnalyticsPageview(),identifyAnalyticsUser() - Support for one provider, multiple providers, or none at all
- A clean disabled mode with
none
Pick Your Provider
- PostHog
- Plausible
- DataFast
Best for: Full product analytics, event tracking, and advanced features like session replay and feature flags.PostHog is the most full-featured option. If you only want one analytics tool and you want it to grow with you, pick this.
Using Multiple Providers
Want more than one? Just comma-separate them:Setup
Add env vars
Add the provider-specific env vars to
.env.local (see the tabs above for exact values).Key Files
lib/analytics/head-scripts.tsx— script injectionlib/analytics/provider.tsx— the root analytics providerlib/analytics/client.ts— shared event helperslib/analytics/providers/*— provider-specific implementations
Verify It Works
Your analytics setup is working if:
- The provider script loads in the browser
- Pageviews appear in the dashboard
- Custom events appear after you trigger tracked actions
Typo in provider name
Typo in provider name
Make sure
NEXT_PUBLIC_ANALYTICS_PROVIDER is exactly posthog, plausible, datafast, or none. Any typo silently disables analytics.Forgot to restart
Forgot to restart
Next.js doesn’t pick up new env vars until you restart the dev server.
Wrong Plausible domain
Wrong Plausible domain
Your
NEXT_PUBLIC_PLAUSIBLE_DOMAIN must match the site you created in Plausible exactly.Missing DataFast website ID
Missing DataFast website ID
Without
NEXT_PUBLIC_DATAFAST_WEBSITE_ID, DataFast won’t know which site to track.Meta Ads
Need checkout attribution for Meta campaigns? That’s a separate system — read the Meta Ads guide.

