PostHog Analytics

PostHog is already integrated into your project for analytics. Simply set the required environment variables to start using it.

Configuration

To enable PostHog analytics, set the following environment variables in your .env file:

# .env file
NEXT_PUBLIC_POSTHOG_KEY=your-posthog-key
NEXT_PUBLIC_POSTHOG_HOST=your-posthog-host
  • NEXT_PUBLIC_POSTHOG_KEY: Your PostHog API key, which you can find in your PostHog project settings.
  • NEXT_PUBLIC_POSTHOG_HOST: The URL of your PostHog instance (e.g., https://app.posthog.com for the cloud-hosted version or your self-hosted URL).

How It Works

Once the environment variables are configured, PostHog will automatically start capturing analytics data from your application. This includes user interactions, page views, and other events.

Best Practices

  • Keep your NEXT_PUBLIC_POSTHOG_KEY secure and avoid sharing it in public repositories.
  • Use descriptive names for custom events and properties to make analytics data easier to understand.
  • Regularly review your PostHog analytics dashboard to track key performance metrics.

Troubleshooting

If you encounter issues with PostHog:

  • Ensure that the environment variables are correctly set in your .env file and that the file is loaded by your application.
  • Verify that the NEXT_PUBLIC_POSTHOG_HOST points to a valid PostHog instance.
  • Check the browser console for errors related to PostHog integration.

For more information on PostHog, visit the official PostHog documentation.

MatureStack LogoBuilt with MatureStack