exploring-autocapture-events
What it does
This skill explores the automatic click, form and page change events that PostHog records from your website. It is for analysts and product teams who want to know what users click and who want to build actions from those clicks.
When to use it
- βWhen you want to find out what users are clicking on your website.
- βWhen you need a reliable CSS selector for a button or link to build an action.
- βWhen you want to build an action from a click without writing code.
Skill link
https://github.com/PostHog/posthog/blob/master/products/product_analytics/skills/exploring-autocapture-events/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βWhat are users clicking on our pricing page, and how can I make a reliable selector for the signup button?β
5 new skills a week. 1 minute to read.
How it works
It reads the clicked elements recorded with each event, checks whether a selector matches only one element, and runs queries on matching clicks. It can then help you create an action.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Exploring autocapture events
if users opt in then posthog-js automatically captures clicks, form submissions, and page changes as $autocapture events.
Each event records the clicked DOM element and its ancestors in the elements_chain column.
$autocapture is intentionally excluded from the posthog:read-data-schema taxonomy
because it is only useful with autocapture-specific filters (selector, tag, text, href).
This skill fills that gap.
Materialized columns
The events table provides fast access to common element fields without parsing the full chain string.
| Column | Type | Description |
|---|---|---|
elements_chain |
String | Full semicolon-separated element chain (see format reference) |
elements_chain_href |
String | Last href value from the chain |
elements_chain_texts |
Array(String) | All text values from elements |
elements_chain_ids |
Array(String) | All id attribute values |
elements_chain_elements |
Array(String) | Useful tag names: a, button, input, select, textarea, label |
Use materialized columns for exploration queries whenever possible β they avoid regex parsing.
Canonical autocapture properties
Every $autocapture event from posthog-js ships with a fixed set of properties.
Do not query the schema to "look them up" β they are these:
| Property | Examples | Notes |
|---|---|---|
$event_type |
click, submit, change |
the kind of interaction |
$el_text |
Sign up, Submit |
text of the clicked element |
$current_url |
https://app.example.com/pricing |
page the interaction happened on |
$elements_chain |
semicolon-separated chain | parsed via the elements_chain* materialized columns above |
Standard event properties ($browser, $os, $device_type, etc.) are also present.
Workflow
1. Confirm autocapture data exists
Run a count query before doing anything else. If the count is zero, autocapture may be disabled. There are two ways this happens:
- Project settings β the team can set
autocapture_opt_outin PostHog project settings - SDK config β the posthog-js
init()call can passautocapture: false
Tell the user if no data is found so they can check both settings.
SELECT count() as cnt
FROM events
WHERE event = '$autocapture'
AND timestamp > now() - INTERVAL 7 DAY
2. Explore what users are interacting with
Start broad using the materialized columns. The goal is to understand what users are clicking before narrowing down.
Useful explorations:
- Top clicked tag names (via
elements_chain_elements) - Top clicked text values (via
elements_chain_texts) - Top clicked hrefs (via
elements_chain_href) - Raw
elements_chainvalues for a specific page (filtered byproperties.$current_url)
See example queries for all patterns.
3. Find candidate selectors
Once the user identifies an interaction they care about, find a CSS selector that identifies it.
Priority order for selector attributes (best first):
data-attror otherdata-*attributes β highest specificity, stable across deploys, developer-intended anchors. Search withmatch(elements_chain, 'data-attr=')orextractAll.- Element ID (
attr_id) β also highly stable, queryable viaelements_chain_ids. - Tag + class combination β moderately stable but classes change with CSS refactors.
- Text content β fragile (changes with copy edits, i18n) but sometimes the only option.
- Tag name alone β too broad on its own, useful as a qualifier.
When a
FAQ
What does autocapture record?
When the website has it turned on, it records clicks, form submissions and page changes as autocapture events.
What is the elements chain?
It is the record of the clicked element and its parents, which the skill reads to find selectors.
Why does the skill check selectors for uniqueness?
A selector that matches many elements would count clicks you did not mean to track, so the skill checks each selector first.
Details
Original description by the author
Guides exploration of $autocapture events captured by posthog-js to understand user interactions, find CSS selectors (especially data-attr attributes), evaluate selector uniqueness, query matching clicks ad-hoc, and create actions. Use when the user asks about autocapture data, wants to find what users are clicking, needs to build actions from click events, asks about elements_chain, wants to build a trend or funnel filtered by clicks or other autocapture interactions, asks which properties autocapture sends, or asks how to filter $autocapture events. Only applies to projects using posthog-js
repo: PostHog/posthog
Popularity
- GitHub stars
- 41k
- Ranking position
- #6902
- License
- β
- Updated
- 11/2/2026
Comments
- β¦
More skills from this repository
depot-ci
41kHelps your agent set up and run Depot CI workflows, a GitHub Actions alternative, including migrating existing workflows and reading run logs.
depot-container-builds
41kHelps your agent build Docker images on Depot's remote builders, including multi-platform images, pushing to registries, and fixing build failures.
depot-github-runners
41kHelps your agent move GitHub Actions jobs to Depot-managed runners, choosing runner sizes and labels, and troubleshooting runner setup issues.
editing-agents-md
41kHelps your agent decide whether a rule belongs in an AGENTS.md or CLAUDE.md file, and write it so it sticks without bloating the file.
Similar skills
gitcrawl
394kLets your agent search a saved archive of GitHub issues and pull requests, group duplicates, and check their current status on GitHub.
slacrawl
394kLets your agent search and count messages in a local Slack archive, check how fresh that archive is, and refresh it when needed.
goplaces
394kHelps your agent search for places, get their details and reviews, and resolve place names using Google Places, with JSON output for scripts.