AI wizard

The PostHog wizard is an agentic CLI tool that uses AI to set up and manage PostHog in your codebase. By default, it installs and instruments PostHog for you with a single command: npx -y @posthog/wizard@latest.

It does more than installation, though. The wizard can also audit an existing integration, migrate you from another vendor, upload source maps, set up Revenue Analytics, and diagnose configuration issues – so it's just as useful after you're up and running as it is on day one.

When it's done, your project is onboarded with:

How it works

Running the wizard automatically:

  1. Authenticates your PostHog account
  2. Installs the relevant PostHog SDKs
  3. Scans your codebase and app architecture
  4. Creates custom events based on real product flows
  5. Configures .env file with your project credentials
  6. Writes code and instruments the PostHog SDKs client-side and server-side
  7. Generates insights and dashboards in the PostHog app
  8. Optionally installs the PostHog MCP server for your AI agent
The AI wizard integrating both the JS Web SDK and Node SDK into a Next.js application

AI wizard installation

Install PostHog in minutes with our wizard by running this command in your project directory:

Learn more

Wait for it to finish and test the setup once the wizard is complete.

Frameworks and languages

The wizard supports the following frameworks and languages:

We've got more on the way.

Check out the wizard's GitHub repo for more details.

Set up a reverse proxy (recommended)

We recommend setting up a reverse proxy, so that events are less likely to be intercepted by tracking blockers.

We have our own managed reverse proxy service, which is free for all PostHog Cloud users, routes through our infrastructure, and makes setting up your proxy easy.

If you don't want to use our managed service then there are several other options for creating a reverse proxy, including using Cloudflare, AWS Cloudfront, and Vercel.

Grouping products in one project (recommended)

If you have multiple customer-facing products (e.g. a marketing website + mobile app + web app), it's best to install PostHog on them all and group them in one project.

This makes it possible to track users across their entire journey (e.g. from visiting your marketing website to signing up for your product), or how they use your product across multiple platforms.

Add IPs to Firewall/WAF allowlists (recommended)

For certain features like heatmaps, your Web Application Firewall (WAF) may be blocking PostHog’s requests to your site. Add these IP addresses to your WAF allowlist or rules to let PostHog access your site.

EU: 3.75.65.221, 18.197.246.42, 3.120.223.253

US: 44.205.89.55, 52.4.194.122, 44.208.188.173

These are public, stable IPs used by PostHog services (e.g., Celery tasks for snapshots).

Commands

Running npx @posthog/wizard starts the default integration flow. The wizard also supports the following commands:

CommandWhat it does
wizardDefault flow – installs and instruments PostHog
wizard audit <subcommand>Audit an existing integration – see Audit subcommands
wizard revenue-analyticsWire up Stripe + PostHog revenue analytics
wizard migrateMigrate from another analytics or feature-flag vendor
wizard upload-source-mapsUpload source maps to PostHog Error Tracking
wizard mcp add / wizard mcp remove / wizard mcp tutorialManage the PostHog MCP server for your AI agent, or explore the MCP tutorial
wizard slack addConnect PostHog to your Slack
wizard skill <skill-name>Run a single skill by name – browse the available skills in the context-mill releases

Audit subcommands

@npx @posthog/wizard audit on its own runs the events audit. Pass a subcommand to run a specific one.

CommandWhat it does
wizard audit eventsAudit event capture quality and cost (default)
wizard audit allComprehensive audit across every area
wizard audit autocaptureAudit autocapture setup and cost
wizard audit feature-flagsAudit feature flag usage and cost
wizard audit identifyAudit your $identify implementation
wizard audit session-replayAudit session replay setup
wizard audit web-analyticsAudit web analytics setup

Legacy commands

The CLI was overhauled to consolidate commands into a smaller, more consistent surface. If you used an older command name, here's where it went:

Old commandNew commandWhat changed
wizard integratewizardThe default flow now runs the integration
wizard events-auditwizard audit eventsNow an audit subcommand
wizard auditwizard audit <subcommand>Now takes a subcommand; wizard audit all runs a full audit
wizard revenuewizard revenue-analyticsRenamed – update any scripts using revenue
wizard upload-sourcemapswizard upload-source-mapsRenamed (the old upload-sourcemaps still works)

Feedback

We think flows like the AI wizard are pretty cool and the future of developer experience. The AI wizard is our recommended and default method for installing PostHog and getting started.

If you have any feedback or requests, we would love to hear from you. Feel free to comment on this page or open an issue on GitHub.

Community questions

Was this page useful?

Questions about this page? or post a community question.