klaviyo-core-workflow-b
Execute Klaviyo secondary workflow: event tracking, segments, and campaigns. Use when tracking customer events, creating segments, building campaigns, or triggering flows via the Klaviyo API. Trigger with phrases like "klaviyo events", "klaviyo segments", "klaviyo campaigns", "track klaviyo event", "klaviyo flow trigger".
Best use case
klaviyo-core-workflow-b is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Execute Klaviyo secondary workflow: event tracking, segments, and campaigns. Use when tracking customer events, creating segments, building campaigns, or triggering flows via the Klaviyo API. Trigger with phrases like "klaviyo events", "klaviyo segments", "klaviyo campaigns", "track klaviyo event", "klaviyo flow trigger".
Teams using klaviyo-core-workflow-b should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/klaviyo-core-workflow-b/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How klaviyo-core-workflow-b Compares
| Feature / Agent | klaviyo-core-workflow-b | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Execute Klaviyo secondary workflow: event tracking, segments, and campaigns. Use when tracking customer events, creating segments, building campaigns, or triggering flows via the Klaviyo API. Trigger with phrases like "klaviyo events", "klaviyo segments", "klaviyo campaigns", "track klaviyo event", "klaviyo flow trigger".
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
ChatGPT vs Claude for Agent Skills
Compare ChatGPT and Claude for AI agent skills across coding, writing, research, and reusable workflow execution.
Cursor vs Codex for AI Workflows
Compare Cursor and Codex for AI coding workflows, repository assistance, debugging, refactoring, and reusable developer skills.
SKILL.md Source
# Klaviyo Core Workflow B -- Events, Segments & Campaigns
## Overview
Secondary workflow: track customer events, query segments, create/send campaigns, and trigger metric-based flows via the `klaviyo-api` SDK.
## Prerequisites
- Completed `klaviyo-core-workflow-a` (profiles/lists set up)
- API key scopes: `events:write`, `segments:read`, `campaigns:read`, `campaigns:write`, `flows:read`
## Instructions
### Step 1: Track Server-Side Events
```typescript
import {
ApiKeySession,
EventsApi,
EventEnum,
ProfileEnum,
MetricsApi,
} from 'klaviyo-api';
const session = new ApiKeySession(process.env.KLAVIYO_PRIVATE_KEY!);
const eventsApi = new EventsApi(session);
// Track a purchase event (creates the metric if it doesn't exist)
await eventsApi.createEvent({
data: {
type: EventEnum.Event,
attributes: {
metric: {
data: {
type: 'metric',
attributes: { name: 'Placed Order' },
},
},
profile: {
data: {
type: ProfileEnum.Profile,
attributes: { email: 'customer@example.com' },
},
},
properties: {
orderId: 'ORD-12345',
items: [
{ productId: 'SKU-001', name: 'Widget', quantity: 2, price: 29.99 },
{ productId: 'SKU-002', name: 'Gadget', quantity: 1, price: 49.99 },
],
itemCount: 3,
discount: 10.00,
},
// Monetary value for revenue attribution
value: 99.97,
time: new Date().toISOString(),
uniqueId: 'ORD-12345', // Deduplication key
},
},
});
// Track a custom event (triggers flows listening for this metric)
await eventsApi.createEvent({
data: {
type: EventEnum.Event,
attributes: {
metric: {
data: { type: 'metric', attributes: { name: 'Started Checkout' } },
},
profile: {
data: { type: ProfileEnum.Profile, attributes: { email: 'customer@example.com' } },
},
properties: {
cartValue: 149.97,
cartUrl: 'https://shop.example.com/cart/abc123',
items: ['Widget x2', 'Gadget x1'],
},
value: 149.97,
time: new Date().toISOString(),
},
},
});
```
### Step 2: Query Events and Metrics
```typescript
const metricsApi = new MetricsApi(session);
// List all metrics (event types) in your account
const metrics = await metricsApi.getMetrics();
for (const m of metrics.body.data) {
console.log(`${m.attributes.name} (${m.id})`);
}
// Get recent events sorted by newest first
const events = await eventsApi.getEvents({
sort: '-datetime',
filter: 'equals(metric_id,"METRIC_ID_HERE")',
});
for (const event of events.body.data) {
console.log(`${event.attributes.datetime}: ${event.attributes.eventProperties?.orderId}`);
}
```
### Step 3: Work with Segments
```typescript
import { SegmentsApi } from 'klaviyo-api';
const segmentsApi = new SegmentsApi(session);
// List all segments
const segments = await segmentsApi.getSegments();
for (const seg of segments.body.data) {
console.log(`${seg.attributes.name} (${seg.id}) - active: ${seg.attributes.isActive}`);
}
// Get profiles in a segment
const segmentProfiles = await segmentsApi.getSegmentProfiles({
id: 'SEGMENT_ID',
});
for (const profile of segmentProfiles.body.data) {
console.log(profile.attributes.email);
}
// Check segment size (useful before campaign sends)
const segmentWithCount = await segmentsApi.getSegment({
id: 'SEGMENT_ID',
additionalFieldsSegment: ['profile_count'],
});
console.log(`Segment size: ${segmentWithCount.body.data.attributes.profileCount}`);
```
### Step 4: Create an Email Campaign
```typescript
import { CampaignsApi, CampaignEnum, TemplatesApi } from 'klaviyo-api';
const campaignsApi = new CampaignsApi(session);
const templatesApi = new TemplatesApi(session);
// 1. Create an email template
const template = await templatesApi.createTemplate({
data: {
type: 'template',
attributes: {
name: 'Weekly Sale Announcement',
editorType: 'CODE',
html: `
<html>
<body>
<h1>Hey {{ first_name|default:"there" }}!</h1>
<p>Check out our weekly deals.</p>
<a href="{{ url }}">Shop Now</a>
{% unsubscribe %}Unsubscribe{% endunsubscribe %}
</body>
</html>
`,
},
},
});
// 2. Create a campaign targeting a list or segment
const campaign = await campaignsApi.createCampaign({
data: {
type: CampaignEnum.Campaign,
attributes: {
name: 'Weekly Sale - March 2025',
channel: 'email',
audiences: {
included: [{ type: 'segment', id: 'SEGMENT_ID' }],
excluded: [{ type: 'list', id: 'SUPPRESSION_LIST_ID' }],
},
sendOptions: {
useSmartSending: true, // Skip recently emailed contacts
},
},
},
});
const campaignId = campaign.body.data.id;
// 3. Assign template to campaign message
const messages = await campaignsApi.getCampaignCampaignMessages({ id: campaignId });
const messageId = messages.body.data[0].id;
await campaignsApi.assignTemplateToCampaignMessage({
id: messageId,
body: {
data: {
type: 'template',
id: template.body.data.id,
},
},
});
// 4. Send the campaign (or schedule)
await campaignsApi.createCampaignSendJob({
data: {
type: 'campaign-send-job',
id: campaignId,
},
});
console.log('Campaign queued for sending');
```
### Step 5: Query Flows (Read-Only)
```typescript
import { FlowsApi } from 'klaviyo-api';
const flowsApi = new FlowsApi(session);
// List all flows
const flows = await flowsApi.getFlows();
for (const flow of flows.body.data) {
console.log(`${flow.attributes.name} - status: ${flow.attributes.status}`);
}
// Get flow actions (the steps in a flow)
const flowActions = await flowsApi.getFlowFlowActions({ id: 'FLOW_ID' });
for (const action of flowActions.body.data) {
console.log(` Action: ${action.attributes.actionType} - ${action.attributes.status}`);
}
```
## Common Event Names for Flow Triggers
| Event Name | Typical Trigger | Flow Type |
|-----------|----------------|-----------|
| `Placed Order` | Purchase completed | Post-purchase / cross-sell |
| `Started Checkout` | Cart created | Abandoned cart |
| `Viewed Product` | Product page visit | Browse abandonment |
| `Ordered Product` | Per-item tracking | Product review request |
| `Fulfilled Order` | Shipment sent | Shipping confirmation |
| `Cancelled Order` | Order cancelled | Win-back |
| `Subscribed to List` | Email/SMS signup | Welcome series |
| `Custom Event` | Any API event | Custom automation |
## Error Handling
| Error | Status | Cause | Solution |
|-------|--------|-------|----------|
| Invalid metric name | 400 | Empty or null metric | Always include `metric.data.attributes.name` |
| Segment not found | 404 | Wrong segment ID | List segments with `getSegments()` |
| Campaign send failed | 400 | Missing template/audience | Assign template and set audience first |
| Duplicate event | N/A | Same `uniqueId` | Deduplication built-in; safe to retry |
## Resources
- [Events API](https://developers.klaviyo.com/en/reference/events_api_overview)
- [Segments API](https://developers.klaviyo.com/en/reference/segments_api_overview)
- [Campaigns API](https://developers.klaviyo.com/en/reference/campaigns_api_overview)
- [Flows API](https://developers.klaviyo.com/en/reference/flows_api_overview)
- [Metrics API](https://developers.klaviyo.com/en/reference/metrics_api_overview)
## Next Steps
For common errors, see `klaviyo-common-errors`.Related Skills
calendar-to-workflow
Converts calendar events and schedules into Claude Code workflows, meeting prep documents, and standup notes. Use when the user mentions calendar events, meeting prep, standup generation, or scheduling workflows. Trigger with phrases like "prep for my meetings", "generate standup notes", "create workflow from calendar", or "summarize today's schedule".
workhuman-core-workflow-b
Workhuman core workflow b for employee recognition and rewards API. Use when integrating Workhuman Social Recognition, or building recognition workflows with HRIS systems. Trigger: "workhuman core workflow b".
workhuman-core-workflow-a
Workhuman core workflow a for employee recognition and rewards API. Use when integrating Workhuman Social Recognition, or building recognition workflows with HRIS systems. Trigger: "workhuman core workflow a".
wispr-core-workflow-b
Wispr Flow core workflow b for voice-to-text API integration. Use when integrating Wispr Flow dictation, WebSocket streaming, or building voice-powered applications. Trigger: "wispr core workflow b".
wispr-core-workflow-a
Wispr Flow core workflow a for voice-to-text API integration. Use when integrating Wispr Flow dictation, WebSocket streaming, or building voice-powered applications. Trigger: "wispr core workflow a".
windsurf-core-workflow-b
Execute Windsurf's secondary workflow: Workflows, Memories, and reusable automation. Use when creating reusable Cascade workflows, managing persistent memories, or automating repetitive development tasks. Trigger with phrases like "windsurf workflow", "windsurf automation", "windsurf memories", "cascade workflow", "windsurf slash command".
windsurf-core-workflow-a
Execute Windsurf's primary workflow: Cascade Write mode for multi-file agentic coding. Use when building features, refactoring across files, or performing complex code tasks. Trigger with phrases like "windsurf cascade write", "windsurf agentic coding", "windsurf multi-file edit", "cascade write mode", "windsurf build feature".
webflow-core-workflow-b
Execute Webflow secondary workflows — Sites management, Pages API, Forms submissions, Ecommerce (products/orders/inventory), and Custom Code via the Data API v2. Use when managing sites, reading pages, handling form data, or working with Webflow Ecommerce products and orders. Trigger with phrases like "webflow sites", "webflow pages", "webflow forms", "webflow ecommerce", "webflow products", "webflow orders".
webflow-core-workflow-a
Execute the primary Webflow workflow — CMS content management: list collections, CRUD items, publish items, and manage content lifecycle via the Data API v2. Use when working with Webflow CMS collections and items, managing blog posts, team members, or any dynamic content. Trigger with phrases like "webflow CMS", "webflow collections", "webflow items", "create webflow content", "manage webflow CMS", "webflow content management".
veeva-core-workflow-b
Veeva Vault core workflow b for REST API and clinical operations. Use when working with Veeva Vault document management and CRM. Trigger: "veeva core workflow b".
veeva-core-workflow-a
Veeva Vault core workflow a for REST API and clinical operations. Use when working with Veeva Vault document management and CRM. Trigger: "veeva core workflow a".
vastai-core-workflow-b
Execute Vast.ai secondary workflow: multi-instance orchestration, spot recovery, and cost optimization. Use when running distributed training, handling spot preemption, or optimizing GPU spend across multiple instances. Trigger with phrases like "vastai distributed training", "vastai spot recovery", "vastai multi-gpu", "vastai cost optimization".