posthog
🦔 PostHog provides open-source product analytics, session recording, feature flagging and A/B testing that you can self-host.
Top Related Projects
Simple, open source, lightweight (< 1 KB) and privacy-friendly web analytics alternative to Google Analytics.
Empowering People Ethically with the leading open source alternative to Google Analytics that gives you full control over your data. Matomo lets you easily collect data from websites & apps and visualise this data and extract insights. Privacy is built-in. Liberating Web Analytics. Star us on Github? +1. And we love Pull Requests!
Umami is a simple, fast, privacy-focused alternative to Google Analytics.
Quick Overview
PostHog is an open-source product analytics platform that helps teams understand user behavior and improve their products. It offers features like event tracking, funnel analysis, session recording, and feature flags, all while allowing companies to maintain control over their data by self-hosting the platform.
Pros
- Self-hosted solution, providing full data ownership and privacy
- Comprehensive feature set including analytics, session recording, and feature flags
- Open-source with a strong community and regular updates
- Flexible integration options with various frameworks and platforms
Cons
- Requires more setup and maintenance compared to SaaS alternatives
- May have higher infrastructure costs for large-scale deployments
- Learning curve for teams new to product analytics
- Some advanced features may require paid plans
Code Examples
- Initializing PostHog in a React application:
import posthog from 'posthog-js'
posthog.init('<YOUR_PROJECT_API_KEY>', {
api_host: 'https://app.posthog.com'
})
- Tracking a custom event:
posthog.capture('button_clicked', {
button_color: 'blue',
button_text: 'Sign Up'
})
- Identifying a user:
posthog.identify('user_id_123', {
email: 'jane@example.com',
name: 'Jane Doe'
})
- Using feature flags:
posthog.isFeatureEnabled('new_feature', {
send_event: true
}).then((enabled) => {
if (enabled) {
// Show new feature
} else {
// Show old feature
}
})
Getting Started
To start using PostHog, follow these steps:
- Sign up for a PostHog account or set up a self-hosted instance.
- Install the PostHog library in your project:
npm install posthog-js
- Initialize PostHog in your application:
import posthog from 'posthog-js' posthog.init('<YOUR_PROJECT_API_KEY>', { api_host: 'https://app.posthog.com' // Use your self-hosted URL if applicable })
- Start tracking events and using PostHog features in your code.
For more detailed instructions and advanced usage, refer to the official PostHog documentation.
Competitor Comparisons
Simple, open source, lightweight (< 1 KB) and privacy-friendly web analytics alternative to Google Analytics.
Pros of Plausible
- Lightweight and privacy-focused, with no cookies and GDPR compliance
- Simple, clean interface with easy-to-understand metrics
- Open-source and self-hostable with minimal resource requirements
Cons of Plausible
- Limited feature set compared to PostHog's comprehensive toolkit
- Less customizable and extensible for complex analytics needs
- Fewer integrations with third-party tools and services
Code Comparison
PostHog (Python):
from posthog import Posthog
posthog = Posthog(project_api_key='your_api_key', host='https://app.posthog.com')
posthog.capture('user_id', 'event_name', {'property': 'value'})
Plausible (JavaScript):
plausible('event_name', {props: {property: 'value'}})
PostHog offers a more robust API with various client libraries, while Plausible focuses on simplicity with a straightforward JavaScript snippet. PostHog provides more granular control over event tracking and user properties, whereas Plausible emphasizes minimal code for basic event tracking.
Empowering People Ethically with the leading open source alternative to Google Analytics that gives you full control over your data. Matomo lets you easily collect data from websites & apps and visualise this data and extract insights. Privacy is built-in. Liberating Web Analytics. Star us on Github? +1. And we love Pull Requests!
Pros of Matomo
- More established project with a longer history and larger user base
- Offers both self-hosted and cloud-hosted options
- Stronger focus on data privacy and GDPR compliance
Cons of Matomo
- Less modern tech stack compared to PostHog
- More limited event-based analytics capabilities
- Slower development pace and fewer frequent updates
Code Comparison
Matomo (PHP):
$tracker = new MatomoTracker($idSite = 1, 'http://example.org/matomo/');
$tracker->doTrackPageView('Page Title');
PostHog (JavaScript):
posthog.capture('page_view', { page_title: 'Page Title' });
Both Matomo and PostHog are open-source analytics platforms, but they differ in their approach and target audience. Matomo (formerly Piwik) is a more traditional web analytics tool, similar to Google Analytics, while PostHog focuses on product analytics and offers features like session recording and feature flags.
PostHog uses a more modern tech stack (React, Django, ClickHouse) and has a stronger emphasis on developer-friendly features. It also provides a more comprehensive suite of product analytics tools out of the box.
Matomo, on the other hand, has a stronger focus on data privacy and compliance, making it a popular choice for organizations with strict data protection requirements. It also offers a wider range of plugins and integrations due to its longer presence in the market.
Umami is a simple, fast, privacy-focused alternative to Google Analytics.
Pros of umami
- Lightweight and simple to set up, ideal for basic website analytics
- Privacy-focused with no cookies and GDPR compliance
- Free and open-source with a clean, minimalist interface
Cons of umami
- Limited feature set compared to PostHog's comprehensive analytics suite
- Lacks advanced user behavior tracking and product analytics capabilities
- Smaller community and ecosystem for extensions and integrations
Code Comparison
umami (JavaScript):
export async function getWebsiteStats(...) {
return runQuery(
prisma.website.findUnique({
where: { id },
select: {
pageviews: true,
uniques: true,
bounces: true,
totaltime: true,
},
})
);
}
PostHog (Python):
def get_event_count_for_team(team_id: int, event_name: str, ...) -> int:
return EventDefinition.objects.filter(
team_id=team_id,
name=event_name,
deleted=False,
).aggregate(Count("id"))["id__count"]
Both repositories offer web analytics solutions, but they cater to different needs. umami is more focused on simplicity and privacy, while PostHog provides a more comprehensive suite of product analytics tools. The code snippets demonstrate the different approaches: umami uses JavaScript and focuses on basic website stats, while PostHog uses Python and offers more complex event tracking capabilities.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Docs - Community - Roadmap - Changelog - Bug reports
PostHog is an all-in-one, open source platform for building better products
- Specify events manually, or use autocapture to get started quickly
- Analyze data with ready-made visualizations, or do it yourself with SQL
- Only capture properties on the people you want to track, save money when you don't
- Gather insights by capturing session replays, console logs, and network monitoring
- Improve your product with Experiments that automatically analyze performance
- Safely roll out features to select users or cohorts with feature flags
- Send out fully customizable surveys to specific cohorts of users
- Connect to external services and manage data flows with PostHog CDP
PostHog is available with hosting in the EU or US and is fully SOC 2 compliant. It's free to get started and comes with a generous monthly free tier:
- 1 million product analytics events
- 5k session replays
- 1 million feature flag requests
- 250 survey responses
We're constantly adding new features, with web analytics and data warehouse now in beta!
Table of Contents
Get started for free
PostHog Cloud (Recommended)
The fastest and most reliable way to get started with PostHog is signing up for free to PostHog Cloud or PostHog Cloud EU. Your first 1 million events (and 5k replays) are free every month, after which you pay based on usage.
Open-source hobby deploy (Advanced)
You can deploy a hobby instance in one line on Linux with Docker (recommended 4GB memory):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/posthog/posthog/HEAD/bin/deploy-hobby)"
Open source deployments should scale to approximately 100k events per month, after which we recommend migrating to a PostHog Cloud instance. See our docs for more info and limitations. Please note that we do not provide customer support for open source deployments.
Docs
Want to find out more? Request a demo!
PostHog brings all the tools and data you need to build better products.
Analytics and optimization tools
- Event-based analytics: Capture your product's usage automatically, or customize it to your needs
- User and group tracking: Understand the people and groups behind the events and track properties about them when needed
- Data visualizations: Create and share graphs, funnels, paths, retention, and dashboards
- SQL access: Use SQL to get a deeper understanding of your users, breakdown information and create completely tailored visualizations
- Session replays: Watch videos of your users' behavior, with fine-grained filters and privacy controls, as well as network monitoring and captured console logs
- Heatmaps: See where users click and get a visual representation of their behaviour with the PostHog Toolbar
- Feature flags: Test and manage the rollout of new features to specific users and groups, or deploy flags as kill-switches
- Experiments: run simple or complex changes as experiments and get automatic significance calculations
- Correlation analysis: Discover what events and properties correlate with success and failure
- Surveys: Collect qualitative feedback from your users using fully customizable surveys
Data and infrastructure tools
- Import and export your data: Import from and export to the services that matter to you with the PostHog CDP
- Ready-made libraries: Weâve built libraries for JavaScript, Python, Ruby, Node, Go, Android, iOS, PHP, Flutter, React Native, Elixir, Nim, and an API for anything else
- Plays nicely with data warehouses: import events or user data from your warehouse by writing a simple transformation plugin, and export data with pre-built apps - such as BigQuery, Redshift, Snowflake, and S3
Read a full list of PostHog features.
Contributing
We <3 contributions big and small. In priority order (although everything is appreciated) with the most helpful first:
- Vote on features or get early access to beta functionality in our roadmap
- Open a PR (see our instructions on developing PostHog locally)
- Submit a feature request or bug report
Philosophy
Our mission is to increase the number of successful products in the world. To do that, we build product and data tools that help you understand user behavior without losing control of your data.
In our view, third-party analytics tools do not work in a world of cookie deprecation, GDPR, HIPAA, CCPA, and many other four-letter acronyms. PostHog is the alternative to sending all of your customers' personal information and usage data to third parties.
PostHog gives you every tool you need to understand user behavior, develop and test improvements, and release changes to make your product more successful.
PostHog operates in public as much as possible. We detail how we work and our learning on building and running a fast-growing, product-focused startup in our handbook.
Open-source vs. paid
This repo is available under the MIT expat license, except for the ee
directory (which has its license here) if applicable.
Need absolutely ð¯% FOSS? Check out our posthog-foss repository, which is purged of all proprietary code and features.
To learn more, book a demo or see our pricing page.
Weâre hiring!
Come help us make PostHog even better. We're growing fast and would love for you to join us.
Contributors ð¦¸
Top Related Projects
Simple, open source, lightweight (< 1 KB) and privacy-friendly web analytics alternative to Google Analytics.
Empowering People Ethically with the leading open source alternative to Google Analytics that gives you full control over your data. Matomo lets you easily collect data from websites & apps and visualise this data and extract insights. Privacy is built-in. Liberating Web Analytics. Star us on Github? +1. And we love Pull Requests!
Umami is a simple, fast, privacy-focused alternative to Google Analytics.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot