with one click
posthog
Query events, run HogQL analytics, and access product data
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
Query events, run HogQL analytics, and access product data
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
Query and search AWS CloudWatch Logs and run Logs Insights queries
Query Sentry issues, events, and releases for error monitoring and triage
Analyze the codebase database schema, query patterns, and business domain to build a data-agent skill. Use when setting up a new project, after schema changes, or when the data-agent skill needs updating.
Configure the Byaan MCP server in AI coding assistants (Claude Code, Cursor, Codex CLI). Detects the local project, builds the correct stdio config, and installs it into the chosen tool. Only works for local/community mode — not the Mac desktop app.
Initialize Byaan development environment using Docker. Builds and starts backend and frontend containers with SQLite, opens the browser, learns the codebase, and configures MCP. Use when setting up the project for the first time.
Manage issues, projects, and cycles in Linear
| name | posthog |
| display_name | PostHog |
| description | Query events, run HogQL analytics, and access product data |
| emoji | 🦔 |
| homepage | https://posthog.com |
| api | {"base_url":"https://us.posthog.com","domain":"posthog.com","type":"rest","auth":{"type":"bearer"}} |
| credentials | [{"key":"api_key","label":"Personal API Key","placeholder":"phx_...","help":"From PostHog → Avatar → Settings → Personal API Keys"},{"key":"project_id","label":"Project ID","placeholder":"12345","help":"From Project Settings, numeric ID shown in URL"}] |
Use the PostHog API to query events, run HogQL analytics, and access product data like persons, insights, and feature flags.
Before using this skill, you need to create a Personal API Key and find your Project ID.
phx_)https://us.posthog.com/project/12345/settings/project/ is your Project ID (e.g., 12345)When creating the Personal API Key, enable Read access for the following scopes:
| Scope | Access | Purpose |
|---|---|---|
| Query | Read | Execute HogQL queries |
| Event | Read | Access event data |
| Person | Read | Access person/user data |
| Insight | Read | Access saved insights |
| Dashboard | Read | Access dashboards |
| Feature flag | Read | Access feature flag configurations |
| Cohort | Read | Access cohort definitions |
All other scopes can be set to "No access" for maximum security.
The default base URL is https://us.posthog.com (US Cloud). If you use a different region:
| Region | Base URL |
|---|---|
| US Cloud | https://us.posthog.com |
| EU Cloud | https://eu.posthog.com |
| Self-hosted | Your custom domain |
You do not need to handle authentication manually. When you call execute_skill_api(), the system automatically:
Authorization: Bearer <api_key> headerJust call the API with skill name, endpoint path, method, and body — authentication is handled for you.
PostHog uses REST with HogQL queries for analytics. The main query endpoint is:
POST /api/projects/{project_id}/query/
Call execute_skill_api() with these parameters:
execute_skill_api(
skill_name="posthog",
endpoint_path="/api/projects/{project_id}/query/",
method="POST",
body={
"query": {
"kind": "HogQLQuery",
"query": "SELECT event, count() FROM events GROUP BY event LIMIT 10"
}
}
)
Note: Replace {project_id} with the actual project ID from the credentials.
HogQL is PostHog's SQL dialect for querying analytics data. It supports standard SQL with some extensions.
| Table | Description |
|---|---|
events | All tracked events with properties |
persons | User/person data and properties |
sessions | Session aggregations |
groups | Group analytics data |
| Column | Type | Description |
|---|---|---|
event | String | Event name (e.g., $pageview, $autocapture) |
timestamp | DateTime | When the event occurred |
distinct_id | String | User identifier |
properties | Object | Event properties (access with properties.$key) |
person_id | UUID | Internal person identifier |
person | Object | Person properties |
Use dot notation for nested properties:
-- Event properties
properties.$current_url
properties.$browser
properties.$device_type
properties.$referrer
properties.custom_property
-- Person properties
person.properties.email
person.properties.name
| Function | Description |
|---|---|
count() | Count rows |
countDistinct(column) | Count unique values |
sum(column) | Sum values |
avg(column) | Average |
min(column) / max(column) | Min/max |
toDate(timestamp) | Convert to date |
dateDiff('day', start, end) | Date difference |
now() | Current timestamp |
today() | Current date |
SELECT event, timestamp, distinct_id, properties.$current_url
FROM events
ORDER BY timestamp DESC
LIMIT 100
SELECT event, count() as count
FROM events
WHERE timestamp > now() - INTERVAL 7 DAY
GROUP BY event
ORDER BY count DESC
LIMIT 20
SELECT
properties.$current_url as url,
count() as views
FROM events
WHERE event = '$pageview'
AND timestamp > now() - INTERVAL 7 DAY
GROUP BY url
ORDER BY views DESC
LIMIT 20
SELECT countDistinct(distinct_id) as unique_users
FROM events
WHERE timestamp > now() - INTERVAL 30 DAY
SELECT
distinct_id,
count() as total_events,
countDistinct(event) as unique_events,
min(timestamp) as first_seen,
max(timestamp) as last_seen
FROM events
GROUP BY distinct_id
ORDER BY total_events DESC
LIMIT 50
SELECT
toDate(timestamp) as date,
countDistinct(distinct_id) as dau
FROM events
WHERE timestamp > now() - INTERVAL 30 DAY
GROUP BY date
ORDER BY date DESC
SELECT
properties.$browser as browser,
count() as events
FROM events
WHERE timestamp > now() - INTERVAL 7 DAY
GROUP BY browser
ORDER BY events DESC
SELECT
countDistinct(CASE WHEN event = 'page_visit' THEN distinct_id END) as step1_users,
countDistinct(CASE WHEN event = 'signup_started' THEN distinct_id END) as step2_users,
countDistinct(CASE WHEN event = 'signup_completed' THEN distinct_id END) as step3_users
FROM events
WHERE timestamp > now() - INTERVAL 30 DAY
SELECT
distinct_id,
dateDiff('minute', min(timestamp), max(timestamp)) as session_minutes
FROM events
WHERE timestamp > now() - INTERVAL 1 DAY
GROUP BY distinct_id
HAVING session_minutes > 0
ORDER BY session_minutes DESC
LIMIT 20
SELECT
properties.$referrer as referrer,
count() as visits
FROM events
WHERE event = '$pageview'
AND properties.$referrer != ''
AND timestamp > now() - INTERVAL 7 DAY
GROUP BY referrer
ORDER BY visits DESC
LIMIT 20
GET /api/projects/{project_id}/persons/
GET /api/projects/{project_id}/insights/
GET /api/projects/{project_id}/dashboards/
GET /api/projects/{project_id}/feature_flags/
GET /api/projects/{project_id}/cohorts/
GET /api/projects/{project_id}/events/?limit=100
PostHog has deprecated this endpoint (kept for backwards compatibility, offset capped at 50,000). Prefer the Query endpoint with HogQL for any ad-hoc listing or aggregation of events.
List endpoints paginate in one of two ways:
next URLs (persons, insights, dashboards): the response contains {"next": "<url>", "previous": ..., "results": [...]} — request the next URL (path + query only, same host) for the following pagelimit / offset (events): skip-based pagingFor HogQL queries, use LIMIT and OFFSET clauses:
SELECT event, timestamp
FROM events
ORDER BY timestamp DESC
LIMIT 100
OFFSET 200
| Endpoint | Limit |
|---|---|
| Query endpoint | 2400/hour (per organization) |
| Analytics endpoints (insights, persons, recordings) | 240/minute, 1200/hour |
| CRUD/list endpoints | 480/minute, 4800/hour |
PostHog reserves the right to throttle or reject queries that look like bulk exports — keep queries analytical, not extractive.
Project ID is required: All API calls require the project ID in the URL path. Get it from Project Settings.
HogQL requires proper query structure: The query body must have "kind": "HogQLQuery" and the SQL in "query".
Property access syntax: Use properties.$key for event properties. The $ prefix is part of PostHog's naming convention for built-in properties.
Date filtering: Use timestamp > now() - INTERVAL N DAY for recent data. Without date filters, queries may be slow.
Result caps: Without an explicit LIMIT, HogQL results are capped at 100 rows. With an explicit LIMIT, up to 50,000 rows per query.
Region-specific URLs: US Cloud uses us.posthog.com, EU Cloud uses eu.posthog.com. Using the wrong region will fail.
Personal vs Project API Keys: Use Personal API Keys (start with phx_), not Project API Keys (which are for client-side tracking).
Case sensitivity: Event names and property keys are case-sensitive. $pageview is different from $Pageview.
Empty results: If queries return no data, check the date range and ensure events exist for that period.
$ (e.g., $pageview, $autocapture, $pageleave)