Shopify 连接器

Shopify 连接器

将你的 Shopify 店铺连接到 Brevo,实现完整的客户数据同步、弃单召回和自动化营销 campaign。

概览

属性
平台Shopify
类别电商
部署复杂度简单
官方集成
同步数据客户、订单、产品、购物车、事件
可用 Skill12

功能特性

  • 实时客户同步 - 客户数据即时同步到 Brevo 联系人
  • 订单追踪 - 订单事件用于购后流程
  • 产品目录同步 - 产品可用于推荐
  • 弃单追踪 - 追踪并召回被放弃的购物车
  • 浏览行为 - 追踪页面浏览和产品兴趣
  • 多店铺支持 - 连接多个 Shopify 店铺

先决条件

开始前,请确认你具备:

  1. 拥有 admin 权限的 Shopify 店铺
  2. 具备 API 访问权限的 Brevo 账户
  3. Tajo 账户

安装

方式 1:Shopify App Store(推荐)

  1. 访问 Shopify App Store 中的 Tajo 应用
  2. 点击 “Add app”
  3. 授予所请求的权限
  4. 连接你的 Brevo 账户

方式 2:手动安装

第 1 步:创建 Shopify 应用

  1. 进入 Shopify 后台 → Settings → Apps and sales channels
  2. 点击 “Develop apps” → “Create an app”
  3. 将其命名为 “Tajo Integration”

第 2 步:配置 API 权限范围

启用以下 scope:

read_customers
write_customers
read_orders
read_products
read_checkouts
write_script_tags

第 3 步:安装应用

Terminal window
# Using Tajo CLI
tajo connectors install shopify \
--shop-url your-store.myshopify.com \
--api-key $SHOPIFY_API_KEY \
--api-secret $SHOPIFY_API_SECRET

第 4 步:配置 Webhook

Tajo 会自动注册以下 webhook:

Webhook用途
customers/create新客户同步
customers/update客户数据变更
customers/delete删除客户
orders/create下单事件
orders/updated订单状态变更
checkouts/create创建购物车
checkouts/update购物车更新

配置

基础设置

connectors:
shopify:
enabled: true
shop_url: "your-store.myshopify.com"
api_version: "2024-01"
# Data sync options
sync:
customers: true
orders: true
products: true
carts: true
inventory: false # Optional
# List assignment
lists:
all_customers: 5
buyers: 6
abandoned_cart: 7

字段映射

将 Shopify 字段映射到 Brevo 联系人属性:

默认映射

Parameter Type Description
email required
string

客户邮箱(唯一标识)

first_name optional
string

映射到 FIRSTNAME 属性

last_name optional
string

映射到 LASTNAME 属性

phone optional
string

映射到 SMS 属性,用于 WhatsApp/SMS

accepts_marketing optional
boolean

控制订阅状态

orders_count optional
integer

订单总数

total_spent optional
number

客户终身价值

tags optional
array

来自 Shopify 的客户标签

自定义属性映射

field_mapping:
# Standard fields
email: email
first_name: FIRSTNAME
last_name: LASTNAME
phone: SMS
# E-commerce metrics
orders_count: ORDER_COUNT
total_spent: TOTAL_SPENT
last_order_date: LAST_ORDER_DATE
# Custom fields
customer_type: CUSTOMER_TYPE
preferred_language: LANGUAGE
loyalty_tier: VIP_TIER
# Computed fields
average_order_value: AOV
days_since_last_order: RECENCY

产品同步

同步产品用于邮件推荐:

sync:
products:
enabled: true
include_variants: true
include_images: true
categories_as_tags: true
# Filter products
filter:
status: active
exclude_tags: ["hidden", "wholesale-only"]

库存追踪

启用库存水位同步:

sync:
inventory:
enabled: true
low_stock_threshold: 10
out_of_stock_events: true

事件

客户事件

事件触发条件适用场景
customer_created新客户注册欢迎系列
customer_updated资料变更数据同步
customer_tags_added标签被分配分群更新

订单事件

事件触发条件适用场景
order_placed完成结算订单确认
order_fulfilled订单发货发货通知
order_cancelled订单取消取消邮件
order_refunded处理退款退款确认

购物车事件

事件触发条件适用场景
cart_created商品加入购物车浏览追踪
cart_updated购物车变更购物车金额追踪
cart_abandoned30 分钟内未结算召回邮件

