Skip to content
customerio-cost-tuning logo

Customer.io Cost Tuning

customerio-cost-tuning

Optimize Customer.io costs and usage. Use when reducing expenses, optimizing usage, or right-sizing your Customer.io plan. Trigger with phrases like "customer.io cost", "reduce customer.io spend", "customer.io billing", "customer.io pricing".

SKILL.md

Full skill instructions

Customer.io Cost Tuning

Overview

Optimize Customer.io costs by managing profiles, reducing unnecessary operations, and right-sizing your usage.

Prerequisites

  • Access to Customer.io billing dashboard
  • Understanding of pricing model
  • API access for usage analysis

Customer.io Pricing Model

ComponentPricing Basis
ProfilesNumber of people tracked
EmailsVolume sent (included amount varies)
SMSPer message sent
PushVolume sent
ObjectsIncluded with plan

Instructions

Step 1: Profile Cleanup

// scripts/​profile-audit.ts
import { APIClient, RegionUS } from '@customerio/​track';

interface ProfileAudit {
  total: number;
  inactive30Days: number;
  inactive90Days: number;
  noEmail: number;
  suppressed: number;
  recommendations: string[];
}

async function auditProfiles(): Promise<ProfileAudit> {
  const audit: ProfileAudit = {
    total: 0,
    inactive30Days: 0,
    inactive90Days: 0,
    noEmail: 0,
    suppressed: 0,
    recommendations: []
  };

  // Query via Customer.io App API or export
  // Analyze profile data

  const now = Math.floor(Date.now() / 1000);
  const thirtyDaysAgo = now - (30 * 24 * 60 * 60);
  const ninetyDaysAgo = now - (90 * 24 * 60 * 60);

  // Example analysis
  if (audit.inactive90Days > audit.total * 0.3) {
    audit.recommendations.push(
      'Consider archiving profiles inactive >90 days to reduce costs'
    );
  }

  if (audit.noEmail > audit.total * 0.1) {
    audit.recommendations.push(
      'Remove profiles without email addresses (cannot receive communications)'
    );
  }

  return audit;
}

Step 2: Suppress Inactive Users

// lib/​profile-management.ts
import { TrackClient, RegionUS } from '@customerio/​track';

const client = new TrackClient(
  process.env.CUSTOMERIO_SITE_ID!,
  process.env.CUSTOMERIO_API_KEY!,
  { region: RegionUS }
);

// Suppress users who haven't engaged
async function suppressInactiveUsers(
  userIds: string[],
  dryRun: boolean = true
): Promise<{ suppressed: string[]; errors: string[] }> {
  const results = { suppressed: [] as string[], errors: [] as string[] };

  for (const userId of userIds) {
    if (dryRun) {
      console.log(`[DRY RUN] Would suppress: ${userId}`);
      results.suppressed.push(userId);
      continue;
    }

    try {
      await client.suppress(userId);
      results.suppressed.push(userId);
    } catch (error: any) {
      results.errors.push(`${userId}: ${error.message}`);
    }
  }

  return results;
}

// Delete users to fully remove from billing
async function deleteUsers(
  userIds: string[],
  dryRun: boolean = true
): Promise<{ deleted: string[]; errors: string[] }> {
  const results = { deleted: [] as string[], errors: [] as string[] };

  for (const userId of userIds) {
    if (dryRun) {
      console.log(`[DRY RUN] Would delete: ${userId}`);
      results.deleted.push(userId);
      continue;
    }

    try {
      await client.destroy(userId);
      results.deleted.push(userId);
    } catch (error: any) {
      results.errors.push(`${userId}: ${error.message}`);
    }
  }

  return results;
}

Step 3: Event Deduplication

// lib/​smart-tracking.ts
import { LRUCache } from 'lru-cache';
import { TrackClient } from '@customerio/​track';

const recentEvents = new LRUCache<string, number>({
  max: 100000,
  ttl: 3600000 // 1 hour
});

interface TrackingConfig {
  dedupWindowMs: number;
  skipEvents: string[];
  sampleRate: Record<string, number>;
}

const config: TrackingConfig = {
  dedupWindowMs: 60000, // 1 minute dedup window
  skipEvents: [
    'page_viewed', // High volume, low value
    'heartbeat'
  ],
  sampleRate: {
    'feature_used': 0.1, // Sample 10% of feature usage
    'search_performed': 0.5 // Sample 50% of searches
  }
};

