ConfigsApr 16, 2026·3 min read

PostHog — Open Source Product Analytics & Session Replay

PostHog is a self-hosted product analytics platform with event tracking, session replay, feature flags, A/B testing, and a data warehouse built in.

TL;DR
PostHog provides self-hosted product analytics with session replay, feature flags, and A/B testing in one platform.
§01

What it is

PostHog is an open-source product analytics platform that combines event tracking, session replay, feature flags, A/B testing, and a data warehouse in a single self-hosted application. It replaces the need for separate tools like Google Analytics, Hotjar, LaunchDarkly, and Optimizely.

PostHog is for product teams who want full control over their analytics data. It suits startups and enterprises that need product insights without sending user behavior data to third-party services.

§02

How it saves time or tokens

This workflow provides a single Docker command that launches a working PostHog instance. Instead of configuring multiple analytics tools separately, you get everything in one deployment. The included JavaScript snippet auto-captures page views, clicks, and form submissions without manual event instrumentation.

§03

How to use

  1. Deploy PostHog with Docker:
docker run -d --name posthog \
  -p 8000:8000 \
  -v posthog_data:/var/lib/postgresql/data \
  posthog/posthog:release
  1. Open http://localhost:8000 and complete the setup wizard. Create your organization and first project.
  1. Add the PostHog snippet to your application:
<script>
  !function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src=s.api_host+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags getFeatureFlag getFeatureFlagPayload reloadFeatureFlags group updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures getActiveMatchingSurveys getSurveys".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
  posthog.init('your-project-api-key', {api_host: 'http://localhost:8000'})
</script>
§04

Example

// Custom event tracking
posthog.capture('purchase_completed', {
  product_id: 'prod_123',
  amount: 49.99,
  currency: 'USD'
});

// Feature flag check
if (posthog.isFeatureEnabled('new_checkout_flow')) {
  renderNewCheckout();
} else {
  renderClassicCheckout();
}

// Identify users
posthog.identify('user_123', {
  email: 'user@example.com',
  plan: 'pro'
});
§05

Related on TokRepo

§06

Common pitfalls

  • The Docker single-container deployment is for evaluation only. Production deployments need separate PostgreSQL, Redis, ClickHouse, and Kafka instances. Use the PostHog Helm chart for Kubernetes.
  • Auto-capture records every click and page view, which can generate high event volumes. Use the autocapture config option to filter unnecessary events.
  • Session replay recordings consume significant storage. Set retention policies to avoid running out of disk space.

Frequently Asked Questions

What does PostHog include?+

PostHog includes product analytics (event tracking, funnels, retention), session replay (video recordings of user sessions), feature flags (gradual rollouts), A/B testing (experiments), and a data warehouse for SQL queries on your analytics data.

Is PostHog free?+

PostHog is open source under the MIT license. Self-hosted deployments are free with no event limits. PostHog Cloud offers a free tier with generous limits and paid plans for higher volumes.

How does PostHog compare to Google Analytics?+

PostHog focuses on product analytics (user behavior, funnels, retention) while GA focuses on marketing analytics (traffic sources, campaigns). PostHog includes session replay, feature flags, and A/B testing. PostHog can be self-hosted for full data control.

Can I use PostHog with mobile apps?+

Yes. PostHog provides SDKs for iOS, Android, React Native, and Flutter. Mobile SDKs support event tracking, feature flags, and user identification. Session replay for mobile is available on select platforms.

Does PostHog support A/B testing?+

Yes. PostHog experiments let you run A/B tests with statistical significance calculations. You define variants, target user segments, and track conversion goals. Results include confidence intervals and sample size recommendations.

Citations (3)

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets