skills/customer-crm/customer-segmentation/SKILL.md
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
npx skillsauth add finsilabs/awesome-ecommerce-skills customer-segmentationInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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.
| 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 |
Option A: Shopify Admin segments (basic, free)
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:
Champions (high-value, frequent, recent):
Ordered at least 3 times AND Last order within 60 days AND Total spent > $200At Risk — High Value:
Total spent > $200 AND Last order 90–180 days agoRecent First-Time Buyers:
Order count equals 1 AND First order within 30 daysLapsed Customers:
Last order more than 180 days ago AND Order count >= 2Subscribers who never purchased:
Email subscriber AND Order count equals 0To create segments in Klaviyo:
Klaviyo Predictive Analytics (paid plans):
Option A: Metorik (recommended analytics platform)
Option B: Klaviyo for WooCommerce
Customer Groups for tier-based segmentation:
Klaviyo for behavioral segmentation:
Build RFM scoring in SQL and sync to an ESP for activation:
-- 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;
// 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');
});
}
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, review request, upsell to next tier | | Recent First-Time Buyers | Second-purchase email series (send 7 days after first order) | | At Risk — High Value | Personalized win-back with acknowledgment: "It's been a while" | | Cannot Lose Them | Direct outreach, significant offer (20% off), personal email from founder | | Lapsed / Lost | Low-cost re-engagement (newsletter, product announcement); remove from active campaigns |
Upload your most recent buyers as suppression lists on Meta and Google to avoid wasting acquisition budget:
| Problem | Solution | |---------|----------| | Champions segment shrinks every month | Champions require recent + high frequency — customers naturally graduate out; supplement with "Loyal Customers" for long-term relationship management | | RFM scores biased by one very large order | Klaviyo's predicted CLV smooths this out; for custom builds, use median order value in the monetary score rather than total spend | | Segment sync to Klaviyo creates duplicate profiles | Always match by email as the primary key when syncing; if duplicates exist, use Klaviyo's profile merge | | Cohort analysis shows declining retention but reason unclear | Segment cohort by acquisition channel to identify whether specific channels bring lower-quality customers |
tools
Let shoppers save products to a wishlist, share it with friends, and get notified when saved items come back in stock or drop in price
development
Build a themeable storefront with design tokens and CSS custom properties that supports white-labeling, multi-brand variants, and dark mode
development
Speed up product discovery with instant search suggestions, fuzzy typo matching, and category-aware results powered by Algolia or Elasticsearch
development
Build a mobile-first storefront with thumb-friendly navigation, sticky add-to-cart buttons, and touch-optimized components for high mobile conversion