Klaviyo Developer
Expert-level guidance for building with the Klaviyo API — custom event tracking, profile management, SDK integration, webhooks, catalog sync, and data pipeline architecture.
For marketing strategy, flow auditing, segmentation, deliverability, and campaign optimization, see the klaviyo-analyst skill.
Install
git clone https://github.com/thatrebeccarae/claude-marketing.git && cp -r claude-marketing/skills/klaviyo-developer ~/.claude/skills/
MCP vs. SDK: When to Use Which
This skill is SDK-first by design — you're building production integrations against the Klaviyo API, not running ad-hoc queries. That said, Klaviyo's official MCP server is the right tool for parts of integration work, and you should know when to reach for it.
Use the SDK (klaviyo-api) when… |
Use the MCP (https://mcp.klaviyo.com/mcp) when… |
| Writing production event-tracking code |
Exploring an account's event schema before writing the integration |
| Building bulk import / sync pipelines |
Sanity-checking that events landed with the right property shape |
| Implementing webhook handlers |
Pulling a quick property inventory during integration design |
| Catalog sync jobs |
Inspecting flow trigger conditions while debugging why an event isn't firing a flow |
| Anything in CI, cron, or a deployed service |
Iterating on event schema design with the marketing analyst in the room |
The MCP wraps the same API this skill targets, so the schema rules, rate limits, and nesting constraints below apply equally to MCP-driven calls. The MCP is currently pinned to API revision 2026-04-15 — keep that in mind if you're versioning your own SDK code against an older revision.
For the full MCP tool inventory, OAuth setup, and read-only mode flag, see REFERENCE.md. For audit/analyst work, see the klaviyo-analyst skill — it's built around the MCP.
Core Capabilities
API Authentication & Versioning
- Private API key setup and key management best practices
- Public API key usage for client-side tracking (klaviyo.js)
- OAuth 2.0 authorization flow for third-party apps
- API revision headers and version lifecycle management
Custom Event Tracking
- Server-side event tracking via Events API
- Client-side tracking with klaviyo.js
- Event schema design and property naming conventions
- Idempotent event submission patterns
Profile Management
- Profile create, upsert, and bulk import patterns
- Custom property management and data types
- Subscription management (email, SMS consent)
- Profile merge and deduplication strategies
Webhooks
- Webhook subscription setup and event types
- Payload verification and signature validation
- Retry handling and idempotent webhook processing
SDK Usage & Libraries
- Python SDK (klaviyo-api)
- Node.js SDK (klaviyo-api-node)
- Ruby, PHP, and other community SDKs
- SDK initialization, error handling, and retry configuration
Catalog & Product Feed Sync
- Catalog item create/update/delete via API
- Category and variant management
- Product feed sync architecture for recommendations
- Handling large catalogs with bulk operations
Data Export & Warehouse Sync
- Metric aggregation API for reporting
- Profile and event export patterns
- Cursor-based pagination for large datasets
- ETL pipeline design for data warehouse integration
SDK Quick Reference
| Language |
Package |
Install |
| Python |
klaviyo-api |
pip install klaviyo-api |
| Node.js |
klaviyo-api |
npm install klaviyo-api |
| Ruby |
klaviyo-api-sdk |
gem install klaviyo-api-sdk |
| PHP |
klaviyo/api |
composer require klaviyo/api |
Rate Limits
| Endpoint Category |
Limit |
Window |
| Most endpoints |
75 requests |
per second |
| Bulk imports |
10 requests |
per second |
| Profile/Event create |
350 requests |
per second |
| Campaign send |
10 requests |
per second |
Headers returned: RateLimit-Limit, RateLimit-Remaining, RateLimit-Reset
API Revision Timeline
| Revision |
Key Changes |
| 2026-01-15 |
Latest. Custom Objects Ingestion, Geofencing API (beta). |
| 2025-10-15 |
Forms API, Flow Actions API, SMS ROI reporting. |
| 2025-07-15 |
Mapped Metrics API, Custom Objects API (GA). |
| 2025-04-15 |
Web Feeds API, Custom Metrics, Push Token registration. |
| 2025-01-15 |
Reviews APIs, Flows Create API, Campaign image management. |
| 2024-10-15 |
Universal Content API, Form/Segment Reporting, Reviews API. |
| 2024-07-15 |
Forms API (retrieval), Webhooks API. |
| 2024-02-15 |
Reporting API, Create or Update Profile (upsert). |
Always include the revision header in API requests.
Essential Developer Checklist
- API key management — Store private keys in environment variables, never commit to source. Rotate keys periodically.
- Revision header — Always include
revision: YYYY-MM-DD header. Pin to a specific version.
- Rate limit handling — Implement exponential backoff with jitter on 429 responses.
- Idempotent events — Include a unique
unique_id property to prevent duplicate event tracking.
- Profile upserts — Use
POST /profiles/ with existing identifier for upsert behavior (creates or updates).
- Webhook verification — Validate webhook signatures before processing payloads.
- Pagination — Use cursor-based pagination for list endpoints. Never assume result counts.
- Error handling — Parse JSON:API error responses. Handle 4xx (client) and 5xx (server) differently.
- SDK initialization — Configure SDK with API key at app startup, not per-request.
- Testing — Use Klaviyo test/sandbox accounts. Mock API responses in unit tests.
Workflow: Custom Integration Setup
When building a custom Klaviyo integration:
- Define requirements — What events to track, what profile data to sync, what triggers are needed
- API key provisioning — Create a private API key with minimum required scopes
- Event schema design — Map business events to Klaviyo metric names and properties
- Profile sync strategy — Determine identifier (email vs phone vs external_id), upsert frequency
- Implement tracking — Server-side event tracking with proper error handling and retries
- Catalog sync (if applicable) — Product feed sync for recommendations and browse abandonment
- Webhook setup — Subscribe to relevant events, implement handler with signature verification
- Rate limit strategy — Queue and throttle API calls, implement backoff
- Monitoring — Log API errors, track event delivery rates, alert on failures
- Testing & validation — Verify events appear in Klaviyo, test flow triggers, validate profile data
Workflow: Integration Health Audit
When auditing an existing Klaviyo integration for health and data quality:
- Inventory active integrations — List all configured integrations (built-in and custom). Identify active vs stale connections.
- Map event sources — For each metric in the account, identify its source (built-in integration, custom API, Klaviyo-internal, form). Flag metrics with zero recent volume.
- Audit event schemas — Pull property structures for key events (Placed Order, Started Checkout, Viewed Product, Added to Cart). Check for:
- Missing standard properties (e.g.,
$value, ItemNames, line items)
- Duplicate/redundant metrics (e.g., "Placed Order" and "Order Placed" from different sources)
- Inconsistent property naming (camelCase vs snake_case across events)
- Check profile data pipeline — Verify profile properties are being synced correctly. Look for:
- Properties set by API vs properties set by events
- Stale properties (set once, never updated)
- Properties used in segmentation vs properties sitting unused
- Review catalog sync — Verify product catalog is synced and fresh. Check:
- Total catalog items vs expected product count
- Last sync timestamp
- Variant coverage (are variants synced or just parent products?)
- Category structure completeness
- Assess flow trigger architecture — Map how flows are triggered:
- Direct metric triggers (robust) vs segment-entry triggers via API-synced properties (brittle)
- Single points of failure (if API sync breaks, do all flows stop?)
- Trigger redundancy and fallback patterns
- Identify data accessibility gaps — Check for data that exists in event payloads but isn't usable:
- Nested objects in event properties (can use in templates, cannot use in segments/splits)
- Properties available in events but not synced to profiles (can't segment on them)
- Events tracked but not used in any flow or segment
- Produce integration health report — Document findings with severity ratings:
- Critical: Integration failures, broken event tracking, data loss
- High: Missing standard events, duplicate metrics, flow trigger fragility
- Medium: Unused events, incomplete catalog, stale profile properties
- Low: Naming inconsistencies, optimization opportunities
Event Schema Best Practices
Property Naming Conventions
- Use PascalCase for standard Klaviyo properties:
ProductName, ItemPrice, OrderId
- Use snake_case for custom properties:
business_type, account_id, reorder_count
- Never mix conventions within a single event — pick one and be consistent
- Prefix custom properties to avoid collision with Klaviyo-reserved names
Required Properties by Event
| Event |
Required Properties |
Revenue Property |
| Placed Order |
$value, OrderId, Items[] (line items) |
$value |
| Started Checkout |
$value, CheckoutURL, Items[] |
$value |
| Viewed Product |
ProductName, ProductID, URL, ImageURL |
— |
| Added to Cart |
$value, AddedItemProductName, AddedItemProductID, Items[] |
$value |
| Fulfilled Order |
$value, OrderId |
— |
Nesting Rules and Limitations
Klaviyo handles nested objects differently depending on where you access them:
| Context |
Access Level |
Example |
| Email/SMS templates |
Full access via Jinja — can loop over arrays, access nested properties |
{% for item in event.Items %}{{ item.ProductName }}{% endfor %} |
| Flow conditional splits |
Top-level properties ONLY — cannot access nested object fields |
Can split on event.OrderId, cannot split on event.Items[0].ProductName |
| Segments |
Top-level properties ONLY — cannot filter by nested object fields |
Can segment on "has done Placed Order where $value > 100", cannot segment on "where Items contains ProductName = X" |
| Flow triggers |
Top-level properties for trigger filters |
Same as conditional splits |
Workaround for nested data: If you need to segment or split on nested data, flatten it to top-level properties:
# Instead of relying on Items[] array for segmentation:
properties = {
"$value": 149.99,
"OrderId": "ORD-123",
"Items": [{"ProductName": "Wireless Headphones", "Category": "Electronics"}],
# Flatten for segmentation:
"ItemCategories": "Electronics,Accessories", # Comma-joined for "contains" filter
"HasElectronics": True, # Boolean flag for split
"TopItemCategory": "Electronics" # Top category for split
}
Custom Event Patterns (DTC / Subscription / Marketplace)
Additional events beyond the standard Shopify/e-commerce schema:
| Event Name |
Trigger |
Key Properties |
Account Created |
New account registered |
account_type, referral_source, signup_channel |
Subscription Started |
Recurring order activated |
$value, frequency, product_ids, plan_name |
Subscription Cancelled |
Recurring order stopped |
reason, plan_name, lifetime_charges |
Reorder Placed |
Repeat purchase of consumable |
$value, OrderId, days_since_last_order, reorder_items |
Wishlist Added |
Item saved for later |
ProductName, ProductID, Categories, Price |
Catalog Browsed |
Category/search activity |
category, search_term, results_count |
Sync key customer properties to profiles for segmentation:
profile_properties = {
"customer_type": "Subscriber",
"interests": ["Skincare", "Wellness"],
"subscription_plan": "Monthly Box",
"account_tier": "VIP",
"first_order_date": "2024-03-15",
"lifetime_order_count": 8,
"avg_order_value": 72.50,
"preferred_categories": ["Skincare", "Supplements"]
}
Data Accessibility Diagnosis
When data exists in Klaviyo but isn't usable where expected:
Symptoms
- "We track [event] but can't segment on [property]"
- "Flow split doesn't see the property we're sending"
- "Profile has the data but segment doesn't pick it up"
Root Causes and Solutions
| Symptom |
Root Cause |
Solution |
| Can't segment on event property |
Property is nested inside an array/object |
Flatten to top-level property on the event |
| Can't split flow on event property |
Property is nested |
Flatten, or use profile property instead |
| Segment doesn't match profiles |
Property is on events, not profiles |
Sync property to profile via API or "Update Profile Property" flow action |
| Profile property exists but segment empty |
Property value format mismatch (string "true" vs boolean true) |
Standardize data types in API sync |
| Event tracked but no flow triggers |
Metric name mismatch (case-sensitive) |
Verify exact metric name in Klaviyo matches API call |
| Flow triggers but filter excludes everyone |
Segment used as flow filter evaluates incorrectly |
Check segment conditions — may reference stale or incorrectly-typed properties |
Diagnosis Workflow
- Check metric exists: Use GET
/metrics/ to verify the event name appears
- Check event properties: Use GET
/events/?filter=... to pull recent events and inspect property structure
- Check profile properties: Use GET
/profiles/{id}/ to verify expected properties are on the profile
- Test segment conditions: Compare segment definition against actual profile data — look for type mismatches, case sensitivity issues
- Test flow trigger: Send a test event and trace whether the flow fires, where it stops, and why
How to Use This Skill
Ask me questions like:
- "How do I track a custom event from my Node.js backend?"
- "Help me set up a bulk profile import script"
- "What are Klaviyo's rate limits and how should I handle them?"
- "How do I verify Klaviyo webhook signatures?"
- "Set up catalog sync for my custom e-commerce platform"
- "How do I implement OAuth for a Klaviyo app?"
- "Design a data pipeline to export Klaviyo data to BigQuery"
- "Help me migrate from Klaviyo v1/v2 API to the current API"
- "Audit my integration — are events structured correctly?"
- "Why can't I segment on a property I'm tracking in events?"
Integration Examples
For complete integration patterns, worked examples with sample output, and code snippets, see EXAMPLES.md.
Scripts
The skill includes utility scripts for API interaction and integration management:
Developer Client
# Track a custom event
python scripts/klaviyo_client.py --action track-event \
--email user@example.com --event "Placed Order" \
--properties '{"value": 99.99, "OrderId": "ORD-123"}'
# Upsert a profile
python scripts/klaviyo_client.py --action upsert-profile \
--email user@example.com \
--properties '{"first_name": "Jane", "loyalty_tier": "Gold"}'
# List catalog items
python scripts/klaviyo_client.py --action catalog-items --format table
# Export profiles to CSV
python scripts/klaviyo_client.py --action export-profiles \
--max-pages 10 --format csv --output profiles.csv
Developer Tools
# Integration health check
python scripts/dev_tools.py --tool health-check
# Validate event tracking
python scripts/dev_tools.py --tool validate-events \
--events "Placed Order,Started Checkout,Viewed Product"
# Test webhook endpoint
python scripts/dev_tools.py --tool test-webhook \
--webhook-url https://example.com/webhooks/klaviyo
# Import profiles from CSV
python scripts/dev_tools.py --tool import-csv \
--file contacts.csv --list-id LIST_ID
# Export data with pagination
python scripts/dev_tools.py --tool export-data \
--resource profiles --max-records 5000 --output profiles.csv
The scripts handle API authentication, rate limiting, and JSON:API formatting. I'll help interpret results and provide implementation guidance.
Troubleshooting
Authentication Error: Verify that:
KLAVIYO_API_KEY is set as an environment variable or in a .env file
- The key starts with
pk_ (private API key, not public)
- The key has the required scopes for your operation (e.g.,
events:write for tracking, profiles:write for imports)
Rate Limit Errors (429): The SDK handles retries automatically (up to 3 retries with 60s max delay). If you still hit limits:
- Queue and throttle bulk operations (max 10 req/s for imports)
- Check
RateLimit-Remaining header proactively
- Implement exponential backoff with jitter for raw HTTP
Bulk Import Errors: Check that:
- Batch size does not exceed 10,000 profiles per job
- Email or phone is provided for each profile (at least one identifier)
- CSV column names match expected field names
Import Errors: Install required packages:
pip install klaviyo-api python-dotenv pandas
Security Notes
- Never hardcode API keys in code or commit them to version control
- Store keys in environment variables or
.env files
- Add
.env to .gitignore
- Use minimum required scopes — only enable write access where needed
- Rotate API keys periodically in Klaviyo Settings
- For OAuth integrations, store client secrets securely and refresh tokens before expiry
Data Privacy
This skill interacts with the Klaviyo API for integration development. When using write operations:
- Validate data before sending to avoid corrupting profile records
- Never log or store API keys, webhook secrets, or PII in plain text
- Use idempotency keys to prevent duplicate events
- Implement webhook signature verification to prevent spoofing
- Follow GDPR/CCPA requirements when handling profile data
- Use the Data Privacy Deletion endpoint for right-to-erasure requests
All operations are performed via the official Klaviyo API with proper authentication.
For detailed API endpoint reference, code patterns, authentication, and architecture diagrams, see REFERENCE.md.
For marketing strategy, flow optimization, and campaign auditing, use the klaviyo-analyst skill.
1---2name: klaviyo-developer3description: Klaviyo API and developer integration expertise. Event tracking, SDKs, webhooks, rate limits, OAuth, catalog sync, and code patterns. Use when the user asks about Klaviyo API, integrating with Klaviyo, tracking events, building custom integrations, webhook handling, or developer implementation. For marketing strategy, flow optimization, and campaign auditing, see the klaviyo-analyst skill.4license: MIT5origin: custom6author: Rebecca Rae Barton7author_url: https://github.com/thatrebeccarae8metadata:9 source: https://skillmd.com/skills/thatrebeccarae/klaviyo-developer10 version: 1.1.011 category: email-lifecycle12 domain: klaviyo13 updated: 2026-05-1414 tested: 2026-05-1415 tested_with: "Claude Code v2.1, Klaviyo MCP API revision 2026-04-15"16---1718# Klaviyo Developer1920Expert-level guidance for building with the Klaviyo API — custom event tracking, profile management, SDK integration, webhooks, catalog sync, and data pipeline architecture.2122> For marketing strategy, flow auditing, segmentation, deliverability, and campaign optimization, see the **klaviyo-analyst** skill.2324## Install2526```bash27git clone https://github.com/thatrebeccarae/claude-marketing.git && cp -r claude-marketing/skills/klaviyo-developer ~/.claude/skills/28```2930## MCP vs. SDK: When to Use Which3132This skill is **SDK-first by design** — you're building production integrations against the Klaviyo API, not running ad-hoc queries. That said, Klaviyo's official MCP server is the right tool for parts of integration work, and you should know when to reach for it.3334| Use the **SDK** (`klaviyo-api`) when… | Use the **MCP** (`https://mcp.klaviyo.com/mcp`) when… |35|---|---|36| Writing production event-tracking code | Exploring an account's event schema before writing the integration |37| Building bulk import / sync pipelines | Sanity-checking that events landed with the right property shape |38| Implementing webhook handlers | Pulling a quick property inventory during integration design |39| Catalog sync jobs | Inspecting flow trigger conditions while debugging why an event isn't firing a flow |40| Anything in CI, cron, or a deployed service | Iterating on event schema design with the marketing analyst in the room |4142The MCP wraps the same API this skill targets, so the schema rules, rate limits, and nesting constraints below apply equally to MCP-driven calls. The MCP is currently pinned to API revision `2026-04-15` — keep that in mind if you're versioning your own SDK code against an older revision.4344For the full MCP tool inventory, OAuth setup, and read-only mode flag, see [REFERENCE.md](REFERENCE.md#mcp-server-reference). For audit/analyst work, see the **klaviyo-analyst** skill — it's built around the MCP.4546## Core Capabilities4748### API Authentication & Versioning49- Private API key setup and key management best practices50- Public API key usage for client-side tracking (klaviyo.js)51- OAuth 2.0 authorization flow for third-party apps52- API revision headers and version lifecycle management5354### Custom Event Tracking55- Server-side event tracking via Events API56- Client-side tracking with klaviyo.js57- Event schema design and property naming conventions58- Idempotent event submission patterns5960### Profile Management61- Profile create, upsert, and bulk import patterns62- Custom property management and data types63- Subscription management (email, SMS consent)64- Profile merge and deduplication strategies6566### Webhooks67- Webhook subscription setup and event types68- Payload verification and signature validation69- Retry handling and idempotent webhook processing7071### SDK Usage & Libraries72- Python SDK (klaviyo-api)73- Node.js SDK (klaviyo-api-node)74- Ruby, PHP, and other community SDKs75- SDK initialization, error handling, and retry configuration7677### Catalog & Product Feed Sync78- Catalog item create/update/delete via API79- Category and variant management80- Product feed sync architecture for recommendations81- Handling large catalogs with bulk operations8283### Data Export & Warehouse Sync84- Metric aggregation API for reporting85- Profile and event export patterns86- Cursor-based pagination for large datasets87- ETL pipeline design for data warehouse integration8889## SDK Quick Reference9091| Language | Package | Install |92|----------|---------|---------|93| Python | `klaviyo-api` | `pip install klaviyo-api` |94| Node.js | `klaviyo-api` | `npm install klaviyo-api` |95| Ruby | `klaviyo-api-sdk` | `gem install klaviyo-api-sdk` |96| PHP | `klaviyo/api` | `composer require klaviyo/api` |9798## Rate Limits99100| Endpoint Category | Limit | Window |101|-------------------|-------|--------|102| Most endpoints | 75 requests | per second |103| Bulk imports | 10 requests | per second |104| Profile/Event create | 350 requests | per second |105| Campaign send | 10 requests | per second |106107Headers returned: `RateLimit-Limit`, `RateLimit-Remaining`, `RateLimit-Reset`108109## API Revision Timeline110111| Revision | Key Changes |112|----------|-------------|113| 2026-01-15 | Latest. Custom Objects Ingestion, Geofencing API (beta). |114| 2025-10-15 | Forms API, Flow Actions API, SMS ROI reporting. |115| 2025-07-15 | Mapped Metrics API, Custom Objects API (GA). |116| 2025-04-15 | Web Feeds API, Custom Metrics, Push Token registration. |117| 2025-01-15 | Reviews APIs, Flows Create API, Campaign image management. |118| 2024-10-15 | Universal Content API, Form/Segment Reporting, Reviews API. |119| 2024-07-15 | Forms API (retrieval), Webhooks API. |120| 2024-02-15 | Reporting API, Create or Update Profile (upsert). |121122Always include the `revision` header in API requests.123124## Essential Developer Checklist1251261. **API key management** — Store private keys in environment variables, never commit to source. Rotate keys periodically.1272. **Revision header** — Always include `revision: YYYY-MM-DD` header. Pin to a specific version.1283. **Rate limit handling** — Implement exponential backoff with jitter on 429 responses.1294. **Idempotent events** — Include a unique `unique_id` property to prevent duplicate event tracking.1305. **Profile upserts** — Use `POST /profiles/` with existing identifier for upsert behavior (creates or updates).1316. **Webhook verification** — Validate webhook signatures before processing payloads.1327. **Pagination** — Use cursor-based pagination for list endpoints. Never assume result counts.1338. **Error handling** — Parse JSON:API error responses. Handle 4xx (client) and 5xx (server) differently.1349. **SDK initialization** — Configure SDK with API key at app startup, not per-request.13510. **Testing** — Use Klaviyo test/sandbox accounts. Mock API responses in unit tests.136137## Workflow: Custom Integration Setup138139When building a custom Klaviyo integration:1401411. **Define requirements** — What events to track, what profile data to sync, what triggers are needed1422. **API key provisioning** — Create a private API key with minimum required scopes1433. **Event schema design** — Map business events to Klaviyo metric names and properties1444. **Profile sync strategy** — Determine identifier (email vs phone vs external_id), upsert frequency1455. **Implement tracking** — Server-side event tracking with proper error handling and retries1466. **Catalog sync** (if applicable) — Product feed sync for recommendations and browse abandonment1477. **Webhook setup** — Subscribe to relevant events, implement handler with signature verification1488. **Rate limit strategy** — Queue and throttle API calls, implement backoff1499. **Monitoring** — Log API errors, track event delivery rates, alert on failures15010. **Testing & validation** — Verify events appear in Klaviyo, test flow triggers, validate profile data151152## Workflow: Integration Health Audit153154When auditing an existing Klaviyo integration for health and data quality:1551561. **Inventory active integrations** — List all configured integrations (built-in and custom). Identify active vs stale connections.1572. **Map event sources** — For each metric in the account, identify its source (built-in integration, custom API, Klaviyo-internal, form). Flag metrics with zero recent volume.1583. **Audit event schemas** — Pull property structures for key events (Placed Order, Started Checkout, Viewed Product, Added to Cart). Check for:159 - Missing standard properties (e.g., `$value`, `ItemNames`, line items)160 - Duplicate/redundant metrics (e.g., "Placed Order" and "Order Placed" from different sources)161 - Inconsistent property naming (camelCase vs snake_case across events)1624. **Check profile data pipeline** — Verify profile properties are being synced correctly. Look for:163 - Properties set by API vs properties set by events164 - Stale properties (set once, never updated)165 - Properties used in segmentation vs properties sitting unused1665. **Review catalog sync** — Verify product catalog is synced and fresh. Check:167 - Total catalog items vs expected product count168 - Last sync timestamp169 - Variant coverage (are variants synced or just parent products?)170 - Category structure completeness1716. **Assess flow trigger architecture** — Map how flows are triggered:172 - Direct metric triggers (robust) vs segment-entry triggers via API-synced properties (brittle)173 - Single points of failure (if API sync breaks, do all flows stop?)174 - Trigger redundancy and fallback patterns1757. **Identify data accessibility gaps** — Check for data that exists in event payloads but isn't usable:176 - Nested objects in event properties (can use in templates, cannot use in segments/splits)177 - Properties available in events but not synced to profiles (can't segment on them)178 - Events tracked but not used in any flow or segment1798. **Produce integration health report** — Document findings with severity ratings:180 - **Critical**: Integration failures, broken event tracking, data loss181 - **High**: Missing standard events, duplicate metrics, flow trigger fragility182 - **Medium**: Unused events, incomplete catalog, stale profile properties183 - **Low**: Naming inconsistencies, optimization opportunities184185## Event Schema Best Practices186187### Property Naming Conventions188- Use **PascalCase** for standard Klaviyo properties: `ProductName`, `ItemPrice`, `OrderId`189- Use **snake_case** for custom properties: `business_type`, `account_id`, `reorder_count`190- Never mix conventions within a single event — pick one and be consistent191- Prefix custom properties to avoid collision with Klaviyo-reserved names192193### Required Properties by Event194195| Event | Required Properties | Revenue Property |196|-------|-------------------|------------------|197| Placed Order | `$value`, `OrderId`, `Items[]` (line items) | `$value` |198| Started Checkout | `$value`, `CheckoutURL`, `Items[]` | `$value` |199| Viewed Product | `ProductName`, `ProductID`, `URL`, `ImageURL` | — |200| Added to Cart | `$value`, `AddedItemProductName`, `AddedItemProductID`, `Items[]` | `$value` |201| Fulfilled Order | `$value`, `OrderId` | — |202203### Nesting Rules and Limitations204205Klaviyo handles nested objects differently depending on where you access them:206207| Context | Access Level | Example |208|---------|-------------|---------|209| **Email/SMS templates** | Full access via Jinja — can loop over arrays, access nested properties | `{% for item in event.Items %}{{ item.ProductName }}{% endfor %}` |210| **Flow conditional splits** | Top-level properties ONLY — cannot access nested object fields | Can split on `event.OrderId`, cannot split on `event.Items[0].ProductName` |211| **Segments** | Top-level properties ONLY — cannot filter by nested object fields | Can segment on "has done Placed Order where $value > 100", cannot segment on "where Items contains ProductName = X" |212| **Flow triggers** | Top-level properties for trigger filters | Same as conditional splits |213214**Workaround for nested data**: If you need to segment or split on nested data, flatten it to top-level properties:215```python216# Instead of relying on Items[] array for segmentation:217properties = {218 "$value": 149.99,219 "OrderId": "ORD-123",220 "Items": [{"ProductName": "Wireless Headphones", "Category": "Electronics"}],221 # Flatten for segmentation:222 "ItemCategories": "Electronics,Accessories", # Comma-joined for "contains" filter223 "HasElectronics": True, # Boolean flag for split224 "TopItemCategory": "Electronics" # Top category for split225}226```227228### Custom Event Patterns (DTC / Subscription / Marketplace)229230Additional events beyond the standard Shopify/e-commerce schema:231232| Event Name | Trigger | Key Properties |233|------------|---------|----------------|234| `Account Created` | New account registered | `account_type`, `referral_source`, `signup_channel` |235| `Subscription Started` | Recurring order activated | `$value`, `frequency`, `product_ids`, `plan_name` |236| `Subscription Cancelled` | Recurring order stopped | `reason`, `plan_name`, `lifetime_charges` |237| `Reorder Placed` | Repeat purchase of consumable | `$value`, `OrderId`, `days_since_last_order`, `reorder_items` |238| `Wishlist Added` | Item saved for later | `ProductName`, `ProductID`, `Categories`, `Price` |239| `Catalog Browsed` | Category/search activity | `category`, `search_term`, `results_count` |240241Sync key customer properties to profiles for segmentation:242```python243profile_properties = {244 "customer_type": "Subscriber",245 "interests": ["Skincare", "Wellness"],246 "subscription_plan": "Monthly Box",247 "account_tier": "VIP",248 "first_order_date": "2024-03-15",249 "lifetime_order_count": 8,250 "avg_order_value": 72.50,251 "preferred_categories": ["Skincare", "Supplements"]252}253```254255## Data Accessibility Diagnosis256257When data exists in Klaviyo but isn't usable where expected:258259### Symptoms260- "We track [event] but can't segment on [property]"261- "Flow split doesn't see the property we're sending"262- "Profile has the data but segment doesn't pick it up"263264### Root Causes and Solutions265266| Symptom | Root Cause | Solution |267|---------|-----------|----------|268| Can't segment on event property | Property is nested inside an array/object | Flatten to top-level property on the event |269| Can't split flow on event property | Property is nested | Flatten, or use profile property instead |270| Segment doesn't match profiles | Property is on events, not profiles | Sync property to profile via API or "Update Profile Property" flow action |271| Profile property exists but segment empty | Property value format mismatch (string "true" vs boolean `true`) | Standardize data types in API sync |272| Event tracked but no flow triggers | Metric name mismatch (case-sensitive) | Verify exact metric name in Klaviyo matches API call |273| Flow triggers but filter excludes everyone | Segment used as flow filter evaluates incorrectly | Check segment conditions — may reference stale or incorrectly-typed properties |274275### Diagnosis Workflow2761. **Check metric exists**: Use GET `/metrics/` to verify the event name appears2772. **Check event properties**: Use GET `/events/?filter=...` to pull recent events and inspect property structure2783. **Check profile properties**: Use GET `/profiles/{id}/` to verify expected properties are on the profile2794. **Test segment conditions**: Compare segment definition against actual profile data — look for type mismatches, case sensitivity issues2805. **Test flow trigger**: Send a test event and trace whether the flow fires, where it stops, and why281282## How to Use This Skill283284Ask me questions like:285- "How do I track a custom event from my Node.js backend?"286- "Help me set up a bulk profile import script"287- "What are Klaviyo's rate limits and how should I handle them?"288- "How do I verify Klaviyo webhook signatures?"289- "Set up catalog sync for my custom e-commerce platform"290- "How do I implement OAuth for a Klaviyo app?"291- "Design a data pipeline to export Klaviyo data to BigQuery"292- "Help me migrate from Klaviyo v1/v2 API to the current API"293- "Audit my integration — are events structured correctly?"294- "Why can't I segment on a property I'm tracking in events?"295296## Integration Examples297298For complete integration patterns, worked examples with sample output, and code snippets, see [EXAMPLES.md](EXAMPLES.md).299300## Scripts301302The skill includes utility scripts for API interaction and integration management:303304### Developer Client305```bash306# Track a custom event307python scripts/klaviyo_client.py --action track-event \308 --email user@example.com --event "Placed Order" \309 --properties '{"value": 99.99, "OrderId": "ORD-123"}'310311# Upsert a profile312python scripts/klaviyo_client.py --action upsert-profile \313 --email user@example.com \314 --properties '{"first_name": "Jane", "loyalty_tier": "Gold"}'315316# List catalog items317python scripts/klaviyo_client.py --action catalog-items --format table318319# Export profiles to CSV320python scripts/klaviyo_client.py --action export-profiles \321 --max-pages 10 --format csv --output profiles.csv322```323324### Developer Tools325```bash326# Integration health check327python scripts/dev_tools.py --tool health-check328329# Validate event tracking330python scripts/dev_tools.py --tool validate-events \331 --events "Placed Order,Started Checkout,Viewed Product"332333# Test webhook endpoint334python scripts/dev_tools.py --tool test-webhook \335 --webhook-url https://example.com/webhooks/klaviyo336337# Import profiles from CSV338python scripts/dev_tools.py --tool import-csv \339 --file contacts.csv --list-id LIST_ID340341# Export data with pagination342python scripts/dev_tools.py --tool export-data \343 --resource profiles --max-records 5000 --output profiles.csv344```345346The scripts handle API authentication, rate limiting, and JSON:API formatting. I'll help interpret results and provide implementation guidance.347348## Troubleshooting349350**Authentication Error**: Verify that:351- `KLAVIYO_API_KEY` is set as an environment variable or in a `.env` file352- The key starts with `pk_` (private API key, not public)353- The key has the required scopes for your operation (e.g., `events:write` for tracking, `profiles:write` for imports)354355**Rate Limit Errors (429)**: The SDK handles retries automatically (up to 3 retries with 60s max delay). If you still hit limits:356- Queue and throttle bulk operations (max 10 req/s for imports)357- Check `RateLimit-Remaining` header proactively358- Implement exponential backoff with jitter for raw HTTP359360**Bulk Import Errors**: Check that:361- Batch size does not exceed 10,000 profiles per job362- Email or phone is provided for each profile (at least one identifier)363- CSV column names match expected field names364365**Import Errors**: Install required packages:366```bash367pip install klaviyo-api python-dotenv pandas368```369370## Security Notes371372- **Never hardcode** API keys in code or commit them to version control373- Store keys in environment variables or `.env` files374- Add `.env` to `.gitignore`375- Use **minimum required scopes** — only enable write access where needed376- Rotate API keys periodically in Klaviyo Settings377- For OAuth integrations, store client secrets securely and refresh tokens before expiry378379## Data Privacy380381This skill interacts with the Klaviyo API for integration development. When using write operations:382- Validate data before sending to avoid corrupting profile records383- Never log or store API keys, webhook secrets, or PII in plain text384- Use idempotency keys to prevent duplicate events385- Implement webhook signature verification to prevent spoofing386- Follow GDPR/CCPA requirements when handling profile data387- Use the Data Privacy Deletion endpoint for right-to-erasure requests388389All operations are performed via the official Klaviyo API with proper authentication.390391For detailed API endpoint reference, code patterns, authentication, and architecture diagrams, see [REFERENCE.md](REFERENCE.md).392393For marketing strategy, flow optimization, and campaign auditing, use the **klaviyo-analyst** skill.