Back to Case Studies

Promotion and Demand Analytics for an E-commerce Promotion Platform

Forecasting, Discount Sensitivity and Retention

ProductionRetail & E-commerceOct 2024 – Feb 2025MLOps, Infrastructure & Data Science
+2 pp
Customer retention after the insights
~30%
WAPE on volatile promotion sales
18 mo.
Of order history modelled
1 view
Forecasts, discounts, loyalty, churn

My Role

Role
Architect & tech lead
Independent consulting
Team
Me + 2 engineers + a PM
Stage reached
Built; insights raised retention
Key decisions
  • Multivariate TSMixer over univariate forecasting models
  • Group discount codes into families before modelling
  • Gradient boosting for explainable discount sensitivity

Approach at a Glance

Details
  1. 1Turning the Shopify Export into Clean Data
  2. 2Demand Forecasting with a Multivariate Model
  3. 3Demand Sensitivity with Gradient Boosting
  4. 4Testing Each Promotion Mechanic
  5. 5Customer Analytics: Loyalty, Cohorts and Churn

Executive Summary

The data-science layer of a SaaS platform that helps e-commerce merchants on Shopify and similar systems manage pricing and promotions. Its merchants run a constant stream of promotions: discount codes, bundles, subscriptions, free gifts above an order value, loyalty programmes. They can't tell which of them actually pay off, how much each product will sell, or which customers are about to stop buying. The platform needed models that answer those questions from a merchant's own order data.

Working on 18 months of raw merchant order data, we built:

  • demand forecasting per product with a multivariate model that takes discounts, prices and marketing into account, reconciled across the product hierarchy;
  • demand sensitivity models that show how sales respond to each kind of discount and to marketing spend, and where deeper discounts start to hurt margin;
  • promotion analytics: discount groups, bundles, subscriptions, the free-gift threshold and the loyalty programme, each tested for its real effect;
  • customer analytics: segmentation, cohorts and churn prediction.

Product-level forecasts reached a WAPE of about 30% on highly promotion-driven sales, and acting on the retention analytics raised customer retention by 2 percentage points. I was the architect and tech lead, working with two engineers and a PM, from October 2024 to February 2025.


Client Profile

The client is a London-based SaaS company building a pricing and promotions platform for e-commerce merchants. Its value to merchants depends on turning their raw store data into reliable answers about promotions, and promotions are where that data is messiest:

  • Hundreds of discount codes: one-off codes for new users, families of campaign codes, subscription discounts, all in one free-text column. Without grouping them, no single code had enough history to measure its effect.
  • Unlabelled mechanics: buy-one-get-one deals, bundles and subscriptions often weren't marked as such, and a subscription discount looks just like a promotional one.
  • Overlapping promotions: several promotions ran at once, so the effect of any single one was hard to isolate.
  • Short history: 18 months is barely enough to separate seasonality from promotion effects.
  • Raw export quirks: an order's total was recorded only on its first line, refunds had to be excluded, and customers had to be identified from their email addresses.

Technical Approach

  1. Turning the Shopify Export into Clean Data – We excluded refunded and partially refunded orders, created customer IDs from emails, and rebuilt the value of each product line from quantity and price, validated against each order's subtotal. We then built a dictionary of discount groups: one-off alphanumeric codes became "new user", and campaign codes were grouped into families so that each group had enough history to measure its effect. We also derived features the data didn't have, such as discount percentage, free-shipping detection and likely subscription orders, recognised from code patterns and cross-checked with product SKUs.

  2. Demand Forecasting with a Multivariate Model – We compared univariate models, which only look at past sales, with multivariate ones that also see discounts, prices and marketing. The multivariate TSMixer model was chosen: in a promotion-driven business, the planned promotions explain much of next month's demand, and a univariate model can't use them. Forecasts were made per product and reconciled hierarchically, so product forecasts add up consistently to categories and the whole range. Product-level forecasts reached a WAPE of about 30%, given that individual products' sales swing sharply with every campaign.

  3. Demand Sensitivity with Gradient Boosting – To measure how sales respond to each discount group, price level and marketing budget, we used gradient-boosted models. They handle the mix of categorical and numeric features, capture non-linear effects such as diminishing returns from deeper discounts, and their feature importances make the sensitivity explainable to the marketing team. The analysis showed the tipping point where deeper discounts stopped generating enough extra sales to justify the lost margin.

  4. Testing Each Promotion Mechanic –

    • Free gift above an order value: average order value and profit were compared for orders with and without the gift, with statistical tests to confirm the difference was real.
    • Bundles: interpretable models assessed which product combinations sold better together, and optimisation suggested better bundles than the existing ones.
    • Overlapping promotions: grouped baselines were used to separate the effect of promotions running at the same time.
    • Profitability: margin after discounts and the cost of goods for each promotion type, and the factors that drive it.
  5. Customer Analytics: Loyalty, Cohorts and Churn –

    • Segmentation: by behaviour (purchase frequency, average order value, total spend), by product, and by geography, clustering shipping locations.
    • Loyalty programme: repeat-purchase rate, purchase interval and customer lifetime value for members against non-members.
    • Cohorts: customers grouped by month of first purchase, to track retention over time.
    • Churn prediction: survival analysis (a Cox proportional hazards model) estimates when each customer is likely to stop buying, so the merchant can reach at-risk customers before they leave.

    Acting on these insights raised the merchant's customer retention by 2 percentage points.


Business Outcome

The platform could give merchants evidence instead of intuition about their promotions: demand forecasts that account for planned promotions, a measure of how sales respond to each discount type and where discounts stop paying off, tested answers about free gifts, bundles and the loyalty programme, and a churn model that flags customers before they leave. Acting on the retention insights raised the merchant's customer retention by 2 percentage points.

The project showed how much value sits in a raw store export once it is cleaned and structured. Most of the work, grouping discount codes, detecting subscriptions and separating overlapping promotions, was what made every model after it possible.

Technologies

Time-Series ForecastingTSMixerDartsHierarchical ForecastingGradient BoostingSurvival AnalysisCohort AnalysisClusteringStatistical TestingShopify Data

Planning something similar?

Tell me about it on a short call. New projects can start within 2 weeks