Setting Up Marketing Process Automation via Web Application
Marketing automation combines user action tracking, audience segmentation, and automatic communications into a single system. Instead of manual distribution — chains that trigger on specific events.
System Architecture
Website (events) Event broker Automation
───────────────── ─────────────── ──────────────
Registration ────────► Kafka/Redis ──► Email chains
Page view ────────────► Stream ──► Push notifications
Add to cart │ ──► SMS
Purchase │ ──► Segmentation
Unsubscribe ▼
CDP (Customer
Data Platform)
Tools
| Tool | Type | Automation |
|---|---|---|
| Customer.io | SaaS | Email, push, SMS, webhooks |
| Brevo (Sendinblue) | SaaS | Email, SMS, WhatsApp |
| Klaviyo | SaaS | Email, SMS (e-commerce) |
| Mautic | Self-hosted | Email, SMS, landing pages |
| PostHog | Self-hosted | Product analytics + automation |
Event Tracking
// analytics.ts — unified event tracking
class MarketingTracker {
constructor(
private customerIo: CustomerIO,
private posthog: PostHog
) {}
async track(userId: string, event: string, properties: Record<string, unknown>) {
// Send to Customer.io for automation
await this.customerIo.track({
id: userId,
name: event,
data: properties
});
// Send to PostHog for analytics
this.posthog.capture({
distinctId: userId,
event,
properties
});
}
async identify(userId: string, traits: UserTraits) {
await this.customerIo.identify({
id: userId,
...traits,
last_seen: new Date().toISOString()
});
}
}
// Usage in event handler
await tracker.track(userId, 'checkout_started', {
cart_value: cart.total,
items_count: cart.items.length,
currency: 'USD'
});
await tracker.track(userId, 'page_viewed', {
page_name: 'pricing',
plan_viewed: 'pro'
});
Segmentation via Customer.io
// Creating a segment via API
const segment = await customerio.createSegment({
name: 'High-Intent Pro Users',
filter: {
and: [
{ attribute: { field: 'plan', operator: 'eq', value: 'free' } },
{ event: { name: 'pricing_viewed', timeframe: { days: 7 }, count: { min: 2 } } },
{ attribute: { field: 'total_orders', operator: 'gte', value: 1 } }
]
}
});
Automated Chain: Abandoned Cart
[Event: checkout_started]
│
[Wait 1 hour]
│
[Check: was purchase made?]
│ │
Yes No
│ │
[Exit] [Email: "You forgot your cart"]
│
[Wait 24 hours]
│
[Check: purchase?]
│
No
│
[Email: 10% discount]
│
[Wait 48 hours]
│
No
│
[Exit chain]
Content Personalization
// Email template with dynamic content
const emailData = {
to: user.email,
templateId: 'abandoned-cart',
dynamicTemplateData: {
firstName: user.firstName,
cartItems: cart.items.map(item => ({
name: item.productName,
imageUrl: item.imageUrl,
price: formatPrice(item.price),
quantity: item.quantity
})),
cartTotal: formatPrice(cart.total),
discountCode: isHighValueCart(cart) ? 'CART10' : null,
checkoutUrl: `https://example.com/checkout?cart=${cart.id}&source=email`
}
};
UTM Tracking and Attribution
// Add UTM parameters to all links in emails
function addUtmParams(url: string, campaign: string, medium = 'email'): string {
const params = new URLSearchParams({
utm_source: 'customer-io',
utm_medium: medium,
utm_campaign: campaign,
utm_content: 'link'
});
return `${url}?${params}`;
}
Timeline
Basic automation (welcome + abandoned cart) — 1 week. Full set of chains with segmentation and A/B tests — 2–4 weeks.







