Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Identify and avoid Customer.io anti-patterns and gotchas. Use when reviewing integrations, onboarding developers, or auditing existing Customer.io code. Trigger: "customer.io mistakes", "customer.io anti-patterns", "customer.io gotchas", "customer.io pitfalls", "customer.io code review".
.claude/skills/jeremylongshore-customerio-known-pitfalls/SKILL.md| Model | Eval pass | Runs |
|---|---|---|
| gemini-3.6-flash | 100% | 30 |
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-08 | ✗→✓ | ▲ Improved | 77% | 0% |
| case-13 | ✗→✓ | ▲ Improved | 240% | 0% |
| case-14 | ✗→✓ | ▲ Improved | 81% | 0% |
| case-15 | ✓→✗ | ▼ Worse | 75% | 0% |
| case-01 | ✓→✓ | = Same ✓ | 147% | 0% |
The 12 most common Customer.io integration mistakes, with the wrong pattern, the correct pattern, and why it matters. Use this as a code review checklist and developer onboarding reference.
typescript// WRONG — using Track API key for transactional messages const api = new APIClient(process.env.CUSTOMERIO_TRACK_API_KEY!); // Gets 401 because App API uses a DIFFERENT bearer token // CORRECT — use the App API key const api = new APIClient(process.env.CUSTOMERIO_APP_API_KEY!);
Why: Customer.io has two separate authentication systems. Track API uses Basic Auth (Site ID + Track Key). App API uses Bearer Auth (App Key). They are not interchangeable.
typescript// WRONG — JavaScript Date.now() returns milliseconds await cio.identify("user-1", { created_at: Date.now(), // 1704067200000 → year 55976 }); // CORRECT — Customer.io expects Unix seconds await cio.identify("user-1", { created_at: Math.floor(Date.now() / 1000), // 1704067200 });
Why: Customer.io accepts millisecond values without error but interprets them as seconds, resulting in dates thousands of years in the future. Segments using date comparisons silently break.
typescript// WRONG — tracking before identifying creates orphaned events await cio.track("new-user", { name: "signed_up", data: {} }); // User profile doesn't exist yet — event may be lost // CORRECT — always identify first await cio.identify("new-user", { email: "user@example.com" }); await cio.track("new-user", { name: "signed_up", data: {} });
Why: Track calls on non-existent users may be silently dropped. Always identify() before track().
typescript// WRONG — email can change, creating duplicate profiles await cio.identify("user@example.com", { email: "user@example.com" }); // When user changes email, old profile orphaned, new one created // CORRECT — use immutable database ID await cio.identify("usr_abc123", { email: "user@example.com", // Email as attribute, not ID });
Why: The first argument to identify() is the permanent user ID. If you use email and the user changes it, you get two profiles. Use your database primary key instead.
typescript// WRONG — user can't receive email campaigns await cio.identify("user-1", { first_name: "Jane", plan: "pro", // No email attribute! }); // CORRECT — always include email for email campaigns await cio.identify("user-1", { email: "jane@example.com", first_name: "Jane", plan: "pro", });
Why: Without an email attribute, the user profile exists but can't receive any email campaigns or transactional messages.
typescript// WRONG — creates hundreds of unique event names await cio.track("user-1", { name: `viewed_${productId}`, // "viewed_SKU-12345" data: {}, }); // CORRECT — use a static name with data properties await cio.track("user-1", { name: "product_viewed", // Consistent, filterable data: { product_id: productId }, // Dynamic data in properties });
Why: Dynamic event names pollute your event catalog and make it impossible to create campaign triggers. Use a fixed set of event names and pass variations as data properties.
typescript// WRONG — API call adds 200ms+ to every request app.post("/api/action", async (req, res) => { const result = await doBusinessLogic(req.body); await cio.track(req.user.id, { name: "action_taken", data: {} }); // BLOCKS response res.json(result); }); // CORRECT — fire-and-forget for non-critical tracking app.post("/api/action", async (req, res) => { const result = await doBusinessLogic(req.body); cio.track(req.user.id, { name: "action_taken", data: {} }) .catch((err) => console.error("CIO track failed:", err.message)); res.json(result); // Returns immediately });
Why: Customer.io tracking is non-critical analytics. Don't add 200ms+ latency to every user request.
typescript// WRONG — keep sending to bounced addresses, damaging sender reputation // (No webhook handler for bounces) // CORRECT — suppress users who bounce async function handleBounceWebhook(event: { customer_id: string }) { await cio.suppress(event.customer_id); console.warn(`Suppressed bounced user: ${event.customer_id}`); }
Why: Continuing to send to bounced addresses damages your sender reputation, eventually causing all your emails to go to spam.
typescript// WRONG — creates a new TCP connection for every API call app.post("/track", async (req, res) => { const cio = new TrackClient(siteId, apiKey, { region: RegionUS }); await cio.track(req.body.userId, req.body.event); res.sendStatus(200); }); // CORRECT — singleton, created once const cio = new TrackClient(siteId, apiKey, { region: RegionUS }); app.post("/track", async (req, res) => { await cio.track(req.body.userId, req.body.event); res.sendStatus(200); });
Why: Each new TrackClient() creates fresh connections. Singleton reuses TCP connections, reducing latency by 50-80%.
typescript// WRONG — multiple naming conventions await cio.track(userId, { name: "UserSignedUp" }); // PascalCase await cio.track(userId, { name: "user-signed-up" }); // kebab-case await cio.track(userId, { name: "user signed up" }); // spaces // CORRECT — consistent snake_case everywhere await cio.track(userId, { name: "user_signed_up" });
Why: Event names are case-sensitive. Inconsistent naming means campaign triggers only match one variant, and your event catalog becomes a mess.
typescript// WRONG — blasting API at full speed during import for (const user of allUsers) { await cio.identify(user.id, user.attrs); // 1000+ req/sec → 429 errors } // CORRECT — rate-limited processing import Bottleneck from "bottleneck"; const limiter = new Bottleneck({ maxConcurrent: 10, minTime: 15 }); for (const user of allUsers) { await limiter.schedule(() => cio.identify(user.id, user.attrs)); }
Why: Customer.io rate limits at ~100 req/sec. Without throttling, bulk operations trigger 429 errors and potentially get your API key temporarily blocked.
typescript// WRONG — PII in event names is unsanitizable await cio.track(userId, { name: `email_sent_to_john@example.com` }); // CORRECT — PII only in data properties (can be deleted per GDPR) await cio.track(userId, { name: "email_sent", data: { recipient: "john@example.com" }, });
Why: Event names are indexed and cached. PII in event names can't be deleted for GDPR compliance. Always put PII in event data properties.
| # | Pitfall | Fix | |---|---------|-----| | 1 | Wrong API key type | Track key for tracking, App key for transactional | | 2 | Millisecond timestamps | Math.floor(Date.now() / 1000) | | 3 | Track before identify | Always identify() first | | 4 | Email as user ID | Use immutable database ID | | 5 | Missing email attribute | Include email in identify() | | 6 | Dynamic event names | Static names, dynamic data properties | | 7 | Blocking request path | Fire-and-forget with .catch() | | 8 | No bounce handling | Suppress bounced users via webhook | | 9 | New client per request | Singleton pattern | | 10 | Inconsistent event names | Always snake_case | | 11 | No rate limiting | Use Bottleneck or p-queue | | 12 | PII in event names | PII in data properties only |
bash# Quick grep audit for common pitfalls in your codebase echo "=== Customer.io Pitfall Audit ===" echo "--- Checking for Date.now() without /1000 ---" grep -rn "created_at.*Date.now()" --include="*.ts" --include="*.js" \ | grep -v "/ 1000" || echo "OK" echo "--- Checking for new TrackClient inside functions ---" grep -rn "new TrackClient" --include="*.ts" --include="*.js" \ | grep -v "^.*const\|^.*let\|^.*export" || echo "OK" echo "--- Checking for dynamic event names ---" grep -rn "name:.*\`" --include="*.ts" --include="*.js" \ | grep "track\|Track" || echo "OK" echo "--- Checking for blocking await in routes ---" grep -rn "await.*cio\.\|await.*track\.\|await.*identify" --include="*.ts" \ | grep "router\.\|app\." || echo "Review these for fire-and-forget"
After reviewing pitfalls, use customerio-reliability-patterns for fault tolerance.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | pass→pass | 7,867 | 6,637 | -16% | 1 | 1 | 0% | 1,587 | 3,926 | +147% | 0 | 0 | — |
case-02 | pass→pass | 5,505 | 4,984 | -9% | 1 | 1 | 0% | 1,161 | 3,553 | +206% | 0 | 0 | — |
case-03 | pass→pass | 10,701 | 6,707 | -37% | 1 | 1 | 0% | 2,000 | 3,793 | +90% | 0 | 0 | — |
case-04 | pass→pass | 8,334 | 5,374 | -36% | 1 | 1 | 0% | 1,514 | 3,467 | +129% | 0 | 0 | — |
case-05 | pass→pass | 2,762 | 2,449 | -11% | 1 | 1 | 0% | 561 | 3,025 | +439% | 0 | 0 | — |
case-06 | pass→pass | 9,499 | 6,980 | -27% | 1 | 1 | 0% | 1,823 | 3,906 | +114% | 0 | 0 | — |
case-07 | pass→pass | 12,961 | 8,235 | -36% | 1 | 1 | 0% | 2,595 | 4,154 | +60% | 0 | 0 | — |
case-08 | fail→pass | 10,429 | 5,640 | -46% | 1 | 1 | 0% | 1,946 | 3,449 | +77% | 0 | 0 | — |
case-09 | pass→pass | 9,966 | 9,020 | -9% | 1 | 1 | 0% | 1,911 | 4,251 | +122% | 0 | 0 | — |
case-10 | pass→pass | 7,285 | 4,281 | -41% | 1 | 1 | 0% | 1,282 | 3,311 | +158% | 0 | 0 | — |
case-11 | pass→pass | 16,106 | 15,290 | -5% | 1 | 1 | 0% | 3,044 | 5,397 | +77% | 0 | 0 | — |
case-12 | pass→pass | 8,098 | 3,904 | -52% | 1 | 1 | 0% | 1,407 | 3,234 | +130% | 0 | 0 | — |
case-13 | fail→pass | 27,263 | 14,073 | -48% | 1 | 1 | 0% | 1,626 | 5,526 | +240% | 0 | 0 | — |
case-14 | fail→pass | 13,431 | 9,599 | -29% | 1 | 1 | 0% | 2,425 | 4,383 | +81% | 0 | 0 | — |
case-15 | pass→fail | 13,879 | 9,045 | -35% | 1 | 1 | 0% | 2,426 | 4,247 | +75% | 0 | 0 | — |
case-16 | pass→pass | 6,740 | 5,538 | -18% | 1 | 1 | 0% | 1,272 | 3,562 | +180% | 0 | 0 | — |
case-17 | pass→pass | 4,986 | 3,349 | -33% | 1 | 1 | 0% | 914 | 3,072 | +236% | 0 | 0 | — |
case-18 | pass→pass | 2,702 | 2,820 | +4% | 1 | 1 | 0% | 463 | 3,080 | +565% | 0 | 0 | — |
case-19 | pass→pass | 12,734 | 13,863 | +9% | 1 | 1 | 0% | 2,127 | 4,920 | +131% | 0 | 0 | — |
case-20 | pass→pass | 5,481 | 4,327 | -21% | 1 | 1 | 0% | 1,052 | 3,384 | +222% | 0 | 0 | — |
case-21 | pass→pass | 13,835 | 10,736 | -22% | 1 | 1 | 0% | 2,629 | 4,696 | +79% | 0 | 0 | — |
case-22 | pass→pass | 9,854 | 6,733 | -32% | 1 | 1 | 0% | 1,848 | 3,878 | +110% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted, and 21 counted toward the lift figure. The other 1 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +9 percentage points is the difference between those two pass rates over the 21 comparable cases. 1 case got worse with the skill loaded, and it is included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.