Menu

PostHog Integration

PostHog is a feature-rich, open-source analytics tool. In addition to basic analytics, it also supports session replay, which can be very helpful for understanding user behavior.

Good to know

  • NEXTY.DEV disables tracking scripts in development to avoid polluting analytics data.
  • To verify locally, open app/[locale]/layout.tsx and components/tracking/PostHogProvider.tsx and remove the process.env.NODE_ENV === "development" check.
  • If you don't need local verification, just set the production environment variables and the scripts will be enabled automatically.

Configuration Steps

Step 1: Create a PostHog account

  1. Visit PostHog and register an account
  2. Create a new project

Step 2: Get API Key

  1. In the PostHog dashboard, click Settings
  2. Copy your Project API Key
  3. Note your Host URL
posthog

Step 3: Set environment variables

In your .env.local or environment variable configuration, add:

.env
NEXT_PUBLIC_POSTHOG_KEY=phc_your_project_api_key_here
NEXT_PUBLIC_POSTHOG_HOST=your_posthog_host_url