name: product-analytics description: 与产品分析平台深度集成,用于指标、漏斗、留存和实验分析。查询Amplitude/Mixpanel/Heap数据,生成留存曲线,计算转化指标,并构建仪表板配置。 allowed-tools: Read, Grep, Write, Bash, Edit, Glob
产品分析技能
查询和分析产品分析数据,用于指标定义、漏斗分析、留存曲线和实验跟踪。
概述
此技能提供了与产品分析平台协作的全面能力。它通过指标查询、漏斗分析、群组留存跟踪和仪表板生成,支持数据驱动的产品决策。
能力
分析平台集成
- 查询Amplitude、Mixpanel、Heap、GA4数据
- 执行自定义事件查询
- 拉取预定义报告数据
- 同步指标定义
漏斗分析
- 定义和计算转化漏斗
- 识别流失点和摩擦点
- 按用户属性细分漏斗
- 比较不同时间的漏斗表现
留存分析
- 生成留存曲线和矩阵
- 计算群组留存率
- 按用户细分分析留存
- 识别留存驱动因素和预测因子
指标定义
- 定义北极星指标和支持指标
- 创建事件跟踪规范
- 记录指标计算方式
- 构建指标层次结构(树)
仪表板配置
- 生成仪表板布局
- 配置图表规范
- 定义告警阈值
- 导出仪表板配置
先决条件
分析平台访问
支持的平台:
- Amplitude(需要API密钥)
- Mixpanel(服务账户)
- Heap(API访问权限)
- Google Analytics 4(BigQuery导出)
- Posthog(API密钥)
配置
{
"platform": "amplitude",
"credentials": {
"api_key": "${AMPLITUDE_API_KEY}",
"secret_key": "${AMPLITUDE_SECRET_KEY}"
},
"project_id": "123456",
"timezone": "America/Los_Angeles"
}
使用模式
漏斗分析查询
## 漏斗定义
### 漏斗:注册到首次价值实现
**步骤**:
1. 页面浏览:/signup
2. 事件:signup_started
3. 事件:signup_completed
4. 事件:first_action_completed
**过滤器**:
- 平台:web
- 日期范围:最近30天
- 仅新用户
**细分**:
- 按流量来源
- 按设备类型
漏斗查询示例(Amplitude风格)
# 漏斗分析查询
funnel_config = {
"events": [
{"event_type": "signup_started"},
{"event_type": "signup_completed"},
{"event_type": "onboarding_completed"},
{"event_type": "first_value_action"}
],
"filters": {
"platform": ["web", "ios", "android"],
"date_range": {
"start": "2026-01-01",
"end": "2026-01-24"
}
},
"conversion_window": "7天",
"group_by": ["platform", "utm_source"]
}
# 预期输出格式
funnel_results = {
"overall": {
"step_1": {"users": 10000, "rate": 1.0},
"step_2": {"users": 6500, "rate": 0.65},
"step_3": {"users": 4200, "rate": 0.65},
"step_4": {"users": 2100, "rate": 0.50}
},
"overall_conversion": 0.21,
"segments": {
"web": {"conversion": 0.18},
"ios": {"conversion": 0.25},
"android": {"conversion": 0.19}
}
}
留存分析
## 留存查询
### 群组定义
- **群组划分依据**:signup_date(按周)
- **留存事件**:any_active_event
- **时间周期**:第1天、7天、14天、30天、60天、90天
### 输出:留存矩阵
| 群组周 | 用户数 | D1 | D7 | D14 | D30 | D60 | D90 |
|-------------|-------|-----|-----|-----|-----|-----|-----|
| 1月1-7日 | 1000 | 45% | 30% | 25% | 20% | 15% | 12% |
| 1月8-14日 | 1200 | 48% | 32% | 27% | 22% | - | - |
| 1月15-21日 | 1100 | 46% | 31% | - | - | - | - |
留存查询示例
# 留存分析配置
retention_config = {
"cohort_definition": {
"event": "signup_completed",
"grouping": "week"
},
"retention_event": {
"event_type": "any_active",
"conditions": ["page_view", "feature_used", "content_created"]
},
"periods": [1, 7, 14, 30, 60, 90],
"date_range": {
"start": "2025-10-01",
"end": "2026-01-24"
},
"segments": ["subscription_tier", "signup_source"]
}
# 预期输出
retention_results = {
"retention_matrix": [
{
"cohort": "2025-W40",
"cohort_size": 1000,
"retention": {
"D1": 0.45,
"D7": 0.30,
"D14": 0.25,
"D30": 0.20,
"D60": 0.15,
"D90": 0.12
}
}
],
"averages": {
"D1": 0.46,
"D7": 0.31,
"D14": 0.26,
"D30": 0.21,
"D60": 0.16,
"D90": 0.13
},
"trends": {
"D30_trend": "+2%", # 与上一周期相比
"D7_trend": "-1%"
}
}
指标定义规范
## 指标规范模板
### 指标:周活跃用户(WAU)
**定义**:在7天周期内执行至少一项合格操作的独立用户。
**计算**:
```sql
SELECT COUNT(DISTINCT user_id)
FROM events
WHERE event_type IN ('page_view', 'feature_used', 'content_created')
AND event_timestamp >= CURRENT_DATE - INTERVAL '7 days'
合格事件:
- page_view(任何页面)
- feature_used
- content_created
- content_shared
排除项:
- 机器人流量(user_agent过滤器)
- 内部用户(邮箱域名过滤器)
细分:
- 按平台(web, ios, android)
- 按订阅等级
- 按注册群组
告警:
- 警告:周环比下降>5%
- 严重:周环比下降>10%
### 事件跟踪规范
```json
{
"event_name": "feature_used",
"description": "用户与产品功能交互",
"category": "engagement",
"properties": {
"feature_name": {
"type": "string",
"required": true,
"description": "使用的功能名称",
"examples": ["search", "export", "share"]
},
"feature_version": {
"type": "string",
"required": false,
"description": "功能版本"
},
"action": {
"type": "string",
"required": true,
"enum": ["click", "view", "complete", "cancel"]
},
"duration_ms": {
"type": "integer",
"required": false,
"description": "在功能上花费的时间"
}
},
"user_properties": {
"subscription_tier": "string",
"signup_date": "date"
}
}
与Babysitter SDK集成
任务定义示例
const analyticsQueryTask = defineTask({
name: 'analytics-query',
description: '查询产品分析数据',
inputs: {
queryType: { type: 'string', required: true }, // funnel, retention, metric
config: { type: 'object', required: true },
platform: { type: 'string', default: 'amplitude' },
dateRange: { type: 'object', required: true }
},
outputs: {
results: { type: 'object' },
visualizations: { type: 'array' },
insights: { type: 'array' }
},
async run(inputs, taskCtx) {
return {
kind: 'skill',
title: `运行${inputs.queryType}分析`,
skill: {
name: 'product-analytics',
context: {
operation: inputs.queryType,
config: inputs.config,
platform: inputs.platform,
dateRange: inputs.dateRange
}
},
io: {
inputJsonPath: `tasks/${taskCtx.effectId}/input.json`,
outputJsonPath: `tasks/${taskCtx.effectId}/result.json`
}
};
}
});
仪表板配置
仪表板规范
{
"dashboard_name": "产品健康仪表板",
"refresh_interval": "1h",
"layout": {
"columns": 3,
"rows": 4
},
"widgets": [
{
"id": "wau_trend",
"type": "line_chart",
"position": {"row": 1, "col": 1, "width": 2},
"metric": "weekly_active_users",
"time_range": "90d",
"comparison": "previous_period"
},
{
"id": "retention_heatmap",
"type": "heatmap",
"position": {"row": 1, "col": 3, "width": 1},
"metric": "cohort_retention",
"periods": [1, 7, 30]
},
{
"id": "funnel_chart",
"type": "funnel",
"position": {"row": 2, "col": 1, "width": 3},
"funnel_id": "signup_to_activation",
"segments": ["platform"]
}
],
"alerts": [
{
"metric": "weekly_active_users",
"condition": "decrease_percent > 5",
"severity": "warning",
"notification": "slack"
}
]
}
输出格式
漏斗分析报告
# 漏斗分析报告:注册到首次价值实现
## 概述
- **周期**:2026年1月1日-24日
- **总用户数**:10,000
- **整体转化率**:21%
## 逐步分析
| 步骤 | 事件 | 用户数 | 转化率 | 流失率 |
|------|-------|-------|-----------|----------|
| 1 | signup_started | 10,000 | 100% | - |
| 2 | signup_completed | 6,500 | 65% | 35% |
| 3 | onboarding_completed | 4,200 | 65% | 35% |
| 4 | first_value_action | 2,100 | 50% | 50% |
## 关键洞察
1. **最大流失点**:第4步(从引导到首次价值实现)- 50%流失
2. **表现最佳细分**:iOS用户(25%整体转化率)
3. **机会点**:移动端引导流程优化
## 建议
1. 简化首次价值实现的操作指引
2. 在引导过程中添加进度指示器
3. 对第3步流失用户实施重新参与策略
最佳实践
- 明确定义指标:记录计算逻辑和边界情况
- 使用一致时区:所有查询对齐到单一时区
- 全面细分分析:始终按关键用户细分进行分析
- 验证数据质量:检查跟踪缺口和异常
- 版本化事件模式:跟踪事件定义的变更
- 设置合适的告警:通过有意义的阈值避免告警疲劳