exploring-autocapture-events
Skill này làm gì
Skill này khám phá các sự kiện tự động ghi nhận click, gửi biểu mẫu và thay đổi trang mà PostHog ghi lại từ website của bạn. Nó dành cho nhà phân tích và nhóm sản phẩm muốn biết người dùng nhấp vào đâu và muốn tạo hành động từ các click đó.
Khi nào nên dùng
- ✓Khi bạn muốn biết người dùng đang nhấp vào gì trên website của mình.
- ✓Khi bạn cần một CSS selector đáng tin cậy cho một nút hoặc liên kết để tạo hành động.
- ✓Khi bạn muốn tạo một hành động từ một click mà không cần viết mã.
Liên kết skill
https://github.com/PostHog/posthog/blob/master/products/product_analytics/skills/exploring-autocapture-events/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Người dùng đang nhấp vào gì trên trang giá của chúng tôi, và làm sao tạo một selector đáng tin cậy cho nút đăng ký?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill đọc các phần tử được nhấp ghi kèm mỗi sự kiện, kiểm tra xem một selector chỉ khớp với đúng một phần tử hay không, và chạy truy vấn trên các click khớp. Sau đó, skill có thể giúp bạn tạo một hành động.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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
Câu hỏi thường gặp
Autocapture ghi lại những gì?
Khi website bật tính năng này, nó ghi lại các click, lần gửi biểu mẫu và thay đổi trang dưới dạng sự kiện autocapture.
Chuỗi phần tử là gì?
Đó là bản ghi về phần tử được nhấp và các phần tử cha của nó, mà skill đọc để tìm selector.
Vì sao skill kiểm tra selector có duy nhất không?
Một selector khớp nhiều phần tử sẽ đếm những click mà bạn không định theo dõi, nên skill kiểm tra từng selector trước.
Chi tiết
Mô tả gốc của tác giả
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
Độ phổ biến
- Sao GitHub
- 41k
- Vị trí xếp hạng
- #6902
- Giấy phép
- —
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
depot-ci
41kGiúp agent của bạn thiết lập và chạy quy trình Depot CI, một lựa chọn thay thế GitHub Actions, gồm chuyển các quy trình hiện có và đọc nhật ký chạy.
depot-container-builds
41kGiúp agent của bạn build image Docker trên các builder từ xa của Depot, gồm image đa nền tảng, đẩy lên registry và sửa lỗi build.
depot-github-runners
41kGiúp agent của bạn chuyển các job GitHub Actions sang runner do Depot quản lý, chọn kích thước và nhãn runner, và xử lý lỗi thiết lập runner.
editing-agents-md
41kGiúp agent của bạn quyết định một quy tắc nên nằm trong file AGENTS.md hay CLAUDE.md, và viết sao cho quy tắc được tuân thủ mà file không bị phình to.
Skill tương tự
gitcrawl
394kCho phép agent của bạn tìm trong kho lưu trữ issue và pull request GitHub, gom các mục trùng lặp và kiểm tra trạng thái hiện tại trên GitHub.
slacrawl
394kCho phép agent của bạn tìm và đếm tin nhắn trong kho lưu trữ Slack cục bộ, kiểm tra kho đó mới đến mức nào và làm mới khi cần.
goplaces
394kGiúp agent của bạn tìm địa điểm, lấy chi tiết và đánh giá, và xác định tên địa điểm bằng Google Places, với đầu ra JSON cho script.