Query Analytics
query_analyticsInput Schema
| Name | Required | Description | Default |
|---|---|---|---|
| days | No | Number of days of snapshots to look back (default 7). Use `days=0` to fetch only the most recent snapshot — which under the daily-window collector covers yesterday UTC. This is the right call for the setup-time "show the user a sample of yesterday's data" flow, since it matches what the scheduled digest will show. Ignored for metric="digest_view". | |
| metric | Yes | One of "traffic", "sources", "top_pages", "top_clicks", "engagement", "daily_digest", "digest_view", "custom". Use "digest_view" to read exactly what the user sees on this agent's Analytics Output tab — the derived today + history entries (each with week-over-week deltas) + PostHog link; the other metrics return raw snapshot data. | |
| custom_query | No | Raw HogQL SQL query (only for metric="custom"). Must be a valid SELECT statement, e.g. "SELECT properties.$pathname as path, count() as views FROM events WHERE event = '$pageview' GROUP BY path ORDER BY views DESC LIMIT 10". Do NOT pass natural language — this is sent directly to the PostHog query API. | |
| on_behalf_of | No | An agency client's email, from list_agency_clients, to run this call in that client's account: their agents, settings, connected accounts, and credits. Omit it to act on your own account. |