Trình Kết Nối Klaviyo
Kết nối Klaviyo với Brevo qua Tajo để migration hoặc đồng bộ dữ liệu marketing giữa các nền tảng. Đồng bộ profiles, events, lists, segments, flows và campaign data cho chiến lược marketing đa kênh hợp nhất.
Tổng Quan
| Thuộc Tính | Giá Trị |
|---|---|
| Nền Tảng | Klaviyo |
| Danh Mục | Marketing |
| Độ Phức Tạp Thiết Lập | Trung Bình |
| Tích Hợp Chính Thức | Không |
| Dữ Liệu Đồng Bộ | Profiles, Sự Kiện, Lists, Segments, Campaigns |
| Skills Có Sẵn | 10 |
| Chuẩn API | JSON:API |
Tính Năng
- Đồng bộ profile - Đồng bộ hai chiều customer profiles giữa Klaviyo và Brevo
- Forward sự kiện - Forward Klaviyo tracked events sang Brevo để kích hoạt automation
- Migration list - Đồng bộ Klaviyo lists sang Brevo contact lists
- Đồng bộ segment - Xuất Klaviyo segments như Brevo lists hoặc segments
- Xuất dữ liệu flow - Kéo dữ liệu hiệu suất flow cho cross-platform analytics
- Đồng bộ campaign - Phối hợp campaigns qua kênh Klaviyo và Brevo
- Đồng bộ catalog - Sao chép product catalogs giữa các nền tảng
- Quản lý coupon - Đồng bộ mã coupon và dữ liệu sử dụng
Yêu Cầu
Trước khi bắt đầu, hãy đảm bảo bạn có:
- Tài khoản Klaviyo với quyền truy cập API
- Private API Key với phạm vi phù hợp
- Public API Key Klaviyo của bạn (company ID 6 ký tự)
- Tài khoản Brevo với quyền truy cập API
- Tài khoản Tajo với API credentials
Xác Thực
Private API Key
Klaviyo sử dụng private API keys với scoped access cho server-side authentication. Đặt key trong header Authorization:
curl https://a.klaviyo.com/api/profiles/ \ -H "Authorization: Klaviyo-API-Key your-private-api-key" \ -H "revision: 2026-01-15"Phạm Vi API Key
Cấu hình phạm vi khi tạo private key:
| Phạm Vi | Quyền Truy Cập | Mô Tả |
|---|---|---|
profiles | Read/Full | Truy cập contact profiles |
events | Read/Full | Truy cập tracked events |
lists | Read/Full | Truy cập contact lists |
segments | Read | Truy cập segments |
campaigns | Read | Truy cập campaign data |
metrics | Read | Truy cập metric definitions |
flows | Read | Truy cập flow configurations |
catalogs | Read | Truy cập product catalogs |
Public API Key
Cho client-side tracking, sử dụng company ID 6 ký tự:
curl -X POST "https://a.klaviyo.com/client/events/?company_id=COMPANY_ID" \ -H "Content-Type: application/json" \ -d '{"data": {...}}'OAuth (Tích Hợp Partner)
Klaviyo hỗ trợ OAuth cho tech partners, cung cấp bảo mật và giới hạn tốc độ tốt hơn:
curl https://a.klaviyo.com/api/profiles/ \ -H "Authorization: Bearer YOUR_OAUTH_TOKEN" \ -H "revision: 2026-01-15"Cấu Hình
Thiết Lập Cơ Bản
connectors: klaviyo: enabled: true private_api_key: "your-klaviyo-private-key" public_api_key: "XXXXXX" api_revision: "2026-01-15"
# Tùy chọn đồng bộ dữ liệu sync: profiles: true events: true lists: true segments: true catalogs: false
# Gán danh sách Brevo lists: all_contacts: 20 subscribers: 21 high_value: 22Ánh Xạ Profile
Ánh xạ Klaviyo profile properties sang thuộc tính liên hệ Brevo:
profile_mapping: email: email first_name: FIRSTNAME last_name: LASTNAME phone_number: SMS city: CITY region: REGION country: COUNTRY zip: ZIP organization: COMPANY title: JOB_TITLE
# Thuộc tính tùy chỉnh lifetime_value: LTV total_orders: ORDER_COUNT last_order_date: LAST_ORDER_DATE preferred_channel: CHANNEL_PREFÁnh Xạ Sự Kiện
Ánh xạ Klaviyo metrics sang Brevo events:
event_mapping: "Placed Order": "order_completed" "Ordered Product": "product_purchased" "Started Checkout": "checkout_started" "Added to Cart": "cart_updated" "Viewed Product": "product_viewed" "Subscribed to List": "customer_subscribed" "Received Email": "email_received" "Opened Email": "email_opened" "Clicked Email": "email_clicked"API Endpoints
| Phương Thức | Endpoint | Mô Tả |
|---|---|---|
GET | /api/profiles/ | Liệt kê profiles |
POST | /api/profiles/ | Tạo profile |
PATCH | /api/profiles/{id}/ | Cập nhật profile |
POST | /api/profile-merge/ | Merge profiles trùng lặp |
GET | /api/events/ | Liệt kê events |
POST | /api/events/ | Tạo event |
GET | /api/lists/ | Liệt kê tất cả lists |
POST | /api/lists/{id}/relationships/profiles/ | Thêm profiles vào list |
GET | /api/segments/ | Liệt kê segments |
GET | /api/campaigns/ | Liệt kê campaigns |
GET | /api/flows/ | Liệt kê flows |
GET | /api/metrics/ | Liệt kê metrics |
POST | /api/metric-aggregates/ | Truy vấn metric aggregates |
GET | /api/catalog-items/ | Liệt kê catalog items |
Ví Dụ Code
Khởi Tạo Trình Kết Nối Klaviyo
import { TajoClient } from '@tajo/sdk';
const tajo = new TajoClient({ apiKey: process.env.TAJO_API_KEY, brevoApiKey: process.env.BREVO_API_KEY});
// Kết nối tài khoản Klaviyoawait tajo.connectors.connect('klaviyo', { privateApiKey: process.env.KLAVIYO_PRIVATE_KEY, publicApiKey: process.env.KLAVIYO_PUBLIC_KEY});Đồng Bộ Profiles Sang Brevo
// Lấy Klaviyo profiles và đồng bộ sang Brevoconst response = await fetch('https://a.klaviyo.com/api/profiles/', { headers: { 'Authorization': `Klaviyo-API-Key ${PRIVATE_KEY}`, 'revision': '2026-01-15', 'Accept': 'application/vnd.api+json' }});
const { data } = await response.json();
// Mỗi profile theo định dạng JSON:API// {// "type": "profile",// "id": "01ABCDEF",// "attributes": {// "email": "[email protected]",// "first_name": "Jane",// "last_name": "Kim",// "phone_number": "+15551234567",// "properties": { "lifetime_value": 450.00 }// }// }Tạo Event
// Track event trong Klaviyo (được forward sang Brevo qua Tajo)await fetch('https://a.klaviyo.com/api/events/', { method: 'POST', headers: { 'Authorization': `Klaviyo-API-Key ${PRIVATE_KEY}`, 'revision': '2026-01-15', 'Content-Type': 'application/vnd.api+json', 'Accept': 'application/vnd.api+json' }, body: JSON.stringify({ data: { type: 'event', attributes: { metric: { data: { type: 'metric', attributes: { name: 'Placed Order' } } }, profile: { }, properties: { OrderId: 'ORD-1234', Value: 89.99, Items: [ { ProductName: 'Widget Pro', Price: 89.99, Quantity: 1 } ] }, value: 89.99 } } })});Truy Vấn Metric Aggregates
// Lấy dữ liệu metric tổng hợp cho báo cáoawait fetch('https://a.klaviyo.com/api/metric-aggregates/', { method: 'POST', headers: { 'Authorization': `Klaviyo-API-Key ${PRIVATE_KEY}`, 'revision': '2026-01-15', 'Content-Type': 'application/vnd.api+json' }, body: JSON.stringify({ data: { type: 'metric-aggregate', attributes: { metric_id: 'METRIC_ID', measurements: ['count', 'sum_value'], interval: 'day', filter: ['greater-or-equal(datetime,2024-01-01)', 'less-than(datetime,2024-02-01)'] } } })});Giới Hạn Tốc Độ
| Xác Thực | Giới Hạn Burst | Giới Hạn Ổn Định |
|---|---|---|
| Private API Key | 75 yêu cầu/giây | 700 yêu cầu/phút |
| OAuth | 150 yêu cầu/giây | 1.500 yêu cầu/phút |
| Client API | 100 yêu cầu/giây | N/A |
| Bulk operations | 10 yêu cầu/giây | 100 yêu cầu/phút |
Yêu Cầu API Revision
Tất cả Klaviyo API requests yêu cầu header revision được đặt thành ngày API version hợp lệ (ví dụ: 2026-01-15). Requests không có header này sẽ bị từ chối.
Khắc Phục Sự Cố
| Sự Cố | Nguyên Nhân | Giải Pháp |
|---|---|---|
400 Bad Request | API key không hợp lệ hoặc thiếu | Xác minh private API key chính xác |
403 Forbidden | Phạm vi không đủ | Kiểm tra phạm vi API key khớp quyền cần thiết |
Thiếu header revision | Header chưa đặt | Thêm revision: 2026-01-15 vào tất cả requests |
| Profile không tìm thấy | Định danh sai | Dùng Klaviyo profile ID, không phải email để lookup |
| Events không đồng bộ | Tên metric sai | Khớp chính xác tên metric như định nghĩa trong Klaviyo |
429 Too Many Requests | Vượt giới hạn tốc độ | Triển khai exponential backoff, cân nhắc OAuth để có giới hạn cao hơn |
| Lỗi định dạng JSON:API | Content type sai | Dùng application/vnd.api+json cho Content-Type và Accept headers |
Thực Hành Tốt Nhất
- Sử dụng định dạng JSON:API - Tuân theo JSON:API specification cho tất cả request và response payloads
- Đặt revision header - Luôn bao gồm header
revisionvới ngày API version mới nhất - Sử dụng sparse fieldsets - Chỉ yêu cầu các trường cần thiết với
?fields[profile]=email,first_nameđể giảm kích thước payload - Tận dụng relationships - Sử dụng tham số
includecủa JSON:API để lấy related resources trong một request - Sử dụng cursor pagination - Điều hướng qua tập kết quả lớn với tham số
page[cursor] - Triển khai bulk operations - Sử dụng bulk endpoints cho batch profile imports và event creation
- Dùng OAuth để có giới hạn cao hơn - Xác thực OAuth cung cấp giới hạn tốc độ cao hơn 2x so với private keys
Bảo Mật
- Phạm vi private API key - Kiểm soát Read/Full chi tiết mỗi loại tài nguyên
- Hỗ trợ OAuth - Xác thực dựa trên token an toàn cho tích hợp partner
- Cô lập public key - Client-side keys chỉ giới hạn thao tác create
- TLS 1.2+ - Tất cả giao tiếp API được mã hóa trong quá trình truyền
- SOC 2 Type II - Klaviyo được chứng nhận SOC 2 Type II
- Tuân thủ GDPR - Data Privacy API cho yêu cầu xóa profile