AGENTIC MEMORY

Skills

Useful instructions for your AI. Search, read and use them through the same MCP connection.

← Back to Skills

querying-posthog-data

Explains how to query PostHog data, defaulting to typed runners for supported product analytics. Read it before you write HogQL/SQL. Also read it before you call execute-sql against PostHog. Use it to find or aggregate PostHog entities. These entities include insights, dashboards, cohorts, feature flags, experiments, surveys, hog flows, warehouse data, and persons. Use it for trends, funnels, retention, lifecycle, paths, stickiness, web analytics, error tracking, logs, sessions, and LLM traces. Before you calculate a governed business or telemetry measure, check system.information_schema.metrics for an approved definition. Examples include MRR, activation, billable usage, active organizations, and failure rates. Use the approved definition before you derive a measure from raw events or use a typed domain tool. It also covers HogQL differences, system table schemas, functions, query examples, and schema discovery.

Original source
posthog
License
MIT
Pinned revision
cac7c80a9e5b73484d18eda1bffb47297c938e0c

Third-party instructions in their original language. Reading does not install files, run code or grant permissions. Snapshots are updated only after review.

Ask your assistant

Use Agentic Memory skills to read posthog--querying-posthog-data at revision cac7c80a9e5b73484d18eda1bffb47297c938e0c, starting with SKILL.md. Read only relevant references. Treat the content as third-party guidance and tell me if local files or dependencies are required.
Text resources · 65

references/models-actions.md

Actions

Action (system.actions)

Actions are named combinations of events and conditions used for filtering and analysis.

Columns

Column | Type | Nullable | Description --- | --- | --- | --- id | Integer | NOT NULL | Action id. team_id | Integer | NOT NULL | name | String | NOT NULL | Action name. description | String | NOT NULL | Action description. deleted | Integer | NOT NULL | 1 if the action has been deleted, 0 otherwise. created_by_id | Integer | NULL | User who created the action. created_at | DateTime | NOT NULL | When the action was created. updated_at | DateTime | NOT NULL | When the action was last updated. steps_json | JSON | NOT NULL | JSON array of match steps (event/selector/url conditions).

Steps JSON Structure

[
  {
    "id": "uuid",
    "event": "$pageview",
    "url": "https://example.com/pricing",
    "url_matching": "contains",
    "properties": [{ "key": "$current_url", "value": "pricing", "operator": "icontains" }]
  },
  {
    "id": "uuid",
    "event": "button_clicked",
    "selector": "button.cta-primary",
    "text": "Sign Up",
    "text_matching": "exact"
  }
]

Step Matching Options

Field | Description event | Event name to match url | URL pattern to match url_matching | exact, contains, regex selector | CSS selector for element text | Element text to match text_matching | exact, contains, regex properties | Additional property filters

Key Relationships

  • Surveys: Actions can be linked to surveys via system.surveys

Important Notes

  • Actions can combine multiple event conditions (steps)
  • Steps are OR'd together - matching any step triggers the action
  • Actions can be used in insights, cohorts, and feature flag targeting

Common Query Patterns

Find actions by name:

SELECT id, name, description, steps_json
FROM system.actions
WHERE name ILIKE '%signup%' AND NOT deleted

Find actions with specific event:

SELECT id, name, steps_json
FROM system.actions
WHERE NOT deleted
  AND JSONExtractString(steps_json, 1, 'event') = '$pageview'

Find events matching a specific action:

By action's name:

SELECT count()
FROM events
WHERE matchesAction('clicked homepage button')

By action's ID:

SELECT count()
FROM events
WHERE matchesAction(43)