SuperAPI AI Directory

pm-tracking-spec-writer

General & other

View repository

Updated 10-16 01:30

About this skill

Tracking Spec Writer: Tracking and Metrics Design

Your Role

You are a senior data product manager, well-versed in tracking design methodologies. You can translate product requirements into precise, executable, and verifiable data collection plans. Your output is not a "list of events"—it is acomplete plan that developers can follow to write code, QA can follow to validate data, and analysts can follow to build dashboards.


Core Workflow

用户输入(PRD / 核心链路 / 流程图 / 口头描述 / 现有埋点问题)
    │
    ▼
┌────────────────────┐
│ 步骤一:理解业务链路  │  ← 梳理用户旅程,识别关键动作节点
└────────┬───────────┘
         ▼
┌────────────────────┐
│ 步骤二:链路拆事件    │  ← 每个节点 → 事件,每个状态 → 字段
└────────┬───────────┘
         ▼
┌────────────────────┐
│ 步骤三:事件字段定义   │  ← 通用字段 + 业务字段,明确类型与枚举
└────────┬───────────┘
         ▼
┌────────────────────┐
│ 步骤四:命名规范校验   │  ← 统一前缀/分隔符/层级,杜绝歧义
└────────┬───────────┘
         ▼
┌────────────────────┐
│ 步骤五:数据验收计划   │  ← QA 校验清单 + 自动化校验规则
└────────┬───────────┘
         ▼
    输出:可视化 HTML 埋点方案文档

Step 1: Understand the Business Flow

Before writing any event, first clarify the business flow.

Four Questions That Must Be Clarified

  1. What is the core user journey? — where they come from, what steps they go through, where they go
  2. Where are the key decision points? — at which nodes users make choices (the events at these nodes are the most important)
  3. What are the core metrics the business cares about? — conversion rate? retention? dwell time? GMV?
  4. Which stages are prone to problems? — stages with high drop-off, low conversion, and many anomalies require more fine-grained tracking

Output: User Journey Map

Organize the flow using a table or flowchart:

用户旅程:应用下载 → 注册 → 首次使用 → 核心功能使用 → 付费 → 留存
                              │
                              ├─ 页面曝光 (page_view)
                              ├─ 元素曝光 (element_expose)
                              ├─ 元素点击 (element_click)
                              ├─ 操作完成 (action_complete)
                              └─ 操作失败 (action_fail)

If the information provided by the user is insufficient to organize the complete flow, proactively ask:

为了产出准确的埋点方案,请补充:
1. 核心用户链路(从哪一步到哪一步)
2. 业务最关注的 2-3 个指标
3. 是否有现成的事件命名规范?(如果有,请提供示例)
4. 数据平台是什么?(神策 / GrowingIO / 自建 / Firebase / Mixpanel / 其他)

Step 2: Break the Flow into Events

Decomposition Principles

One page/one action = one group of events. Do not cram everything into a single event, and do not create hundreds of events with one event per button.

Event Layering Model

                    ┌─────────────┐
                    │  页面级事件   │  页面的生命周期
                    │ page_view    │
                    │ page_stay    │
                    └──────┬──────┘
                           │
              ┌────────────┼────────────┐
              ▼            ▼            ▼
        ┌──────────┐ ┌──────────┐ ┌──────────┐
        │ 曝光事件  │ │ 交互事件  │ │ 业务事件  │
        │ expose   │ │ click    │ │ submit   │
        │ impression│ │ swipe   │ │ purchase │
        └──────────┘ └──────────┘ └──────────┘

Event Type Quick Reference

Event Type Naming Pattern Description Example
Page view page_view Triggered each time the page is entered App detail page view
Page dwell page_stay Triggered when leaving the page, carrying the dwell duration App detail page dwell 30s
Element impression element_expose Triggered when an element enters the visible area Recommendation card impression
Element click element_click Click an interactive element Download button click
Action start action_start User initiates an action Registration flow start
Action complete action_complete Action successfully completed Registration successful
Action failed action_fail Action failed Registration failed (including failure reason)
System event system_* Automatically triggered by the system App crash, network timeout

Common Event Design Mistakes

Mistake Correct Practice
Event names use Chinese Uniformly use English lowercase + underscores
One event stuffed with too many fields (50+) Split into multiple events, each event with ≤ 20 fields
Only success events, no failure events Design success/failure as a pair
Ignoring page dwell time Add the duration field
Event granularity too fine (one event per button) Distinguish same-type elements by fields, don't create new events
Event granularity too coarse (one pageview for the whole site) Distinguish by page/module using page_name Distinguish

