Claude
Skills
Sign in
Back

customer-segmentation

Included with Lifetime
$97 forever

Segment customers by purchase behavior, recency, and spend using Klaviyo, your platform's built-in tools, or a custom RFM analysis to power targeted marketing

customer-crmsegmentationrfmcohortbehavioraltargetingcrmcustomer-analyticslifecycle

What this skill does


# Customer Segmentation

## Overview

Customer segmentation divides your customer base into groups with similar purchase behavior so marketing campaigns, promotions, and product recommendations can be precisely targeted. Klaviyo, Omnisend, and Metorik all provide RFM-style segmentation out of the box for Shopify and WooCommerce without custom SQL. Only build a custom segmentation system if your platform's tools don't support the segment logic you need.

## When to Use This Skill

- When personalizing email campaigns by lifecycle stage (new, active, at-risk, lapsed)
- When building suppression lists to avoid wasting ad spend on already-converted customers
- When identifying "champion" customers for VIP programs and early access campaigns
- When analyzing which acquisition cohort has the best 90-day retention
- When syncing behavioral segments to advertising platforms (Meta, Google)

## Core Instructions

### Step 1: Determine platform and choose the right segmentation tool

| Platform | Built-in Segmentation | Recommended Tool |
|----------|-----------------------|-----------------|
| **Shopify** | Basic: Admin → Customers → Filters; Advanced: Klaviyo or Omnisend | Klaviyo for email + SMS; Lifetimely for cohort analysis |
| **WooCommerce** | WooCommerce Analytics → Customers (basic filters) | Klaviyo + WooCommerce plugin; or Metorik for analytics |
| **BigCommerce** | Customer Groups (tier-based); Analytics → Customers | Klaviyo for behavioral segmentation |
| **Custom / Headless** | Build RFM scoring in SQL; sync to Klaviyo for activation | Required when platform has no segmentation tools |

---

### Step 2: Platform-specific setup

---

#### Shopify

**Option A: Shopify Admin segments (basic, free)**

1. Go to **Admin → Customers**
2. Use the filter bar to create segments based on:
   - Order count, total spent, last order date
   - Email subscription status, tags, location
   - Product purchased
3. Save the filter as a customer segment
4. Export the segment to CSV for use in ads or email campaigns

**Option B: Klaviyo (recommended for lifecycle segmentation)**

Klaviyo syncs automatically with Shopify and provides RFM-style segmentation built on real purchase data.

**Key segments to create in Klaviyo:**

1. **Champions** (high-value, frequent, recent):
   - Rule: `Ordered at least 3 times` AND `Last order within 60 days` AND `Total spent > $200`
   - Action: Early access to new products, VIP perks, referral program invites

2. **At Risk — High Value**:
   - Rule: `Total spent > $200` AND `Last order 90–180 days ago`
   - Action: Win-back flow with personalized offer

3. **Recent First-Time Buyers**:
   - Rule: `Order count equals 1` AND `First order within 30 days`
   - Action: Onboarding sequence, encourage second purchase

4. **Lapsed Customers**:
   - Rule: `Last order more than 180 days ago` AND `Order count >= 2`
   - Action: Re-engagement campaign with "We've missed you" messaging

5. **Subscribers who never purchased**:
   - Rule: `Email subscriber` AND `Order count equals 0`
   - Action: Welcome series with social proof and first-order incentive

To create segments in Klaviyo:
1. Go to **Lists & Segments → Create Segment**
2. Add conditions using the filter builder — Klaviyo has 150+ pre-built filter types including Shopify-specific events
3. Name the segment clearly (e.g., "At Risk High Value — 90-180 days")
4. Use the segment in a Flow trigger or as an audience for a Campaign

**Klaviyo Predictive Analytics (paid plans):**
- Klaviyo automatically calculates **Predicted CLV**, **Expected Date of Next Order**, and **Churn Risk** per customer
- Find these under **Analytics → Predictive Analytics**
- Use these predictions as segment filter criteria without any custom code

---

#### WooCommerce

**Option A: Metorik (recommended analytics platform)**

1. Install **Metorik** (connects via WooCommerce REST API)
2. Go to **Metorik → Segments → Create Segment**
3. Build rule-based segments using purchase history, product affinity, geography, and more
4. Metorik calculates RFM scores automatically
5. Export segment to CSV or sync directly to Klaviyo/Mailchimp

