How to Build a Churn Prediction Model for Your Shopify Store
A step-by-step guide to building a churn prediction model using your Shopify data. Covers data preparation, model selection, retention analysis, and integration with your marketing stack.
Three platforms, three answers, one budget to defend. Your GA4 export already holds the answer, and the first finding is free and never leaves your browser. Get your first finding free
By Joris van Huët, Founder & CEOUpdated 7 min read
How to Build a Churn Prediction Model for Your Shopify Store
Your Shopify store has everything you need to predict which customers are about to stop buying: order history, purchase timing, product categories, average order values, and customer engagement data.
This guide walks you through building a churn prediction model using your Shopify data, step by step. You do not need a data science team to start.
Step 1: Define Churn for Your Business
See also: Churn Prediction for Ecommerce: Models, Metrics, and Prevention
Before building any model, you need a clear definition of churn. In a subscription model this is obvious: cancellation. For non-subscription Shopify stores, you need to define a time-based threshold.
Calculate Your Inter-Purchase Interval
Pull your order data from Shopify and calculate the average number of days between repeat purchases for customers who have bought at least twice. You can export this from Shopify's customer reports or use the API.
Example calculation:
- Pull all customers with 2+ orders from the last 24 months
- For each customer, calculate the days between their first and second purchase, second and third, etc.
- Take the median (not the mean: the mean is skewed by outliers)
If your median inter-purchase interval is 42 days, a reasonable churn threshold is 2-2.5x that interval: 84-105 days without a purchase.
Segment by Product Category
Different product categories have different natural replenishment cycles. A beauty brand selling skincare might have a 35-day cycle for serums but a 90-day cycle for tools. If your store sells across categories, consider category-specific churn definitions.
Define Your At-Risk Window
Your churn prediction model is most useful when it identifies customers who are in the at-risk window: past the expected repurchase date but not yet fully churned. For a brand with a 42-day inter-purchase interval:
- Active: Purchased within 42 days
- At-risk: 42-84 days since last purchase
- Likely churned: 84+ days since last purchase
Step 2: Prepare Your Shopify Data
Export the Data You Need
From Shopify, export or query the following for each customer:
- Customer ID
- First order date
- Most recent order date
- Total number of orders
- Total revenue (lifetime spend)
- Average order value
- Days since last order (calculated from today)
- Product categories purchased
- Acquisition source (UTM parameters from first order)
- Discount usage (percentage of orders using a discount code)
If you use Shopify's customer tags or a CRM layer, also pull:
- Email engagement data (open rate, click rate from your email platform)
- Customer service contact history
- Return/exchange history
Build Your Feature Set
Transform the raw data into features your model can use:
| Feature | Calculation | Why It Matters |
|---|---|---|
| Recency | Days since last order | Strongest single churn predictor |
| Frequency | Total orders | Multi-purchase customers churn less |
| Monetary | Average order value | Higher-value customers may be more engaged |
| Inter-purchase interval | Avg days between orders | Baseline for expected behavior |
| Discount dependency | % of orders with discount | High discount use predicts churn when discounts stop |
| Category breadth | # of distinct categories purchased | Cross-category buyers are stickier |
| First-order channel | UTM source from first order | Some channels produce higher-churn customers |
The recency ratio is the single most useful engineered feature. A recency ratio of 1.0 means the customer is exactly at their expected repurchase time. A ratio of 2.0 means they are significantly overdue. This normalizes across customers with different purchase frequencies.
Step 3: Choose Your Model
Option A: RFM Scoring (No Code Required)
If you do not have a data science team, start with RFM scoring in a spreadsheet.
Score each customer from 1 to 5 on Recency, Frequency, and Monetary value (5 = best). Customers with a Recency score of 1 or 2 and a Frequency score of 3+ are your highest-value at-risk segment: they used to buy frequently and have stopped.
Pros: Immediate implementation, easy to explain to stakeholders. Cons: No probability scores, no ability to incorporate non-purchase features like email engagement.
Option B: Logistic Regression (Basic Python/R)
If you have basic analytical capabilities, logistic regression provides actual churn probability scores.
Target variable: Did the customer purchase in the next 90 days? (1 = yes, 0 = no) Features: Recency ratio, frequency, monetary value, discount dependency, category breadth, first-order channel
A logistic regression model is interpretable: you can see exactly which features increase or decrease churn probability and by how much. This is valuable for explaining to your team why certain customers are flagged as at-risk.
Option C: Gradient Boosted Trees (Advanced)
For brands with data science resources, gradient boosted models (XGBoost, LightGBM) capture nonlinear relationships and feature interactions that logistic regression misses.
These models can incorporate dozens of features including email engagement sequences, browsing behavior, product review submissions, and customer journey data from your analytics platform.
Option D: Probabilistic Models (BG/NBD)
The BG/NBD (Beta-Geometric/Negative Binomial Distribution) model is specifically designed for non-contractual settings like ecommerce. It estimates the probability that each customer is still "alive" based on their purchase history patterns.
Libraries like lifetimes in Python make this relatively straightforward to implement. The model requires only purchase dates and customer IDs: no feature engineering needed.
Step 4: Validate Your Model
Train-Test Split
Never evaluate a prediction model on the same data you used to train it.
Step 5: Integrate with Your Marketing Stack
Connect to Your Email Platform
Export your churn scores to your email marketing platform (Klaviyo, Mailchimp, etc.) as customer properties.
Use your churn scores to improve Meta Ads and Google Ads performance:
- Exclude high-churn-probability customers from acquisition campaigns to avoid wasting spend on re-showing ads to disengaged customers
- Create lookalike audiences based on your lowest-churn, highest-CLV customers
- Build custom audiences of at-risk customers for targeted retargeting campaigns
Connect to Your Attribution Platform
When your churn prediction model identifies that customers from certain acquisition channels have systematically higher churn rates, it changes your acquisition strategy.
For example, retention analysis might reveal that customers acquired through heavy discount promotions on paid social have a 75% 90-day churn rate, while customers acquired through content marketing have a 45% churn rate. The first channel looks efficient on first-purchase ROAS, but the second channel produces dramatically higher customer lifetime value.
Connecting churn data to marketing attribution transforms your understanding of channel performance from "which channel drives the cheapest first purchase" to "which channel drives the most valuable long-term customers."
Step 6: Iterate and Improve
Refresh the Model Regularly
Customer behavior changes. Seasonal patterns shift. New products alter repurchase cycles. Refresh your churn model at least quarterly with updated training data.
Expand Your Feature Set
As your data infrastructure matures, add new features to your model:
- Site browsing data: Are at-risk customers still visiting but not buying?
- First-party data from surveys, quizzes, and preference centers
- Customer service sentiment: Negative interactions strongly predict churn
- Marketing automation engagement: Flow-level email interaction patterns
Getting Started Today
You do not need to build the perfect churn prediction model on day one. Start with RFM scoring in a spreadsheet using your Shopify export data. That alone will identify your most at-risk valuable customers and enable targeted retention campaigns.
As your capability grows, graduate to probabilistic or machine learning models and integrate with your marketing analytics stack for a complete view of acquisition quality and retention performance.
Go deeper: Causal attribution, explained.
Sixty-second versions of these ideas: Causality Engine on YouTube Shorts.
Have an audience of ecommerce operators? Earn 20% recurring commission by recommending the €99 read.
Keep reading
Terms in this article
- Attribution PlatformAttribution Platform is a software tool that connects marketing activities to customer actions. It tracks touchpoints across channels to measure campaign impact.
- Content MarketingContent Marketing is a strategic approach focused on creating and distributing valuable content to attract and retain an audience, driving profitable customer action.
- Customer journeyCustomer journey is the path and sequence of interactions customers have with a website. Customers use multiple devices and channels, making a consistent experience important.
- Email MarketingEmail Marketing is sending commercial messages to a group of people using email. Every email sent to a potential or current customer constitutes email marketing.
- Machine LearningMachine Learning involves computer algorithms that improve automatically through experience and data. It applies to tasks like customer segmentation and churn prediction.
- Marketing AnalyticsMarketing analytics measures, manages, and analyzes marketing performance to improve effectiveness and ROI. It tracks data from various marketing channels to evaluate campaign success.
- Marketing AttributionMarketing attribution assigns credit to marketing touchpoints that contribute to a conversion or sale. Causal inference enhances attribution models by identifying true cause-effect relationships.
- Subscription ModelSubscription Model is a business model where customers pay a recurring price for product or service access. It generates consistent revenue streams.