exploring-autocapture-events
できること
このスキルは、ウェブサイトからPostHogが自動で記録するクリック、フォーム送信、ページの変化のイベントを調べます。どのクリックが多いかを知りたいアナリストやプロダクトチーム、そのクリックからアクションを作りたい人向けです。
使う場面
- ✓ウェブサイトでユーザーが何をクリックしているかを知りたいとき。
- ✓ボタンやリンクに対して、信頼できる CSS セレクターが必要なとき。
- ✓コードを書かずに、クリックからアクションを作りたいとき。
スキルのリンク
https://github.com/PostHog/posthog/blob/master/products/product_analytics/skills/exploring-autocapture-events/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“料金ページでユーザーが何をクリックしているか教えてください。また、サインアップボタンに信頼できるセレクターを作る方法も教えてください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
各イベントとともに記録されたクリック要素を読み、セレクターが1つの要素だけに一致するかを確認し、一致するクリックに対してクエリを実行します。その後、アクションの作成を手伝えます。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)を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
よくある質問
オートキャプチャは何を記録しますか?
ウェブサイトでオンにされている場合、クリック、フォーム送信、ページの変化を、オートキャプチャのイベントとして記録します。
elements chainとは何ですか?
クリックされた要素とその親要素の記録です。スキルはこれを読んでセレクターを見つけます。
なぜセレクターの一意性を確認するのですか?
多くの要素に一致するセレクターでは、意図していないクリックまで計測してしまうため、スキルは各セレクターを先に確認します。
詳細
作者による元の説明
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
人気
- GitHubのスター
- 41k
- ランキング
- #6902
- ライセンス
- —
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
depot-ci
41kエージェントが、GitHub Actionsの代替であるDepot CIのワークフローを設定し実行できるよう支援します。既存のワークフローの移行や、実行ログの確認も含みます。
depot-container-builds
41kエージェントが、Depotのリモート・ビルダーでDockerイメージを作れるよう支援します。マルチプラットフォームのイメージ、レジストリへのプッシュ、ビルド失敗の修正を含みます。
depot-github-runners
41kエージェントが、GitHub Actionsのジョブを Depot が管理するランナーに移し、ランナーのサイズとラベルを選び、ランナー設定の問題を解決できるよう支援します。
editing-agents-md
41kエージェントが、AGENTS.mdとCLAUDE.mdのどちらにルールを書くべきかを判断し、ファイルを膨らませずに守られやすい形で書けるよう支援します。
似ているスキル
gitcrawl
394k保存されたGitHubのイシューとプルリクエストのアーカイブを検索し、重複をまとめ、GitHub上の現在の状態を確認するようエージェントを支援します。
slacrawl
394kローカルのSlackアーカイブ内のメッセージを検索して件数を数え、アーカイブの新しさを確認し、必要に応じて更新するようエージェントを支援します。
goplaces
394kGoogle Placesを使って、場所を検索し、詳細や口コミを取得し、場所の名前を解決するようエージェントを支援します。スクリプト用にJSON出力もできます。