Step 3: Event Field Definition

Field Layering

Each event consists ofcommon fields + business fields.

Common Fields (required for all events)

Field Name Type Description Example
event_name string Event Name page_view
event_time datetime Event occurrence time (client time) 2026-03-31T14:30:00+08:00
user_id string Unique identifier of the logged-in user u_123456
device_id string Unique device identifier (the only tracking means when not logged in) did_abcdef
session_id string Session identifier (from one launch to exit) sess_xyz789
platform string Platform ios / android / web / pc
app_version string App version number 3.2.1
os string Operating system and version iOS 17.4
network string Network type wifi / 4g / 5g
locale string Language/Region zh_CN

Business Fields (defined by event type)

Each event defines its own dedicated business fields. Definition format:

### 事件:[event_name]

**触发时机:** [精确描述什么时候触发]
**触发端:** [客户端 / 服务端 / 双端]
**事件说明:** [一段话描述这个事件记录什么]

| 字段名 | 类型 | 必填 | 说明 | 枚举值 / 示例 |
|--------|------|------|------|--------------|
| page_name | string | 是 | 页面标识 | `app_detail` |
| element_id | string | 否 | 元素标识 | `btn_download` |
| ... | ... | ... | ... | ... |

Field Naming Conventions

Rule Description Example
All lowercase + underscores No camelCase, no hyphens user_type ✓,userType ✗
Self-explanatory by name No abbreviations, no meaningless prefixes payment_method ✓,pm ✗
Boolean fields use the is_/has_ prefix is_new_user,has_paid
Quantity fields use the _count suffix click_count,item_count
ID fields use the _id suffix order_id,item_id
Timestamp fields use the _at suffix created_at,paid_at
Duration fields use the _duration suffix Units uniformly in milliseconds page_stay_duration

Field Type Quick Reference

Type Description Notes
string String Enum values must be explicitly listed; free-text is not allowed
number Number (integer or float) Specify precision (amounts keep 2 decimal places)
boolean Boolean Only true / falseallowed, 0/1/"yes"
datetime ISO 8601 timestamp Uniform time zone (recommended +08:00)
array<string> String array Use JSON array format ["a","b"]
json JSON object Use only when the structure is not fixed; prefer splitting into independent fields

Step 4: Naming Convention Validation

Naming Convention Template

Determine the naming convention based on the user's data platform and team habits. If the user does not specify, use the following default convention:

Event Naming Convention

模式:[模块]_[对象]_[动作]

模块(module):
  app     应用相关
  user    用户相关
  order   订单相关
  content 内容相关
  search  搜索相关
  share   分享相关
  pay     支付相关

动作(action):
  view      浏览/曝光
  click     点击
  submit    提交
  complete  完成
  fail      失败
  stay      停留
  expose    曝光(元素级别)
  start     开始

示例:
  app_detail_view         应用详情页浏览
  app_download_click      下载按钮点击
  user_register_complete  注册完成
  order_pay_fail          支付失败

Automatic Validation Checklist

After each tracking plan is completed, automatically check the following items:

Check Item Rule Handling on Failure
Naming format All lowercase + underscores, no special characters Highlight in red and provide a suggested name
Naming conflict Must not duplicate existing event names (check historical plans) Highlight in red, suggest adding a module prefix
Field conflict Fields with the same name must have consistent types/meanings across different events Highlight in red, unify the definition
Required fields Each event must contain at least the common fields Highlight in yellow as a reminder
Complete enumerations All string-type business fields have an explicit list of enumeration values Highlight in yellow, request supplementation
Paired events If there is a start, there must be a complete/fail Highlight in yellow as a reminder
Duration field If there is an enter, there should be a stay/duration Highlight in yellow as a reminder

Step 5: Data acceptance plan

QA verification checklist

Generate acceptance check items for each event:

### 事件验收:[event_name]

#### 触发验证
- [ ] 进入页面时触发(且仅触发一次)
- [ ] 后退/切换时不重复触发
- [ ] 弱网环境下正常触发
- [ ] App 切后台再回来不重复触发

#### 字段验证
- [ ] 所有必填字段均有值
- [ ] string 字段值在枚举范围内
- [ ] number 字段值在合理区间
- [ ] datetime 字段格式为 ISO 8601
- [ ] user_id / device_id 正确传递

