observability monitoring10 minutes

Get Started with PostHog

Unverified

Quick Summary

Open-source product analytics with session replay, flags, and experiments.

Best for: Open-source product analytics
Time to first integration: 10 minutes

📋Prerequisites

  • Node.js 18+ installed
  • A PostHog account — sign up here
  • An existing project (Next.js, React, or Node.js recommended)

Setup Steps

4 steps
1

Install

Add the PostHog JS SDK to your project.

bash
npm install posthog-js
2

Initialize

Initialize with your project API key and host (from PostHog project settings).

typescript
import posthog from 'posthog-js' posthog.init(apiKey, { api_host: 'https://us.i.posthog.com' })
3

Capture events

Track custom events with properties.

typescript
posthog.capture('event_name', { property: 'value' })
4

Verify

Confirm events appear in the PostHog activity view.

Links