Setup
On first use, read setup.md for integration guidelines.
When to Use
User needs product analytics from Mixpanel. Agent handles event queries, funnel analysis, retention cohorts, user segmentation, and profile lookups.
Architecture
Memory lives in ~/mixpanel/. See memory-template.md for structure.
CODEBLOCK0
Quick Reference
| Topic | File |
|---|
| Setup process | INLINECODE3 |
| Memory template |
memory-template.md |
Core Rules
1. Authentication
Requires a Mixpanel Service Account:
CODEBLOCK1
Create a service account in Mixpanel → Organization Settings → Service Accounts.
2. Query API for Analysis
Use the Query API for insights, funnels, retention:
CODEBLOCK2
3. Funnel Analysis
CODEBLOCK3
4. Retention Cohorts
CODEBLOCK4
5. User Profiles
CODEBLOCK5
6. Export Raw Events
CODEBLOCK6
7. JQL for Complex Queries
CODEBLOCK7
Common Queries
| Goal | Endpoint | Key Params |
|---|
| Event counts | INLINECODE5 | event, type, unit, dates |
| Conversion funnel |
/funnels | events array, dates |
| User retention |
/retention | born_event, event, unit |
| User segments |
/engage | filter
bycohort, properties |
| Raw event export |
/export | dates, event filter |
Mixpanel Traps
- - Wrong date format → use
YYYY-MM-DD, not timestamps - Missing project_id → every Query API call needs it
- Rate limits → 60 requests/hour for free tier, batch queries when possible
- JQL timeouts → queries over 60s fail, add
.take(N) to limit results
External Endpoints
| Endpoint | Data Sent | Purpose |
|---|
| mixpanel.com/api/query/ | Credentials, project ID, query params | Analytics queries |
| data.mixpanel.com/api/2.0/ |
Credentials, project ID, date range | Raw data export |
No other data is sent externally.
Security & Privacy
Data sent to Mixpanel (over HTTPS):
- - Service account credentials for authentication
- Query parameters (event names, date ranges, filters)
- Project ID
Data that stays local:
- - Credentials stored ONLY in environment variables
- Query results cached in ~/mixpanel/
This skill does NOT:
- - Store credentials in memory.md or any file
- Send data to services other than mixpanel.com
- Modify your Mixpanel tracking code or SDK
Trust
By using this skill, analytics data is queried from Mixpanel.
Only install if you trust Mixpanel with your product data.
Related Skills
Install with
clawhub install <slug> if user confirms:
- -
analytics — multi-platform analytics - INLINECODE14 — data processing patterns
- INLINECODE15 — REST API best practices
Feedback
- - If useful: INLINECODE16
- Stay updated: INLINECODE17
设置
首次使用时,请阅读 setup.md 了解集成指南。
使用场景
用户需要来自 Mixpanel 的产品分析数据。代理负责处理事件查询、漏斗分析、留存群组、用户分群和用户画像查询。
架构
数据存储在 ~/mixpanel/ 目录下。结构参考 memory-template.md。
~/mixpanel/
├── memory.md # 项目、已保存查询、洞察
└── queries/ # 已保存的 JQL 查询
快速参考
memory-template.md |
核心规则
1. 身份认证
需要 Mixpanel 服务账号:
bash
export MPSERVICEACCOUNT=your-service-account
export MPSERVICESECRET=your-service-secret
export MPPROJECTID=123456
在 Mixpanel → 组织设置 → 服务账号中创建服务账号。
2. 分析查询 API
使用查询 API 获取洞察、漏斗、留存数据:
bash
BASE=https://mixpanel.com/api/query
AUTH=$(echo -n $MPSERVICEACCOUNT:$MPSERVICESECRET | base64)
洞察查询(事件计数)
curl -s $BASE/insights?project
id=$MPPROJECT_ID \
-H Authorization: Basic $AUTH \
-H Content-Type: application/json \
-d {
params: {
event: [Sign Up, Purchase],
type: general,
unit: day,
from_date: 2024-01-01,
to_date: 2024-01-31
}
} | jq
3. 漏斗分析
bash
curl -s $BASE/funnels?project
id=$MPPROJECT_ID \
-H Authorization: Basic $AUTH \
-H Content-Type: application/json \
-d {
params: {
events: [
{event: Sign Up},
{event: Complete Onboarding},
{event: First Purchase}
],
from_date: 2024-01-01,
to_date: 2024-01-31,
unit: day
}
} | jq .data.meta.overall
4. 留存群组
bash
curl -s $BASE/retention?project
id=$MPPROJECT_ID \
-H Authorization: Basic $AUTH \
-H Content-Type: application/json \
-d {
params: {
born_event: Sign Up,
event: App Open,
from_date: 2024-01-01,
to_date: 2024-01-31,
unit: week,
retention_type: birth
}
} | jq
5. 用户画像
bash
curl -s https://mixpanel.com/api/query/engage?project
id=$MPPROJECT_ID \
-H Authorization: Basic $AUTH \
-H Content-Type: application/json \
-d {
filter
bycohort: {id: 12345},
output_properties: [$email, $name, plan]
} | jq
6. 导出原始事件
bash
curl -s https://data.mixpanel.com/api/2.0/export?project
id=$MPPROJECT_ID \
-H Authorization: Basic $AUTH \
-d from_date=2024-01-01 \
-d to_date=2024-01-07 \
-d event=[\Purchase\]
7. 复杂查询的 JQL
javascript
// Mixpanel JQL(JavaScript 查询语言)
function main() {
return Events({
from_date: 2024-01-01,
to_date: 2024-01-31,
event_selectors: [{event: Purchase}]
})
.groupByUser([properties.$city], mixpanel.reducer.sum(properties.amount))
.groupBy([key.$city], mixpanel.reducer.avg(value))
.sortDesc(value)
.take(10);
}
常见查询
| 目标 | 端点 | 关键参数 |
|---|
| 事件计数 | /insights | event, type, unit, dates |
| 转化漏斗 |
/funnels | events 数组, dates |
| 用户留存 | /retention | born_event, event, unit |
| 用户分群 | /engage | filter
bycohort, properties |
| 原始事件导出 | /export | dates, event 过滤条件 |
Mixpanel 常见陷阱
- - 日期格式错误 → 使用 YYYY-MM-DD,不要用时间戳
- 缺少 project_id → 每次查询 API 调用都需要
- 速率限制 → 免费版每小时 60 次请求,尽量批量查询
- JQL 超时 → 超过 60 秒的查询会失败,添加 .take(N) 限制结果数量
外部端点
| 端点 | 发送数据 | 用途 |
|---|
| mixpanel.com/api/query/ | 凭证、项目 ID、查询参数 | 分析查询 |
| data.mixpanel.com/api/2.0/ |
凭证、项目 ID、日期范围 | 原始数据导出 |
不会向外部发送其他数据。
安全与隐私
发送到 Mixpanel 的数据(通过 HTTPS):
- - 用于身份验证的服务账号凭证
- 查询参数(事件名称、日期范围、过滤条件)
- 项目 ID
本地保留的数据:
- - 凭证仅存储在环境变量中
- 查询结果缓存在 ~/mixpanel/ 目录下
此技能不会:
- - 将凭证存储在 memory.md 或任何文件中
- 向 mixpanel.com 以外的服务发送数据
- 修改您的 Mixpanel 跟踪代码或 SDK
信任声明
使用此技能后,分析数据将从 Mixpanel 查询。
仅当您信任 Mixpanel 处理您的产品数据时才安装。
相关技能
如果用户确认,使用 clawhub install 安装:
- - analytics — 多平台分析
- data-analysis — 数据处理模式
- api — REST API 最佳实践
反馈
- - 如果觉得有用:clawhub star mixpanel
- 保持更新:clawhub sync