启用的 Skill

Shopify 连接器可启用以下 skill:

Skill说明
客户同步实时客户同步
订单事件订单生命周期追踪
弃单召回购物车召回邮件
欢迎系列新客户引导
购后跟进订单后续跟进
赢回流失重新激活沉默客户
浏览召回产品兴趣跟进
补货提醒再购买提醒

代码示例

初始化连接器

import { TajoClient } from '@tajo/sdk';
const tajo = new TajoClient({
apiKey: process.env.TAJO_API_KEY,
brevoApiKey: process.env.BREVO_API_KEY
});
// Connect Shopify store
await tajo.connectors.connect('shopify', {
shopUrl: 'your-store.myshopify.com',
apiKey: process.env.SHOPIFY_API_KEY,
apiSecret: process.env.SHOPIFY_API_SECRET
});

运行初始同步

// Full historical sync
await tajo.connectors.sync('shopify', {
type: 'full',
resources: ['customers', 'orders', 'products'],
since: '2023-01-01'
});
// Check sync status
const status = await tajo.connectors.status('shopify');
console.log(status);
// {
// connected: true,
// lastSync: '2024-01-15T10:30:00Z',
// customersCount: 15420,
// ordersCount: 8234,
// productsCount: 342
// }

追踪购物车事件

将 Tajo 脚本添加到你的 Shopify 主题中:

<!-- Add to theme.liquid before </head> -->
{% if customer %}
<script>
window.tajoConfig = {
customerId: "{{ customer.id }}",
customerEmail: "{{ customer.email }}",
customerName: "{{ customer.first_name }}"
};
</script>
{% endif %}
<script src="https://cdn.tajo.io/shopify.js"></script>

自定义 Webhook 处理器

// Handle Shopify webhooks manually
app.post('/webhooks/shopify', async (req, res) => {
const hmac = req.get('X-Shopify-Hmac-SHA256');
// Verify webhook signature
if (!verifyShopifyWebhook(req.body, hmac)) {
return res.status(401).send('Unauthorized');
}
const topic = req.get('X-Shopify-Topic');
// Forward to Tajo
await tajo.connectors.handleWebhook('shopify', {
topic,
payload: req.body
});
res.status(200).send('OK');
});

监控

仪表盘指标

在 Tajo 仪表盘中监控你的 Shopify 连接:

  • 同步状态:实时连接健康度
  • 已同步客户数:来自 Shopify 的总联系人数
  • 追踪订单数:已处理的订单事件数
  • 购物车召回:弃单召回表现
  • 错误率:同步失败尝试数

Webhook 日志

查看 webhook 送达状态:

Terminal window
tajo connectors logs shopify --type webhook --last 24h

同步历史

查看历史同步记录:

Terminal window
tajo connectors history shopify --limit 10

故障排查

常见问题

API 速率限制

Shopify 的 API 速率限制为 2 请求/秒。对大批量历史导入请使用批量同步。

问题原因解决方案
未收到 webhook应用权限不足使用正确的 scope 重新安装应用
客户未同步缺少邮箱Shopify 要求客户必须有邮箱
产品缺失产品状态问题确认产品为 “active” 状态
购物车未追踪脚本未加载核实 theme.liquid 中已添加脚本

调试模式

开启详细日志:

connectors:
shopify:
debug: true
log_level: verbose
log_webhooks: true

连接测试

Terminal window
tajo connectors test shopify
# ✓ API connection successful
# ✓ Webhooks registered
# ✓ Products accessible
# ✓ Customers readable
# ✓ Orders readable

最佳实践

  1. 先用测试店铺 - 建议先用开发店铺
  2. 在非高峰时段运行初始同步 - 大批量同步会比较慢
  3. 映射自定义属性 - 不要只依赖默认映射
  4. 开启购物车追踪 - 对弃单召回至关重要
  5. 监控 webhook 健康 - 为送达失败设置告警
  6. 使用批量导入 - 超过 10,000 条的历史数据应使用批量方式

安全

  • OAuth 2.0 - 基于 token 的安全认证
  • Webhook 验证 - HMAC 签名校验
  • 加密存储 - API 凭证静态加密
  • 最小权限 - 仅授予必要的 scope

相关资源

Subscribe to updates

developer-docs

Drop your email or phone number — we'll send you what matters next.

AI 助手

你好!关于文档有任何问题都可以问我。

免费开始使用Brevo