export function shouldTrackEvent(
  userId: string,
  eventName: string,
  data?: Record<string, any>
): boolean {
  // Skip excluded events
  if (config.skipEvents.includes(eventName)) {
    return false;
  }

  // Apply sampling for high-volume events
  const sampleRate = config.sampleRate[eventName];
  if (sampleRate !== undefined && Math.random() > sampleRate) {
    return false;
  }

  // Deduplicate identical events
  const eventKey = `${userId}:${eventName}:${JSON.stringify(data || {})}`;
  if (recentEvents.has(eventKey)) {
    return false;
  }

  recentEvents.set(eventKey, Date.now());
  return true;
}

Step 4: Email Cost Optimization

// lib/​email-optimization.ts
interface EmailOptimizationConfig {
  // Skip transactional emails for users who never open
  skipInactiveAfterDays: number;
  // Consolidate multiple notifications
  batchNotifications: boolean;
  batchWindowMinutes: number;
  // Suppress bounced emails
  suppressAfterBounces: number;
}

const emailConfig: EmailOptimizationConfig = {
  skipInactiveAfterDays: 180, // Skip users inactive 6 months
  batchNotifications: true,
  batchWindowMinutes: 30,
  suppressAfterBounces: 3
};

// Check if user should receive emails
async function shouldSendEmail(
  userId: string,
  emailType: 'transactional' | 'marketing'
): Promise<boolean> {
  // Always send critical transactional (password reset, security)
  if (emailType === 'transactional') {
    return true;
  }

  // Check engagement history
  const user = await getUserMetrics(userId);

  // Skip users who haven't opened in 6 months
  const sixMonthsAgo = Date.now() - (180 * 24 * 60 * 60 * 1000);
  if (user.lastEmailOpenedAt < sixMonthsAgo) {
    return false;
  }

  // Skip users with high bounce count
  if (user.bounceCount >= emailConfig.suppressAfterBounces) {
    return false;
  }

  return true;
}

Step 5: Usage Monitoring Dashboard

// lib/​usage-monitor.ts
interface UsageMetrics {
  period: string;
  profiles: {
    total: number;
    new: number;
    deleted: number;
  };
  events: {
    total: number;
    byType: Record<string, number>;
  };
  emails: {
    sent: number;
    delivered: number;
    opened: number;
    bounced: number;
  };
  estimatedCost: number;
}

async function getUsageMetrics(
  startDate: Date,
  endDate: Date
): Promise<UsageMetrics> {
  // Query Customer.io Reporting API
  // or aggregate from your tracking

  return {
    period: `${startDate.toISOString()} - ${endDate.toISOString()}`,
    profiles: {
      total: 10000,
      new: 500,
      deleted: 100
    },
    events: {
      total: 50000,
      byType: {
        'signed_up': 500,
        'feature_used': 20000,
        'page_viewed': 25000 // Candidate for sampling
      }
    },
    emails: {
      sent: 15000,
      delivered: 14500,
      opened: 4350,
      bounced: 150
    },
    estimatedCost: 299 // Monthly estimate
  };
}

// Alert on unexpected usage spikes
function checkUsageAlerts(metrics: UsageMetrics): string[] {
  const alerts: string[] = [];

  // Profile growth alert
  if (metrics.profiles.new > metrics.profiles.total * 0.1) {
    alerts.push('Unusual profile growth detected');
  }

  // Event volume alert
  if (metrics.events.total > 100000) {
    alerts.push('High event volume - consider sampling');
  }

  // Bounce rate alert
  if (metrics.emails.bounced / metrics.emails.sent > 0.05) {
    alerts.push('High bounce rate - clean email list');
  }

  return alerts;
}

Step 6: Cost Reduction Checklist

## Monthly Cost Review Checklist

### Profile Optimization
- [ ] Remove profiles with no email
- [ ] Archive inactive profiles (>90 days)
- [ ] Suppress hard bounced emails
- [ ] Merge duplicate profiles

### Event Optimization
- [ ] Identify high-volume, low-value events
- [ ] Implement sampling for analytics events
- [ ] Deduplicate redundant events
- [ ] Remove deprecated event types

### Email Optimization
- [ ] Clean suppression list
- [ ] Re-engage or remove inactive subscribers
- [ ] Consolidate notification emails
- [ ] Optimize send frequency

### Plan Optimization
- [ ] Review plan vs actual usage
- [ ] Consider annual billing for discount
- [ ] Evaluate feature usage vs plan tier

Cost Savings Estimates

OptimizationTypical Savings
Profile cleanup10-30%
Event deduplication5-15%
Email list hygiene5-10%
Sampling high-volume events10-20%
Annual billing10-20%