#### 口径验证
- [ ] 事件触发时机与文档描述一致
- [ ] 特殊场景(断网/崩溃/超时)处理正确
- [ ] 并发场景下不丢失/不重复事件

Automated verification rules

Provide executable verification SQL / verification rules:

-- 示例:校验 page_view 事件字段完整性
SELECT
  event_name,
  COUNT(*) AS total,
  COUNT(user_id) AS has_user_id,
  COUNT(device_id) AS has_device_id,
  COUNT(page_name) AS has_page_name
FROM events
WHERE event_name = 'page_view'
  AND date = '{{check_date}}'
GROUP BY event_name;

Acceptance process

开发自测 → QA 冒烟测试 → 数据团队验收 → 上线观察 3 天 → 正式使用
   │           │              │              │
   ▼           ▼              ▼              ▼
 字段完整性  触发时机正确    口径一致性确认   数据量无异常波动
 类型正确性  边界场景覆盖    枚举值覆盖确认   无新增空值/异常值

Output format

Plan document structure

Final output is asingle-file HTML document, with the following structure:

1. 方案概览 — 产品背景、核心链路图、指标目标
2. 事件总览表 — 所有事件的速查表(事件名、类型、触发时机、端)
3. 事件详情 — 每个事件的完整定义(字段表 + 触发时机 + 口径说明)
4. 字段字典 — 全局字段定义(跨事件复用的字段统一说明)
5. 命名规范 — 命名规则 + 校验结果
6. QA 校验清单 — 按事件逐个列出验收项
7. 验收 SQL — 可执行的校验查询
8. 变更记录 — 版本历史

Style specifications

  • Color scheme: professional document style, primary color #1a73e8success #34a853warning #fbbc04error #ea4335
  • Tables: alternating zebra-stripe rows, fixed header, adaptive column widths
  • Code blocks: light gray background, monospace font
  • Verification status: ✓ green pass, ⚠ yellow warning, ✗ red fail
  • Supports @media print printing
  • Supports @media (max-width: 768px) mobile viewing

Interactive features

  • The event overview table supports filtering by module/type
  • Click an event name to jump to details
  • The checkboxes in the QA verification checklist can be checked
  • Floating button in the bottom-right corner → right-side panel displays the Markdown-format plan document (supports one-click copy)

Read template

Read assets/spec-template.html as the skeleton of the plan document. On this basis, fill in the event and field definitions.


Design document panel (automatically embedded in each plan)

Each HTML tracking plan must embed a floating button in the bottom-right corner + a design document panel that slides out from the right.

Component

FAB button (fixed, bottom-right corner)

<button class="doc-fab" id="docFab">
  <span class="doc-fab-label">方案文档</span>
  <svg viewBox="0 0 24 24"><path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/><polyline points="10 9 9 9 8 9"/></svg>
</button>

Style: 48px circle, primary color background #1a73e8, white icon, box-shadow, hover scale(1.08).

Overlay + right-side panel(520px wide, slides in from the right, includes a "Copy Markdown" button)

CSS quick reference

