はじめに
支払いイベントに基づいて、パーソナライズされたメールキャンペーンや顧客の旅をトリガーします。新しい顧客へのウェルカムメール、サブスクリプションの更新、支払い失敗通知をCustomer.ioを通じて自動的に送信します。
この統合には、お使いのCustomer.ioサイトIDとAPIキーが必要です。
始め方
Open the Webhook Section
Dodo Paymentsのダッシュボードで、Webhooks → + Add Endpointに移動し、統合のドロップダウンを展開します。 Select Customer.io
Customer.ioの統合カードを選択します。
Enter Credentials
Customer.ioのサイトIDとAPIキーを設定に入力します。
Configure Transformation
トランスフォーメーションコードを編集して、イベントをCustomer.ioのTrack API形式に整えます。
Test & Create
サンプルのペイロードでテストし、Createをクリックして同期を有効にします。
Done!
🎉 支払いイベントがCustomer.ioのメールオートメーションをトリガーするようになります。
変換コードの例
支払いイベントのトラッキング
function handler(webhook) {
if (webhook.eventType === "payment.succeeded") {
const p = webhook.payload.data;
webhook.url = "https://track.customer.io/api/v2/entity";
webhook.payload = {
type: "person",
identifiers: {
id: p.customer.customer_id
},
action: "payment_completed",
name: "Payment Completed",
attributes: {
email: p.customer.email,
name: p.customer.name,
payment_amount: (p.total_amount / 100).toFixed(2),
payment_method: p.payment_method || "unknown",
payment_id: p.payment_id,
currency: p.currency || "USD"
}
};
}
return webhook;
}
サブスクリプションライフサイクルのトラッキング
function handler(webhook) {
const s = webhook.payload.data;
switch (webhook.eventType) {
case "subscription.active":
webhook.url = "https://track.customer.io/api/v2/entity";
webhook.payload = {
type: "person",
identifiers: {
id: s.customer.customer_id
},
action: "subscription_started",
name: "Subscription Started",
attributes: {
email: s.customer.email,
subscription_id: s.subscription_id,
product_id: s.product_id,
amount: (s.recurring_pre_tax_amount / 100).toFixed(2),
frequency: s.payment_frequency_interval,
next_billing: s.next_billing_date
}
};
break;
case "subscription.cancelled":
webhook.url = "https://track.customer.io/api/v2/entity";
webhook.payload = {
type: "person",
identifiers: {
id: s.customer.customer_id
},
action: "subscription_cancelled",
name: "Subscription Cancelled",
attributes: {
email: s.customer.email,
subscription_id: s.subscription_id,
cancelled_at: s.cancelled_at,
cancel_at_next_billing: s.cancel_at_next_billing_date
}
};
break;
}
return webhook;
}
顧客属性のトラッキング
function handler(webhook) {
if (webhook.eventType === "payment.succeeded") {
const p = webhook.payload.data;
webhook.url = "https://track.customer.io/api/v2/entity";
webhook.payload = {
type: "person",
identifiers: {
id: p.customer.customer_id
},
action: "identify",
name: "Customer Identified",
attributes: {
email: p.customer.email,
name: p.customer.name,
total_spent: (p.total_amount / 100).toFixed(2),
payment_method: p.payment_method || "unknown",
last_payment_date: webhook.payload.timestamp,
customer_since: webhook.payload.timestamp
}
};
}
return webhook;
}
ヒント
- Customer.ioキャンペーンに一致する一貫したイベント名を使用する
- パーソナライズのために関連する属性を含める
- 正確なトラッキングのために適切な顧客識別子を設定する
- キャンペーントリガーのために意味のあるイベント名を使用する
トラブルシューティング
Events not triggering campaigns
- サイトIDとAPIキーが正しいことを確認します
- イベント名がCustomer.ioのキャンペーンに一致しているか確認します
- 顧客識別子が適切に設定されていることを確認します
- Customer.ioのAPIレート制限を確認します