Skill站外收录 @skilllib/skill-2014279384180404225
customerio-primary-workflow
实现用户行为追踪与自动化消息触达,通过定义生命周期事件并集成分析服务,在关键节点触发邮件、推送等多渠道营销活动,支持基于用户状态的精准运营场景。
效率工具 AI 技能
Skills.MD
# Customer.io Primary Workflow
## Overview
Implement Customer.io's primary messaging workflow: identify users, track events, and trigger automated campaigns.
## Prerequisites
- Customer.io SDK configured
- Campaign/workflow created in Customer.io dashboard
- Understanding of your user lifecycle events
## Instructions
### Step 1: Define User Lifecycle Events
```typescript
// events/user-events.ts
export const USER_EVENTS = {
// Onboarding
SIGNED_UP: 'signed_up',
EMAIL_VERIFIED: 'email_verified',
PROFILE_COMPLETED: 'profile_completed',
FIRST_LOGIN: 'first_login',
// Engagement
FEATURE_USED: 'feature_used',
CONTENT_VIEWED: 'content_viewed',
SEARCH_PERFORMED: 'search_performed',
// Conversion
TRIAL_STARTED: 'trial_started',
SUBSCRIPTION_STARTED: 'subscription_started',
UPGRADE_COMPLETED: 'upgrade_completed',
PURCHASE_COMPLETED: 'purchase_completed',
// Churn Risk
INACTIVE_WARNING: 'inactive_warning',
SUBSCRIPTION_CANCELLED: 'subscription_cancelled',
ACCOUNT_DELETED: 'account_deleted',
} as const;
export type UserEvent = typeof USER_EVENTS[keyof typeof USER_EVENTS];
```
### Step 2: Implement Event Tracking Service
```typescript
// services/customerio-service.ts
import { TrackClient, RegionUS } from '@customerio/track';
import { USER_EVENTS, UserEvent } from '../events/user-events';
interface User {
id: string;
email: string;
firstName?: string;
lastName?: string;
plan?: string;
}
export class CustomerIOService {
private client: TrackClient;
constructor() {
this.client = new TrackClient(
process.env.CUSTOMERIO_SITE_ID!,
process.env.CUSTOMERIO_API_KEY!,
{ region: RegionUS }
);
}
// Called on user signup
async onSignup(user: User): Promise<void> {
await this.client.identify(user.id, {
email: user.email,
first_name: user.firstName,
last_name: user.lastName,
created_at: Math.floor(Date.now() / 1000),
plan: 'free',
onboarding_status: 'started'
});
await this.track(user.id, USER_EVENTS.SIGNED_UP, {
signup_source: 'web',
signup_date: new Date().toISOString()
});
}
// Called when email is verified
async onEmailVerified(userId: string): Promise<void> {
await this.updateUser(userId, {
email_verified: true,
email_verified_at: Math.floor(Date.now() / 1000)
});
await this.track(userId, USER_EVENTS.EMAIL_VERIFIED);
}
// Called on subscription change
async onSubscriptionStarted(userId: string, plan: string): Promise<void> {
await this.updateUser(userId, {
plan,
subscription_started_at: Math.floor(Date.now() / 1000)
});
await this.track(userId, USER_EVENTS.SUBSCRIPTION_STARTED, { plan });
}
// Generic tracking method
async track(userId: string, event: UserEvent, data?: Record<string, any>): Promise<void> {
await this.client.track(userId, {
name: event,
data: {
...data,
timestamp: new Date().toISOString()
}
});
}
// Update user attributes
async updateUser(userId: string, attributes: Record<string, any>): Promise<void> {
await this.client.identify(userId, attributes);
}
}
export const cioService = new CustomerIOService();
```
### Step 3: Integrate with Application
```typescript
// routes/auth.ts
import { cioService } from '../services/customerio-service';
app.post('/signup', async (req, res) => {
const user = await createUser(req.body);
// Fire and forget - don't block signup on analytics
cioService.onSignup({
id: user.id,
email: user.email,
firstName: user.firstName,
lastName: user.lastName
}).catch(err => console.error('Customer.io error:', err));
res.json({ user });
});
app.post('/verify-email', async (req, res) => {
const userId = await verifyEmailToken(req.body.token);
cioService.onEmailVerified(userId)
.catch(err => console.error('Customer.io error:', err));
res.json({ success: true });
});
```
### Step 4: Create Dashboard Campaign
In Customer.io Dashboard:
1. Go to Campaigns > Create Campaign
2. Select trigger: Event "signed_up"
3. Add workflow steps:
- Wait 1 day
- Send welcome email
- Wait 3 days
- Branch: if email_verified = false, send reminder
- Continue nurture sequence
## Output
- User lifecycle event definitions
- Customer.io service integration
- Application route integration
- Campaign workflow triggering
## Error Handling
| Error | Cause | Solution |
|-------|-------|----------|
| Event not triggering | Wrong event name | Match exact event name in dashboard |
| User not receiving | Missing email attribute | Ensure email is set on identify |
| Duplicate sends | Multiple event fires | Deduplicate or use idempotency |
## Resources
- [Customer.io Campaigns](https://customer.io/docs/campaigns/)
- [Trigger Events](https://customer.io/docs/events/)
## Next Steps
After implementing primary workflow, proceed to `customerio-core-feature` for advanced features.
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「customerio-primary-workflow」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次