Google Analytics tracks page views. PostHog tracks everything: analytics, session replay, feature flags, A/B tests, and surveys — all in one open-source platform.
What PostHog Replaces
| PostHog feature | Replaces | Paid alternative cost |
|---|---|---|
| Product analytics | Mixpanel, Amplitude | $25-2000/mo |
| Session replay | Hotjar, FullStory | $39-199/mo |
| Feature flags | LaunchDarkly | $10-1000/mo |
| A/B testing | Optimizely | $50-5000/mo |
| Surveys | Typeform, SurveyMonkey | $25-99/mo |
| Total saved | $149-8298/mo |
Free Tier
- 1M analytics events/month
- 5K session recordings/month
- 1M feature flag requests/month
- Unlimited team members
- Self-host option (truly unlimited)
Setup (2 Minutes)
npm install posthog-js
import posthog from "posthog-js";
posthog.init("phc_your_project_key", {
api_host: "https://us.i.posthog.com",
person_profiles: "identified_only",
});
Product Analytics
// Track events
posthog.capture("order_completed", {
total: 99.99,
items: 3,
payment_method: "card",
});
// Identify users
posthog.identify("user_123", {
email: "alice@test.com",
plan: "premium",
company: "Acme Inc",
});
// Group analytics (by company)
posthog.group("company", "acme-inc", {
name: "Acme Inc",
plan: "enterprise",
employees: 500,
});
Feature Flags
// Check flag
if (posthog.isFeatureEnabled("new-checkout-flow")) {
renderNewCheckout();
} else {
renderOldCheckout();
}
// Multivariate flags
const variant = posthog.getFeatureFlag("pricing-page");
if (variant === "variant-a") {
showMonthlyPricing();
} else if (variant === "variant-b") {
showAnnualPricing();
}
// Server-side (Node.js)
import { PostHog } from "posthog-node";
const posthog = new PostHog("phc_key");
const enabled = await posthog.isFeatureEnabled("feature", "user_123");
A/B Testing (Experiments)
Create experiments in the PostHog UI:
- Choose a feature flag for control/variant
- Define your metric (e.g., "order_completed" rate)
- Set statistical significance threshold
- PostHog automatically calculates results
Session Replay
posthog.init("phc_key", {
api_host: "https://us.i.posthog.com",
session_recording: {
maskAllInputs: true, // Privacy
maskTextContent: false,
},
});
Watch real user sessions: clicks, scrolls, rage clicks, errors — all recorded.
Surveys
// Surveys are configured in the PostHog UI
// Target by: URL, user properties, feature flags
// Types: open text, rating, multiple choice, NPS
Self-Host (Docker)
git clone https://github.com/PostHog/posthog.git
cd posthog
docker compose -f docker-compose.hobby.yml up -d
Your data stays on your servers. Unlimited events. Zero cost.
Need analytics or data tools? I build web scraping and developer solutions. Email spinov001@gmail.com or check my Apify tools.
Top comments (0)