Track how users interact with your documentation using PostHog. Doccupine supports both client-side and server-side tracking out of the box, with a privacy-first proxy that routes analytics through your own domain.
Place an analytics.json at your project root (the same folder where you execute npx doccupine).
{
"provider": "posthog",
"posthog": {
"key": "phc_your_project_api_key",
"host": "https://us.i.posthog.com"
}
}"posthog" is supported.https://us.i.posthog.com for US Cloud or https://eu.i.posthog.com for EU Cloud. If you self-host PostHog, use your instance URL.The PostHog project API key is a public identifier used to send events. It is not a secret and is safe to include in your repository.
When analytics.json is configured, Doccupine enables two layers of tracking:
Doccupine routes all analytics traffic through your documentation domain using Next.js rewrites. Instead of sending data directly to PostHog (which ad blockers may intercept), requests go through /ingest on your own domain and are proxied to PostHog.
This means:
The proxy destinations are derived automatically from the host field in your configuration.
analytics.json as the posthog.key value.analytics.json in the project root alongside config.json and theme.json.analytics.json are picked up automatically in watch mode. The layout, middleware, and Next.js config are regenerated.analytics.json is missing, empty, or has an invalid configuration, no tracking code runs. Your site works exactly the same without it.analytics.json for the first time, you may need to restart the Next.js dev server for proxy rewrites to take effect.After adding analytics.json for the first time, restart the dev server so the proxy rewrites are picked up by Next.js.
PostHog offers two cloud regions. Set the host field accordingly:
| Region | Host |
|---|---|
| US Cloud | https://us.i.posthog.com |
| EU Cloud | https://eu.i.posthog.com |
If you omit the host field, it defaults to the US Cloud endpoint.
{
"provider": "posthog",
"posthog": {
"key": "phc_your_project_api_key"
}
}{
"provider": "posthog",
"posthog": {
"key": "phc_your_project_api_key",
"host": "https://eu.i.posthog.com"
}
}analytics.json only in your production/deployment setup to avoid tracking local development traffic.