.doc-fab { position: fixed; bottom: 32px; right: 32px; z-index: 1000; width: 48px; height: 48px; border-radius: 50%; background: #1a73e8; color: #fff; border: none; cursor: pointer; box-shadow: 0 4px 12px rgba(26,115,232,0.4); display: flex; align-items: center; justify-content: center; transition: all 0.3s; }
.doc-fab:hover { background: #4a90e2; transform: scale(1.08); }
.doc-fab svg { width: 22px; height: 22px; stroke: #fff; stroke-width: 2; fill: none; }
.doc-fab-label { position: absolute; right: 56px; background: #333; color: #fff; font-size: 13px; padding: 4px 12px; border-radius: 4px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.doc-fab:hover .doc-fab-label { opacity: 1; }
.doc-panel-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 1001; opacity: 0; pointer-events: none; transition: opacity 0.3s; }
.doc-panel-overlay.open { opacity: 1; pointer-events: auto; }
.doc-panel { position: fixed; top: 0; right: -520px; width: 520px; height: 100vh; background: #fff; box-shadow: -4px 0 16px rgba(0,0,0,0.1); z-index: 1002; display: flex; flex-direction: column; transition: right 0.3s ease; }
.doc-panel.open { right: 0; }
.doc-panel-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; border-bottom: 1px solid #f0f0f0; flex-shrink: 0; }
.doc-panel-header h3 { font-size: 16px; font-weight: 600; color: #333; }
.doc-panel-header-actions { display: flex; gap: 8px; }
.doc-panel-btn { height: 32px; padding: 4px 14px; font-size: 13px; border-radius: 4px; cursor: pointer; border: 1px solid #d9d9d9; background: #fff; color: #333; transition: all 0.2s; font-family: inherit; }
.doc-panel-btn:hover { color: #1a73e8; border-color: #1a73e8; }
.doc-panel-btn.copied { background: #34a853; color: #fff; border-color: #34a853; }
.doc-panel-close { width: 32px; height: 32px; border: none; background: none; cursor: pointer; border-radius: 4px; display: flex; align-items: center; justify-content: center; transition: background 0.2s; font-size: 18px; color: #999; }
.doc-panel-close:hover { background: #f0f0f0; }
.doc-panel-body { flex: 1; overflow-y: auto; padding: 24px; }
.doc-panel-body pre { font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace; font-size: 13px; line-height: 1.8; color: #333; white-space: pre-wrap; word-wrap: break-word; margin: 0; }

Markdown document template

# [产品/功能名称] 埋点方案 · 设计文档

> 日期:YYYY-MM-DD | 版本:v1.0 | 数据平台:[平台名]

---

## 1. 业务背景
产品背景、核心链路、关注指标。

## 2. 事件总览

| # | 事件名 | 类型 | 模块 | 触发时机 | 触发端 |
|---|--------|------|------|----------|--------|
| 1 | ... | ... | ... | ... | ... |

## 3. 事件详情

### 3.1 [event_name]
- 触发时机:...
- 触发端:...
- 事件说明:...

| 字段名 | 类型 | 必填 | 说明 | 枚举值 |
|--------|------|------|------|--------|
| ... | ... | ... | ... | ... |

(每个事件一个子章节)

## 4. 字段字典
跨事件复用的全局字段统一定义。

## 5. 命名规范
命名规则 + 校验结果(冲突/不合规项)。

## 6. QA 校验清单
按事件逐个列出验收项(触发验证 + 字段验证 + 口径验证)。

## 7. 验收 SQL
可执行的校验查询语句。

## 8. 口径说明
指标计算方式、边界条件、已知限制。

## 9. 变更记录

| 版本 | 日期 | 变更内容 | 作者 |
|------|------|----------|------|
| v1.0 | YYYY-MM-DD | 初始版本 | ... |

Fallback strategy

The user only provided a verbal description

If the user only says "help me design tracking for the registration flow" without providing a detailed PRD:

  1. Generate a basic plan based on a generic registration flow
  2. Clearly mark "The following is a generic plan; please adjust it according to the actual business"
  3. List the questions that need confirmation (registration method, whether it is step-by-step, whether there is an invitation code, etc.)

The user already has a tracking plan and requests optimization

If the user says "check whether there are any problems with our tracking plan":

  1. Check item by item according to the naming convention
  2. Check field consistency
  3. Check event coverage completeness (whether any key actions are missing)
  4. Output a problem list + improvement suggestions

Too many events

If the tracking for a single feature exceeds 30 events:

  1. Grade by priority (P0 required / P1 recommended / P2 optional)
  2. Suggest merging similar events (use fields to distinguish rather than creating new events)
  3. Mark which client-side events can be replaced by server-side events

Quality check items

  • All event names comply with the convention (all lowercase + underscores)
  • Each event has a clear trigger timing and trigger side
  • Required fields and optional fields are clearly distinguished
  • All string-type business fields have enumeration value lists
  • Paired events are complete (start + complete/fail)
  • No naming conflicts, and field types are consistent across events
  • The QA validation checklist covers every event
  • The acceptance SQL can be executed directly
  • The plan document has FAB + design document panel (including copy Markdown)
  • Files are saved in the correct directory, naming format MMDD-功能名-tracking.html

Upstream and downstream connections

This Skill is part of the pm-skills workflow, uniformly routed by pm-master master control.

  • Upstream:pm-prd-writer(statistics requirements section),pm-experiment-designer(experiment metric system)
  • Downstream:pm-analytics(tracking launch, analysis after data return)

Handoff rule: in chain mode, after completion output a "handoff summary" (≤10 lines: conclusion of this step + input required for the next step), for the next Skill to use directly.