Documentation
supastarter for Nuxtsupastarter for NuxtAnalytics

PostHog

Learn how to use PostHog with supastarter.

To use PostHog with supastarter, first create a PostHog account and get your project key.

Then, add the API key to your .env.local file and your deployment environment:

NUXT_PUBLIC_POSTHOG_KEY=your_key_here

Next, we need to install the PostHog package:

pnpm add --filter marketing posthog-js

Finally, we need to activate PostHog as the analytics provider. To do this, open apps/marketing/modules/analytics/index.ts and change the content to:

export * from "./provider/posthog";

To customize the PostHog configuration, edit the apps/marketing/modules/analytics/provider/posthog/index.ts.

Note for EU users: You need to adjust the host url:

posthog.init(posthogKey, {
    api_host: "https://eu.i.posthog.com",
    // ...
});

Learn more about analytics with PostHog in the official documentation.

For further instructions, follow the general analytics instructions.

On this page

No Headings