payload-posthog

Getting Started

Install payload-posthog and wire it into your Payload config.

Installation

npm install payload-posthog

Quick start

payload.config.ts
import { buildConfig } from 'payload'
import { payloadPosthog } from 'payload-posthog'

export default buildConfig({
  // ...
  plugins: [
    payloadPosthog({
      apiKey: process.env.POSTHOG_API_KEY!,
      // host: 'https://us.i.posthog.com', // default — use https://eu.i.posthog.com for EU Cloud
      collections: {
        posts: true,
        pages: true,
      },
    }),
  ],
})

With just that, posts and pages emit capture events on create/update/delete, logins get identified, server errors get reported to PostHog, feature-flag helpers are ready to import, and the admin panel gets a PostHog-powered dashboard widget plus session replay.

What's on by default

FeatureDefault
Captureon for collections listed in collections
Identifyon
Feature flagson
Error trackingon
Client (admin panel)on
Reverse proxyoff — opt in
Webhooksoff — requires a handler
Groupsoff — requires a mapper

See the configuration reference for the full option set, or jump straight to a feature guide.

On this page