AGENTIC MEMORY

Skills

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

← Back to Skills

exploring-autocapture-events

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 autocapture.

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--exploring-autocapture-events 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 · 3

references/elements-chain-format.md

elements_chain format

The elements_chain column stores the clicked DOM element and its ancestors as a single string.

Structure

tag_name.class1.class2:key1="value1":key2="value2";parent_tag.parent_class:key="val"
  • Elements are separated by ; (semicolons)
  • First element is the clicked element, subsequent elements are ancestors up the DOM tree
  • Each element starts with tag_name optionally followed by .class segments (sorted alphabetically)
  • After the tag/class portion, key-value attributes follow as :key="value" pairs
  • Quotes within values are escaped as \"

Standard attribute keys

| Key | Description | | ------------- | ------------------------------------------------- | | text | Inner text content of the element | | href | Link href attribute | | attr_id | HTML id attribute | | nth-child | Position among siblings | | nth-of-type | Position among siblings of the same type | | attr_class | CSS classes (also encoded in the .class prefix) |

Custom attributes

Custom DOM attributes appear verbatim in the chain. The most useful for analytics are data-* attributes:

  • data-attr — PostHog's default data attribute (configurable per team)
  • data-testid — common testing attribute, also useful for analytics
  • aria-label — accessibility label, sometimes useful as a selector

Example chain with a data-attr:

button.btn.primary:data-attr="checkout":text="Buy Now";div.container:attr_id="main"

How CSS selectors map to regex

PostHog converts CSS selectors to regex patterns matched against elements_chain:

  • button → (^|;)button(\.|$|;|:)
  • button.cta → (^|;)button.*?cta.*?
  • #submit → uses indexOf(elements_chain_ids, 'submit') > 0 (optimized)
  • [data-attr="checkout"] → (^|;).*?data-attr="checkout".*?
  • button[data-attr="checkout"] → (^|;)button.*?data-attr="checkout".*?

In HogQL, use elements_chain =~ '{regex}' for matching.