tools/integrations/posthog.md
Open-source product analytics with session replay and feature flags.
| Integration | Available | Notes |
|---|---|---|
| API | ✓ | Capture API, Query API, Feature Flags API |
| MCP | - | Not available |
| CLI | ✓ | posthog CLI for local development |
| SDK | ✓ | JavaScript, Python, Ruby, Go, etc. |
Authorization: Bearer {api_key}POST https://app.posthog.com/capture/
{
"api_key": "{project_api_key}",
"event": "signup_completed",
"distinct_id": "user_123",
"properties": {
"plan": "pro",
"$current_url": "https://example.com/signup"
}
}
POST https://app.posthog.com/batch/
{
"api_key": "{project_api_key}",
"batch": [
{"event": "pageview", "distinct_id": "user_1"},
{"event": "signup", "distinct_id": "user_2"}
]
}
GET https://app.posthog.com/api/projects/{project_id}/persons/?distinct_id=user_123
Authorization: Bearer {api_key}
POST https://app.posthog.com/api/projects/{project_id}/query/
{
"query": {
"kind": "HogQLQuery",
"query": "SELECT event, count() FROM events WHERE timestamp > now() - interval 7 day GROUP BY event ORDER BY count() DESC LIMIT 10"
}
}
POST https://app.posthog.com/decide?v=3
{
"api_key": "{project_api_key}",
"distinct_id": "user_123"
}
GET https://app.posthog.com/api/projects/{project_id}/insights/
Authorization: Bearer {api_key}
GET https://app.posthog.com/api/projects/{project_id}/session_recordings/
Authorization: Bearer {api_key}
// Initialize
posthog.init('PROJECT_API_KEY', {
api_host: 'https://app.posthog.com'
});
// Identify user
posthog.identify('user_123', {
email: '[email protected]',
plan: 'pro'
});
// Track event
posthog.capture('signup_completed', {
method: 'email'
});
// Check feature flag
if (posthog.isFeatureEnabled('new-pricing')) {
// Show new pricing
}