PostHog Analytics Integration

18 May 20264 minutes
Carmen Dou

Carmen Dou

Software Engineer

PostHog Analytics in InsForge

InsForge now supports PostHog for product analytics.

One click in the dashboard provisions a PostHog project, links it to your InsForge project, and fills an Analytics page with live KPIs, breakdowns, retention, and session replays. No API key copy-paste, no project picker, no separate login.

How It Works

Open Analytics in the InsForge dashboard and click Connect PostHog.

InsForge Analytics page with the Connect PostHog empty state

If you already have a PostHog account, you'll see PostHog's authorize screen — pick the organization and project, then approve.

PostHog authorize screen requesting access for InsForge

If you don't, InsForge creates a PostHog account for you in the background. Either way, the page reloads with live data in seconds.

What You See After Connecting

Connected Analytics page showing connection status, setup prompt, API key, and KPI cards with a trend chart

The page is built directly on PostHog's /query endpoint:

  • KPIs with trends — visitors, pageviews, sessions, and bounce rate; click any card to swap the trend chart below.
  • Breakdowns — top pages, countries, and device types side by side.
  • Retention — weekly retention cohort computed against your $pageview events.
  • Recent replays — the latest session recordings, openable in a modal without leaving InsForge.
  • Project API key — the phc_ key and host, ready to copy for anything the dashboard doesn't cover.

A time-range selector at the top of the page controls every card in one place, and an Open in PostHog button jumps you straight to the source-of-truth view.

Setup for Agents

Connecting the dashboard is half the job — your app still needs the PostHog SDK. The Analytics page ships a copyable prompt:

text
I'm using InsForge as my backend platform. I want to add product analytics to this project. Read the current directory and use the InsForge skill to set up PostHog analytics for me.

Paste it into Claude Code, Cursor, or any agent that runs the InsForge skill. The skill points the agent at the official PostHog wizard, which detects your framework, installs the right SDK, and wires the provider with your project key. For headless or CI setups, npx @insforge/cli posthog setup runs the same flow from the terminal.