Install
openclaw skills install posthog-queryRun SQL queries against PostHog product analytics data using the PostHog CLI. Use when checking pageviews, event counts, trends, or any analytics data from PostHog.
openclaw skills install posthog-queryRun HogQL (ClickHouse-compatible SQL) queries against PostHog via the CLI.
posthog-cli login # authenticate interactively; stores token in ~/.posthog/credentials.json
Requires API key scope: query:read.
posthog-cli exp query run "<SQL>"
Results are printed as JSON lines to stdout. The CLI reads auth from ~/.posthog/credentials.json (set up via posthog-cli login).
Use bracket notation for event properties — dot notation with quoted keys does not work:
-- ✅ Correct
properties['$current_url']
properties['$browser']
-- ❌ Wrong
properties.'$current_url'
Count all pageviews:
posthog-cli exp query run "SELECT count() as pageviews FROM events WHERE event = '\$pageview'"
Filter by URL:
posthog-cli exp query run "SELECT count() as pageviews FROM events WHERE event = '\$pageview' AND properties['\$current_url'] LIKE 'https://example.com/%'"
7-day daily trend:
posthog-cli exp query run "SELECT toDate(timestamp) as date, count() as pageviews FROM events WHERE event = '\$pageview' AND timestamp >= now() - INTERVAL 7 DAY GROUP BY date ORDER BY date"
Recent events:
posthog-cli exp query run "SELECT event, timestamp FROM events ORDER BY timestamp DESC LIMIT 10"
posthog-cli exp query editor — interactive query editorposthog-cli exp query check "<SQL>" — syntax/type check without running--debug to run to get the full JSON response (columns, types, cache info)$ in event names: '\$pageview' or use double quotes carefully--debug flag returns full metadata including column types and cache status