Error Handling

IssueSolution
Accidental deletionCustomer.io has 30-day recovery
Over-suppressionTrack suppression reasons
Usage spikeSet up usage alerts

Resources

Next Steps

After cost optimization, proceed to customerio-reference-architecture for architecture patterns.

More skills from Dicklesworthstone

environment-setup-guide logo
Dicklesworthstone/pi_agent_rust

environment-setup-guide

Guide developers through setting up development environments with proper tools, dependencies, and configurations

1.8K 0
View
exa-policy-guardrails logo
Dicklesworthstone/pi_agent_rust

exa-policy-guardrails

Implement Exa lint rules, policy enforcement, and automated guardrails. Use when setting up code quality rules for Exa integrations, implementing pre-commit hooks, or configuring CI policy checks for Exa best practices. Trigger with phrases like "exa policy", "exa lint", "exa guardrails", "exa be...

1.8K 0
View
documenso-ci-integration logo
Dicklesworthstone/pi_agent_rust

documenso-ci-integration

Configure CI/CD pipelines for Documenso integrations. Use when setting up automated testing, deployment pipelines, or continuous integration for Documenso projects. Trigger with phrases like "documenso CI", "documenso GitHub Actions", "documenso pipeline", "documenso automated testing".

1.8K 0
View
openrouter-model-availability logo
Dicklesworthstone/pi_agent_rust

openrouter-model-availability

Build check model availability and implement fallback chains. Use when building resilient systems or handling model outages. Trigger with phrases like 'openrouter availability', 'openrouter fallback', 'openrouter model down', 'openrouter health check'.

1.8K 0
View
langfuse-enterprise-rbac logo
Dicklesworthstone/pi_agent_rust

langfuse-enterprise-rbac

Configure Langfuse enterprise organization management and access control. Use when implementing team access controls, configuring organization settings, or setting up role-based permissions for Langfuse projects. Trigger with phrases like "langfuse RBAC", "langfuse teams", "langfuse organization"...

1.8K 0
View
cursor-compliance-audit logo
Dicklesworthstone/pi_agent_rust

cursor-compliance-audit

Execute compliance and security auditing for Cursor usage. Triggers on "cursor compliance", "cursor audit", "cursor security review", "cursor soc2", "cursor gdpr". Use when analyzing or auditing cursor compliance audit. Trigger with phrases like "cursor compliance audit", "cursor audit", "cursor".

1.8K 0
View
apollo-ci-integration logo
Dicklesworthstone/pi_agent_rust

apollo-ci-integration

Configure Apollo.io CI/CD integration. Use when setting up automated testing, continuous integration, or deployment pipelines for Apollo integrations. Trigger with phrases like "apollo ci", "apollo github actions", "apollo pipeline", "apollo ci/cd", "apollo automated tests".

1.8K 0
View
python-script logo
Dicklesworthstone/pi_agent_rust

python-script

Create robust Python automation with full logging and safety checks. Use when tasks need complex data processing, authenticated API work, conditional file operations, or error handling beyond simple shell commands.

1.8K 0
View
posthog-multi-env-setup logo
Dicklesworthstone/pi_agent_rust

posthog-multi-env-setup

Configure PostHog across development, staging, and production environments. Use when setting up multi-environment deployments, configuring per-environment secrets, or implementing environment-specific PostHog configurations. Trigger with phrases like "posthog environments", "posthog staging", "po...

1.8K 0
View
ai-agents-architect logo
Dicklesworthstone/pi_agent_rust

ai-agents-architect

Expert in designing and building autonomous AI agents. Masters tool use, memory systems, planning strategies, and multi-agent orchestration. Use when: build agent, AI agent, autonomous agent, tool use, function calling.

1.8K 0
View
insecure-deserialization-checker logo
Dicklesworthstone/pi_agent_rust

insecure-deserialization-checker

Validate insecure deserialization checker operations. Auto-activating skill for Security Fundamentals. Triggers on: insecure deserialization checker, insecure deserialization checker Part of the Security Fundamentals skill category. Use when working with insecure deserialization checker functiona...

1.8K 0
View
path-traversal-finder logo
Dicklesworthstone/pi_agent_rust

path-traversal-finder

Manage path traversal finder operations. Auto-activating skill for Security Fundamentals. Triggers on: path traversal finder, path traversal finder Part of the Security Fundamentals skill category. Use when working with path traversal finder functionality. Trigger with phrases like "path traversa...

1.8K 0
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View