TurboJet
Analytics

PostHog

Enable PostHog analytics with project token and host configuration.

To use PostHog with TurboJet, create a PostHog account and copy your project API key (project token).

Environment

Add the keys to the root .env (and your deployment environment). See Environment.

.env
NEXT_PUBLIC_ENABLE_POSTHOG=true
NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN=your_key_here
NEXT_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com
KeyNotes
NEXT_PUBLIC_ENABLE_POSTHOGFeature flag; set to false to disable. Defaults on unless "false".
NEXT_PUBLIC_POSTHOG_PROJECT_TOKENRequired for init; empty token disables PostHog
NEXT_PUBLIC_POSTHOG_HOSTDefaults to https://us.i.posthog.com

EU projects: set the host to https://eu.i.posthog.com.

Activation needs both the feature flag enabled and a non-empty token (packages/shared/src/features.ts → posthog, plus the check in @repo/analytics).

Package

posthog-js is already a dependency of @repo/analytics. You do not need to install it in each app.

Marketing and docs call initPostHogClient() from instrumentation-client.ts. Customize init options in:

packages/analytics/src/client.ts
posthog.init(token, {
	api_host: getHost(),
	defaults: "2026-01-30",
	capture_pageview: true,
	capture_pageleave: true,
	person_profiles: "identified_only",
});

Custom events

After setup, track events with captureEvent — see Analytics.

Further reading

On this page