PostHog is already integrated into your project for analytics. Simply set the required environment variables to start using it.
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-hostNEXT_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).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.
NEXT_PUBLIC_POSTHOG_KEY secure and avoid sharing it in public repositories.If you encounter issues with PostHog:
.env file and that the file is loaded by your application.NEXT_PUBLIC_POSTHOG_HOST points to a valid PostHog instance.For more information on PostHog, visit the official PostHog documentation.