klaviyo-migration-deep-dive
Execute major Klaviyo migration strategies: from legacy v1/v2 APIs, from competitors, or full re-platforming to Klaviyo with the strangler fig pattern. Trigger with phrases like "migrate to klaviyo", "klaviyo migration", "switch to klaviyo", "klaviyo replatform", "mailchimp to klaviyo", "legacy to klaviyo", "v1 to v2 klaviyo".
What this skill does
# Klaviyo Migration Deep Dive
## Overview
Comprehensive guide for migrating to Klaviyo from legacy APIs (v1/v2), competing ESPs (Mailchimp, SendGrid, etc.), or re-platforming with the strangler fig pattern. Covers data migration, API mapping, and validation.
## Prerequisites
- Target Klaviyo account configured
- `klaviyo-api` SDK installed
- Source system access for data export
- Feature flag infrastructure (for gradual rollout)
## Migration Types
| Migration | Complexity | Duration | Risk |
|-----------|-----------|----------|------|
| Klaviyo v1/v2 to current API | Low-Medium | 1-2 weeks | Low |
| Mailchimp/SendGrid to Klaviyo | Medium | 2-4 weeks | Medium |
| Custom ESP to Klaviyo | High | 4-8 weeks | High |
| Full re-platform | High | 2-3 months | High |
## Instructions
### Step 1: Legacy v1/v2 to Current API
The most common migration. Klaviyo deprecated v1/v2 endpoints in favor of the JSON:API REST API.
```typescript
// ============================================================
// BEFORE: Legacy v1/v2 endpoints (DEPRECATED, will stop working)
// ============================================================
// v1 Track (event tracking)
// POST https://a.klaviyo.com/api/track
// Body: { token: "PUBLIC_KEY", event: "Placed Order", ... }
// v2 List Subscribe
// POST https://a.klaviyo.com/api/v2/list/LIST_ID/subscribe
// Headers: { api-key: "pk_***" }
// v1 Identify (profile creation)
// POST https://a.klaviyo.com/api/identify
// Body: { token: "PUBLIC_KEY", properties: { $email: "..." } }
// ============================================================
// AFTER: Current REST API (revision 2024-10-15)
// ============================================================
import {
ApiKeySession,
ProfilesApi,
EventsApi,
ProfileEnum,
EventEnum,
} from 'klaviyo-api';
const session = new ApiKeySession(process.env.KLAVIYO_PRIVATE_KEY!);
const profilesApi = new ProfilesApi(session);
const eventsApi = new EventsApi(session);
// v1 Identify → createOrUpdateProfile
await profilesApi.createOrUpdateProfile({
data: {
type: ProfileEnum.Profile,
attributes: {
email: '[email protected]', // was $email
firstName: 'Jane', // was $first_name
lastName: 'Doe', // was $last_name
phoneNumber: '+15551234567', // was $phone_number
properties: { // custom properties stay the same
plan: 'pro',
signupDate: '2024-01-15',
},
},
},
});
// v1 Track → createEvent
await eventsApi.createEvent({
data: {
type: EventEnum.Event,
attributes: {
metric: {
data: { type: 'metric', attributes: { name: 'Placed Order' } },
},
profile: {
data: { type: ProfileEnum.Profile, attributes: { email: '[email protected]' } },
},
properties: {
orderId: 'ORD-123',
items: [{ name: 'Widget', price: 29.99 }],
},
value: 29.99,
time: new Date().toISOString(),
uniqueId: 'ORD-123',
},
},
});
// v2 List Subscribe → subscribeProfiles (bulk)
await profilesApi.subscribeProfiles({
data: {
type: 'profile-subscription-bulk-create-job',
attributes: {
profiles: {
data: [{
type: ProfileEnum.Profile,
attributes: {
email: '[email protected]',
subscriptions: {
email: { marketing: { consent: 'SUBSCRIBED', consentTimestamp: new Date().toISOString() } },
},
},
}],
},
},
relationships: {
list: { data: { type: 'list', id: 'LIST_ID' } },
},
},
});
```
### Step 2: API Field Mapping (v1/v2 to Current)
| v1/v2 Field | Current API Field | Notes |
|-------------|-------------------|-------|
| `$email` | `email` | No `$` prefix |
| `$first_name` | `firstName` | camelCase |
| `$last_name` | `lastName` | camelCase |
| `$phone_number` | `phoneNumber` | camelCase, E.164 format |
| `$city` | `location.city` | Nested under `location` |
| `$region` | `location.region` | Nested under `location` |
| `$country` | `location.country` | Nested under `location` |
| `$zip` | `location.zip` | Nested under `location` |
| `$title` | `title` | camelCase |
| `$organization` | `organization` | camelCase |
| Custom props | `properties.yourProp` | Same structure |
### Step 3: Competitor Migration (Mailchimp/SendGrid)
```typescript
// Data migration adapter -- transform competitor data to Klaviyo format
interface CompetitorContact {
email_address: string;
first_name: string;
last_name: string;
phone: string;
tags: string[];
status: 'subscribed' | 'unsubscribed' | 'cleaned';
stats: { avg_open_rate: number; avg_click_rate: number };
}
function transformToKlaviyo(contact: CompetitorContact) {
return {
data: {
type: 'profile' as const,
attributes: {
email: contact.email_address,
firstName: contact.first_name,
lastName: contact.last_name,
phoneNumber: contact.phone ? formatE164(contact.phone) : undefined,
properties: {
migrationSource: 'mailchimp',
migratedAt: new Date().toISOString(),
previousTags: contact.tags,
historicalOpenRate: contact.stats.avg_open_rate,
historicalClickRate: contact.stats.avg_click_rate,
},
},
},
};
}
// Batch import with progress tracking
async function migrateContacts(contacts: CompetitorContact[]): Promise<{
imported: number;
skipped: number;
failed: string[];
}> {
let imported = 0;
let skipped = 0;
const failed: string[] = [];
for (let i = 0; i < contacts.length; i += 50) {
const batch = contacts.slice(i, i + 50);
const results = await Promise.allSettled(
batch.map(async contact => {
// Skip unsubscribed/cleaned -- don't import suppressed contacts
if (contact.status !== 'subscribed') {
skipped++;
return;
}
const payload = transformToKlaviyo(contact);
await profilesApi.createOrUpdateProfile(payload);
imported++;
})
);
results.forEach((r, idx) => {
if (r.status === 'rejected') {
failed.push(batch[idx].email_address);
}
});
console.log(`Progress: ${Math.min(i + 50, contacts.length)}/${contacts.length} (${imported} imported, ${skipped} skipped)`);
// Respect rate limits
await new Promise(r => setTimeout(r, 1000));
}
return { imported, skipped, failed };
}
```
### Step 4: Strangler Fig Pattern (Gradual Migration)
```typescript
// src/email/service-router.ts
interface EmailService {
sendCampaign(campaign: CampaignData): Promise<void>;
trackEvent(event: EventData): Promise<void>;
getProfile(email: string): Promise<ProfileData>;
}
class LegacyEmailService implements EmailService { /* ... */ }
class KlaviyoEmailService implements EmailService { /* ... */ }
/**
* Route requests between legacy and Klaviyo based on feature flag.
* Gradually increase Klaviyo percentage from 0% to 100%.
*/
class MigrationRouter implements EmailService {
constructor(
private legacy: EmailService,
private klaviyo: EmailService,
private getKlaviyoPercentage: () => number // Feature flag
) {}
private useKlaviyo(): boolean {
return Math.random() * 100 < this.getKlaviyoPercentage();
}
async trackEvent(event: EventData): Promise<void> {
if (this.useKlaviyo()) {
// Send to Klaviyo
await this.klaviyo.trackEvent(event);
} else {
// Send to legacy
await this.legacy.trackEvent(event);
}
// During migration: dual-write to both for comparison
// Remove dual-write after validation
}
async sendCampaign(campaign: CampaignData): Promise<void> {
// Campaigns always go through one system at a time
if (this.getKlaviyoPercentage() >= 100) {
return this.klaviyo.sendCampaign(campaign);
}
return this.legacy.sendCampaign(campaign);
}
}
```
### Step 5: Post-Migration Validation
```typescript
async functionRelated in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.