Amplitude 连接器
通过 Tajo 将 Amplitude 连接到 Brevo,利用产品分析数据驱动营销自动化。同步行为群组、用户属性和产品事件,助力精准活动。
概览
| 属性 | 值 |
|---|---|
| 平台 | Amplitude |
| 类别 | 分析(自定义) |
| 设置复杂度 | 中等 |
| 官方集成 | 否 |
| 同步数据 | 事件、用户、群组、属性 |
| 可用技能 | 6 |
功能
- 事件转发 - 将 Amplitude 追踪事件发送到 Brevo,用于营销自动化触发
- 群组同步 - 将 Amplitude 行为群组导出为 Brevo 联系人列表
- 用户属性同步 - 将 Amplitude 用户属性映射到 Brevo 联系人属性
- 收入跟踪 - 同步收入事件,用于客户终身价值分析
- 行为细分 - 在 Brevo 细分中使用 Amplitude 参与数据
- HTTP V2 API 集成 - 直接与 Amplitude HTTP V2 摄取 API 集成
前提条件
开始之前,请确保您已具备:
- 已创建项目的 Amplitude 账户
- 您的 Amplitude API 密钥和密钥
- 具有 API 访问权限的 Brevo 账户
- 具有 API 凭据的 Tajo 账户
认证
Amplitude API 密钥
Amplitude 使用 API 密钥对进行认证。API 密钥标识您的项目,密钥用于服务端请求认证。
# Find your keys in Amplitude:# Settings > Projects > [Your Project] > GeneralHTTP V2 API 认证
HTTP V2 API 在请求体中使用 API 密钥:
curl -X POST https://api2.amplitude.com/2/httpapi \ -H "Content-Type: application/json" \ -d '{ "api_key": "YOUR_AMPLITUDE_API_KEY", "events": [...] }'配置
基础设置
connectors: amplitude: enabled: true api_key: "your-amplitude-api-key" secret_key: "your-amplitude-secret-key" data_center: "US" # or "EU"
# Data sync options sync: events: true user_properties: true cohorts: true revenue: true
# Brevo list assignment lists: active_users: 10 power_users: 11 churning_users: 12事件映射
将 Amplitude 事件映射到 Brevo 自动化触发器:
event_mapping: # Amplitude event -> Brevo event "Purchase": "order_completed" "Sign Up": "customer_created" "Add to Cart": "cart_updated" "Page View": "page_viewed" "Feature Click": "feature_used"
# Revenue events "Revenue": "revenue_event" "Subscription Started": "subscription_created"用户属性映射
将 Amplitude 用户属性映射到 Brevo 联系人属性:
property_mapping: # Amplitude property -> Brevo attribute email: email first_name: FIRSTNAME last_name: LASTNAME phone: SMS plan_type: PLAN signup_date: SIGNUP_DATE total_purchases: ORDER_COUNT lifetime_revenue: LTV last_active: LAST_ACTIVE device_type: DEVICEAPI 端点
| 方法 | 端点 | 描述 |
|---|---|---|
POST | /2/httpapi | 上传事件(HTTP V2 API) |
POST | /batch | 批量上传事件(批量 API) |
POST | /identify | 设置用户属性 |
POST | /groupidentify | 设置群组属性 |
GET | /2/export | 导出原始事件数据 |
GET | /2/usersearch | 搜索用户 |
GET | /2/useractivity | 获取用户活动时间线 |
POST | /api/3/cohort/export | 导出群组成员 |
GET | /api/3/chart/{chart_id}/query | 查询已保存的图表数据 |
代码示例
初始化 Amplitude 连接器
import { TajoClient } from '@tajo/sdk';
const tajo = new TajoClient({ apiKey: process.env.TAJO_API_KEY, brevoApiKey: process.env.BREVO_API_KEY});
// Connect Amplitude projectawait tajo.connectors.connect('amplitude', { apiKey: process.env.AMPLITUDE_API_KEY, secretKey: process.env.AMPLITUDE_SECRET_KEY, dataCenter: 'US'});通过 HTTP V2 API 发送事件
// Send events to Amplitude (automatically forwarded to Brevo)const response = await fetch('https://api2.amplitude.com/2/httpapi', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ api_key: process.env.AMPLITUDE_API_KEY, events: [ { user_id: "user_123", event_type: "Purchase", event_properties: { revenue: 89.99, product_id: "SKU-001", product_name: "Widget Pro" }, user_properties: { $set: { plan_type: "premium" } }, time: Date.now() } ] })});
// Expected response: { "code": 200, "events_ingested": 1 }将群组同步到 Brevo 列表
// Export an Amplitude cohort and sync to Brevoconst cohort = await tajo.connectors.syncCohort('amplitude', { cohortId: 'abc123', targetList: 11, // Brevo list ID syncMode: 'mirror' // mirror, append, or remove});
console.log(cohort);// {// cohortName: "Power Users",// membersCount: 2450,// syncedToBrevo: 2450,// listId: 11// }速率限制
| API | 限制 | 详情 |
|---|---|---|
| HTTP V2 API | 1,000 事件/秒 | 每项目,突发最高 2,000/秒 |
| 批量 API | 每批 1,000 事件 | 最多 20 批/秒 |
| Identify API | 1,000 请求/秒 | 每项目 |
| 导出 API | 360 请求/小时 | 每项目 |
| 群组导出 | 1 个并发导出 | 每群组 |
| 仪表板 REST API | 360 请求/小时 | 每项目 |
事件大小限制
每个事件负载不能超过 1 MB。HTTP V2 API 每次请求最多接受 2,000 个事件,最大请求体为 20 MB。
故障排除
| 问题 | 原因 | 解决方案 |
|---|---|---|
事件返回 invalid 状态 | 缺少必填字段 | 确保每个事件都设置了 user_id 或 device_id |
| 用户属性未同步 | 属性操作符错误 | 设置时用 $set,首次触达值用 $setOnce |
| 群组导出为空 | 群组仍在计算中 | 等待群组计算完成后再导出 |
| 429 Too Many Requests | 超出速率限制 | 实施指数退避并使用批量 API |
| 收入未跟踪 | 缺少收入字段 | 在事件属性中包含 price、quantity 和 revenue |
| 欧盟数据未路由 | 数据中心错误 | 设置 data_center: "EU" 并使用 api.eu.amplitude.com |
最佳实践
- 使用 HTTP V2 API - 优先使用 V2 API 而非旧版 HTTP API,以获得更好的验证和错误响应
- 批量发送事件 - 每批最多发送 1,000 个事件以获得最佳吞吐量
- 在事件上设置用户属性 - 在追踪事件中包含
user_properties以减少 identify 调用 - 使用群组进行细分 - 同步行为群组而非复制复杂的细分逻辑
- 正确跟踪收入事件 - 使用
revenue、price和productId字段准确追踪收入 - 监控摄取健康状况 - 检查 Amplitude 的摄取调试器以发现事件验证错误
- 实施服务端跟踪 - 使用服务端 SDK 确保事件可靠投递
安全
- 仅 HTTPS - 所有 API 通信需要 TLS 1.2+
- API 密钥轮换 - 通过 Amplitude 设置定期轮换密钥
- IP 白名单 - 企业计划可用
- SOC 2 Type II - Amplitude 通过 SOC 2 Type II 认证
- GDPR/CCPA - 支持用户数据删除和导出请求
- 欧盟数据驻留 - 提供欧盟数据中心选项