**Option B: Klaviyo for WooCommerce**

1. Install **Klaviyo: Email Marketing for WooCommerce** from WordPress.org
2. Klaviyo syncs your WooCommerce order history and creates profiles for all customers
3. Build the same lifecycle segments described in the Shopify section above

---

#### BigCommerce

**Customer Groups for tier-based segmentation:**

1. Go to **Customers → Customer Groups → Add Group**
2. Create groups based on purchase behavior rules:
   - "VIP" — customers with lifetime spend > $500
   - "Repeat Buyers" — customers with 3+ orders
3. Assign group-specific pricing, category access, or shipping rules

**Klaviyo for behavioral segmentation:**
- Install the **Klaviyo for BigCommerce** app
- Connect your BigCommerce store
- Build behavioral segments in Klaviyo using purchase history and event data

---

#### Custom / Headless

Build RFM scoring in SQL and sync to an ESP for activation:

```sql
-- PostgreSQL: Calculate RFM scores for all customers
WITH customer_rfm AS (
  SELECT
    customer_id,
    EXTRACT(EPOCH FROM (NOW() - MAX(created_at))) / 86400 AS recency_days,
    COUNT(id) AS frequency,
    SUM(subtotal_cents) / 100.0 AS monetary
  FROM orders
  WHERE status NOT IN ('cancelled', 'refunded')
  GROUP BY customer_id
),
rfm_scored AS (
  SELECT
    customer_id,
    recency_days, frequency, monetary,
    NTILE(5) OVER (ORDER BY recency_days DESC) AS r_score,  -- Lower recency = higher score
    NTILE(5) OVER (ORDER BY frequency ASC) AS f_score,
    NTILE(5) OVER (ORDER BY monetary ASC) AS m_score
  FROM customer_rfm
)
SELECT
  customer_id, r_score, f_score, m_score,
  r_score + f_score + m_score AS rfm_total,
  CASE
    WHEN r_score >= 4 AND f_score >= 4 AND m_score >= 4 THEN 'champions'
    WHEN r_score >= 3 AND f_score >= 3 AND m_score >= 3 THEN 'loyal_customers'
    WHEN r_score >= 4 AND f_score <= 2 THEN 'recent_customers'
    WHEN r_score <= 2 AND f_score >= 4 AND m_score >= 4 THEN 'cannot_lose_them'
    WHEN r_score <= 2 AND f_score >= 3 THEN 'at_risk'
    WHEN r_score = 1 AND f_score <= 2 THEN 'lost'
    ELSE 'needs_attention'
  END AS segment
FROM rfm_scored;
```

```typescript
// Sync a segment to Klaviyo — batched at 100 profiles per request
export async function syncSegmentToKlaviyo(segmentCustomers: Customer[], klaviyoListId: string) {
  const BATCH_SIZE = 100;
  for (let i = 0; i < segmentCustomers.length; i += BATCH_SIZE) {
    const batch = segmentCustomers.slice(i, i + BATCH_SIZE);
    await fetch(`https://a.klaviyo.com/api/lists/${klaviyoListId}/relationships/profiles/`, {
      method: 'POST',
      headers: {
        Authorization: `Klaviyo-API-Key ${process.env.KLAVIYO_PRIVATE_KEY}`,
        'Content-Type': 'application/json',
        revision: '2024-10-15',
      },
      body: JSON.stringify({
        data: batch.map(c => ({
          type: 'profile',
          attributes: { email: c.email, first_name: c.firstName, last_name: c.lastName },
        })),
      }),
    });
  }
}

// Export suppression list for Meta Ads — hash emails before sending
export async function exportSuppressionListForMeta(lookbackDays = 30): Promise<string[]> {
  const recentBuyers = await db.orders.findMany({
    where: { createdAt: { gte: new Date(Date.now() - lookbackDays * 86400000) }, status: 'completed' },
    select: { customerEmail: true },
    distinct: ['customerEmail'],
  });

  return recentBuyers.map(({ customerEmail }) => {
    const { createHash } = require('crypto');
    return createHash('sha256').update(customerEmail.toLowerCase().trim()).digest('hex');
  });
}
```

---

### Step 3: Map segments to actions

Every segment should have a clear marketing action:

| Segment | Recommended Action |
|---------|-------------------|
| Champions | VIP early access, referral program invite, no win-back discounts needed |
| Loyal Customers | Loyalty program enrollment, revie

Related in customer-crm