> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# Lead Tracker — 计算配置

> **Source of truth**: `studio-website-monorepo/apps/api/src/routes/v3/dashboard-lead-tracker.ts`
> **last\_verified**: 2026-05-29

Lead Tracker 数据来自 `GET /v3/dashboard/lead-tracker?storeId=...&period=rolling-7d|last-week|last-month`。采用 cohort 方式：先找到选定时段内的入站 lead，再追踪这批 lead 的后续转化。

***

## Speed to Lead

从 lead 首次入站通话到首次外呼回复的响应时间。

| 指标            | 产品定义                                  | SQL 口径                                                                                | 状态     |
| ------------- | ------------------------------------- | ------------------------------------------------------------------------------------- | ------ |
| 中位响应时间        | lead 首次 inbound → 首次 outbound 的分钟数中位数 | `PERCENTILE_CONT(0.5)` on `EXTRACT(EPOCH FROM (first_response - first_inbound)) / 60` | ✅ 已接线  |
| 平均响应时间        | 同上，取均值                                | `ROUND(AVG(...))`                                                                     | ✅ 已接线  |
| 分布            | 4 档时间桶                                | `<= 900s` / `900-3600s` / `3600-7200s` / `> 7200s`                                    | ✅ 已接线  |
| Not Attempted | 有 inbound 但 7 天内无 outbound 的 lead 数   | `received - total_contacted`（前端计算）                                                    | ✅ 前端计算 |

> **7 天窗口**：只查 lead inbound 后 7 天内的 outbound 作为 "首次回复"。超过 7 天的不计入 speed 统计。

***

## 漏斗

Cohort 追踪：选定时段内首次出现的 lead，追踪同一批 lead 的转化。

| 阶段             | 产品定义                                                                                                                                       | SQL 口径                                                                                                                                                                                                   | 状态     |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ |
| Received       | 选定时段内有 inbound intro 通话的独立 contact\_phone 数（基于 `calls` 表 cohort，不是 `contacts.lifecycle_stage`）                                             | `COUNT(DISTINCT contact_phone) WHERE direction = 'Inbound' AND (primary_subcategory = 'intro_booking' OR lead_id IS NOT NULL) AND call_state IS DISTINCT FROM 'voicemail' AND contact_phone IS NOT NULL` | ✅ 已接线  |
| First Outreach | Received 中有任何 outbound 通话的数量                                                                                                               | `EXISTS outbound call for same contact_phone in period`                                                                                                                                                  | ✅ 已接线  |
| Booked Intro   | First Outreach 中有 `primary_subcategory = 'intro_booking'` + `primary_outcome_result = 'success'` 的数量（不是 `contacts.lead_status = 'booked'`） | `EXISTS primary_subcategory = 'intro_booking' AND primary_outcome_result = 'success'`                                                                                                                    | ✅ 已接线  |
| Contacted（接通）  | Outreach 中实际接通的数量                                                                                                                          | 当前 endpoint 的 "contacted" = 有 outbound call，不区分接通                                                                                                                                                        | ⚠️ 待开发 |

> **3 层 vs 4 层**：当前后端实现是 3 层（Received → Contacted → Booked）。endpoint 里的 `contacted` 实际等同于 "有 outbound call"（即 outreach），不区分是否接通。4 层漏斗需后端增加接通判断逻辑。

### 转化率

| 指标                 | 公式                         | 状态    |
| ------------------ | -------------------------- | ----- |
| Contact Rate       | contacted / received × 100 | ✅ 已接线 |
| Book Rate          | booked / contacted × 100   | ✅ 已接线 |
| Overall Conversion | booked / received × 100    | ✅ 已接线 |

***

## 趋势

同时查询上期（同长度前一时段）的漏斗数据，计算 delta。
