HomeDashboardCustomer retention

Analysis 02 of 28E-commerce

When do customers come back, and when do they stop?

Of the customers whose first order was in a given month, what share bought again in each later month, how soon do the ones who return come back, and after how long without an order is a customer unlikely to return?

The short answer The biggest single drop comes after the first order: 27.6% of 5,852 identified customers bought once by Dec 9, 2011, while 77.7% of those with a second order placed a third. Customers new in 2010 or 2011 bought in the month after their first 21.0% of the time and between 13.5% and 21.5% in each later month to month 12; the December 2009 cohort, which includes established customers, ran between 33.3% and 49.6%. Returns come early: half of 2010's new customers who came back within a year did so within 71 days. After 120 days without an order the odds of another in the next six months are about even (51.5%), and after 180 days 40.3%.

  • Public data
  • Months observed to Nov 2011
  • Identified customers only

Data as of · fixed dataset

Online retail breakdown Revenue, products and the first 12 cohorts, from the same orders.

Source
UCI Online Retail II, Chen, D. (2012), UCI Machine Learning Repository
Period
Dec 2009 to Dec 2011 (months observed to Nov 2011)
Licence
CC BY 4.0
Charts
5, each with its data table and CSV

Key figures

  • 72.4%Placed a second orderof 5,852 identified customers; 27.6% bought once
  • 21.0%New customers who buy again the next monthcohorts Jan 2010 to Oct 2011, weighted; Dec 2009 cohort 35.0%
  • 40.6%New customers back within 90 daysfirst purchase Jan 1 to Dec 9, 2010 (3,334 customers)
  • 71 daysMedian days to come back2010's new customers who came back within a year
  • 40.3%Order again within 6 months, after 180 quiet daysagainst 83.9% just after an order

The charts

Chart 1Lead chart · share still buying

New customers buy again far less often than the December 2009 cohort, which includes established customers: 21.0% in the next month, against 35.0%.

Of the customers who first bought in a given month, what share bought again k months later?

Each point is the share of a cohort that bought in that month after their first. Customers new from January 2010 (the cohorts of January 2010 to October 2011, 4,682 customers, weighted by size) bought in month 1 21.0% of the time and stayed between 13.5% and 21.5% to month 12. The December 2009 cohort (951 customers) includes customers already buying before the data starts, and runs between 33.3% and 49.6%.
Download CSV

UCI Online Retail II · public data

Retention curve: 12 rows. The weighted line adds up the buyers in that month across every cohort old enough to have reached it and divides by those cohorts' sizes, so later months rest on fewer, older cohorts (the last two columns say how many). Months 13 and later rest on 10 cohorts or fewer and are in chart 2. December 2011 is left out because it is partial.
Months since first purchaseDec 2009 cohort (%)New customers, cohorts Jan 2010 to Oct 2011, weighted (%)Cohorts in the averageCustomers in the average
Month 135.021.0224,682
Month 233.321.5214,461
Month 342.521.1204,273
Month 437.919.4194,166
Month 536.018.6184,065
Month 637.618.4173,957
Month 734.418.6163,846
Month 833.816.4153,740
Month 936.215.0143,561
Month 1042.213.5133,436
Month 1149.614.0123,364
Month 1237.618.4113,288

Chart 2Retention by cohort, full history

Every cohort from December 2009 to October 2011, followed to November 2011.

How does each first-purchase month hold up, month by month?

Rows are first-purchase months, columns the months since. The Online retail page shows the first 12 cohorts to month 12; this is all 23 with every month observed. Among the new cohorts, month 1 ranges from 9.2% (December 2010) to 31.7% (October 2011).
Download CSV

UCI Online Retail II · public data

Every cohort: 23 rows. Share of each first-purchase cohort that bought in each later month, percent. Month 0 is the first month, 100%. Blank cells are months after November 2011, not yet observed. The first 12 rows to month 12 equal the published chart on the Online retail page, cell for cell.
First purchaseCohort sizeMonth 0Month 1Month 2Month 3Month 4Month 5Month 6Month 7Month 8Month 9Month 10Month 11Month 12Month 13Month 14Month 15Month 16Month 17Month 18Month 19Month 20Month 21Month 22Month 23
2009-12951100.035.033.342.537.936.037.634.433.836.242.249.637.628.224.430.326.330.328.425.925.431.330.440.6
2010-01368100.021.532.131.527.231.026.923.428.532.631.017.922.817.919.615.224.520.419.320.125.319.825.3
2010-02375100.023.522.729.324.519.719.228.825.627.711.512.515.217.612.320.016.016.314.422.922.916.5
2010-03441100.019.023.124.323.120.424.730.627.710.911.614.520.016.320.017.017.515.617.720.421.3
2010-04294100.019.019.016.018.422.127.626.510.510.97.513.914.315.615.615.613.915.018.022.8
2010-05255100.015.716.917.617.625.521.212.55.98.211.413.315.315.39.812.513.716.515.3
2010-06267100.017.618.720.623.228.512.79.08.211.210.513.915.012.411.212.413.120.2
2010-07185100.015.718.429.729.214.111.414.614.611.413.514.613.013.519.517.323.8
2010-08163100.019.628.832.516.611.79.812.913.512.912.911.714.717.217.219.6
2010-09239100.023.023.413.08.810.513.89.613.013.012.110.022.616.716.7
2010-10375100.025.914.712.58.88.313.113.910.79.310.712.819.223.2
2010-11326100.017.59.59.57.78.912.910.18.69.211.014.725.2
2010-1276100.09.25.39.211.86.65.39.25.32.69.219.7
2011-0172100.016.722.219.422.215.315.312.511.120.825.0
2011-02125100.016.016.018.421.616.016.015.215.218.4
2011-03179100.017.921.820.122.315.120.720.124.0
2011-04106100.024.519.819.817.923.617.925.5
2011-05111100.023.424.316.221.620.726.1
2011-06108100.023.121.326.920.427.8
2011-07101100.020.829.727.734.7
2011-08107100.026.229.926.2
2011-09188100.027.137.8
2011-10221100.031.7

Chart 3Order by order

The biggest drop is after the first order: 72.4% place a second.

Of the customers who placed a given number of orders, what share placed one more?

27.6% of 5,852 identified customers ordered once. Of those with a second order, 77.7% placed a third, and every later step keeps 80.0% or more.
Download CSV

UCI Online Retail II · public data

Repeat ladder: 10 rows. Orders are distinct invoices that are not cancellations, over the whole history. Customers who first bought late in 2011 had less time to reach the next step, so the first steps read slightly low.
StepPlaced the next order (%)Customers with this many ordersCustomers with one more
1st to 2nd72.45,8524,234
2nd to 3rd77.74,2343,289
3rd to 4th80.03,2892,630
4th to 5th81.42,6302,141
5th to 6th83.42,1411,786
6th to 7th84.41,7861,508
7th to 8th85.51,5081,290
8th to 9th86.51,2901,116
9th to 10th86.11,116961
10th to 11th89.9961864

Chart 4Days to the second purchase day

Returns come early: 40.6% of 2010's new customers were back within 90 days.

How soon after their first purchase do customers come back?

Share of each group with a second purchase day within so many days of the first. Customers whose first purchase fell from January 1 to December 9, 2010 (3,334): 16.0% within 30 days, 40.6% within 90, 69.7% within a year; half of those back within a year came within 71 days. The December 2009 cohort (951): 59.3% and 89.4%.
Download CSV

UCI Online Retail II · public data

Time to come back: 9 rows. Share of each group back by then. New in 2010: first purchase from Jan 1 to Dec 9, 2010. Purchase days, not invoices: several invoices on one day count as one. Every customer here first bought by Dec 9, 2010, so each had at least 365 days to come back.
Back withinDec 2009 cohort (%)New in 2010 (%)
7 days12.93.2
14 days23.67.0
30 days29.116.0
60 days49.630.8
90 days59.340.6
120 days68.547.3
180 days77.557.2
270 days83.564.7
365 days89.469.7

Chart 5Odds of another order after a quiet spell

After 180 days without an order, 40.3% order again within six months.

Once a customer has gone quiet for a while, how likely is another order?

For every purchase day from Dec 1, 2009 to Aug 31, 2010: the share followed by another order within the next 180 days, once the customer has already gone so long without one. Just after an order it is 83.9%; after 90 quiet days 59.2%, after 120 days 51.5%, after 180 days 40.3% and after 270 days 28.3%.
Download CSV

UCI Online Retail II · public data

When they stop: 7 rows. A purchase day stays in the base for a quiet spell if no later order came within it. Every purchase day used has at least 465 days of data after it, enough for the longest spell plus the window.
Days since the last orderOrdered in the next 180 days (%)Purchase days still waitingFollowed by an order in the window
Just ordered83.910,6218,914
30 days76.66,4264,922
60 days67.84,2172,858
90 days59.23,1021,837
120 days51.52,4311,251
180 days40.31,707688
270 days28.31,265358

01Findings

What the charts say.

  1. 27.6% of 5,852 identified customers had not ordered again by Dec 9, 2011; once past the second order, 80.0% or more take each next step.

    Chart 3

  2. New customers buy in the month after their first 21.0% of the time, against 35.0% for the December 2009 cohort, which includes customers already buying before the data starts.

    Chart 1 Chart 2

  3. Returns come early: 40.6% of 2010's new customers were back within 90 days and 69.7% within a year; half of those back within a year came within 71 days.

    Chart 4

  4. The longer the silence, the lower the odds: 83.9% order within six months just after a purchase, 51.5% after 120 quiet days, 40.3% after 180.

    Chart 5

02Method

How the figures were built.

Steps

  1. Dropped non-product stock codes (POST, DOT, M, m, D, BANK CHARGES, AMAZONFEE, C2, PADS, CRUK, ADJUST, ADJUST2, S, B, TEST001/002, gift card vouchers) that represent postage, fees, manual adjustments, and test rows rather than real merchandise.
  2. Dropped rows with price <= 0 (6,207 rows); nearly all of these have no Customer ID and are internal stock corrections, not customer sales.
  3. Dropped negative-quantity rows on invoices that do not start with 'C' (3,457 rows); a true return in this dataset is a cancellation invoice (prefix 'C'), and these unlabeled negative-quantity rows all have null Customer ID and mostly null description, so they read as inventory write-offs rather than customer returns.
  4. Removed 34,035 exact duplicate line items (after the rules above).
  5. Kept rows with missing Customer ID (22.2% of clean rows) for revenue and product analysis since they are real sales; excluded them from the cohort retention analysis, which requires a known customer.
  6. Customers: rows with a Customer ID, on invoices that are not cancellations. A month or a day counts once per customer however many invoices fall in it.
  7. December 2011 (Dec 1 to 9) is left out as an observation month because it is partial; November 2011 is the last month observed.

1,067,371 rows in the source file, 1,021,254 after cleaning; 5,852 identified customers. Every figure on this page comes from the chart tables in data/analyses/customer_retention.json, built from the full cleaned history; the table under each chart says how.

Checks

  • The cleaning reproduces the live Online retail page: 1,067,371 source rows, 1,021,254 after cleaning, 5,852 identified customers, the 27.6% one-time share and all 156 cells of the published cohort chart.
  • Every number on this page was recomputed by separate code (verify_r4.py: plain Python reading the original UCI zip, with no DuckDB and no intermediate files) and matches.
  • The cohort and time-to-come-back queries below were run in DuckDB 1.5.5 and return the figures on this page.

The queries

This series is not in Live SQL. The data file behind every chart is data/analyses/customer_retention.json, built by data/analyses/scripts/build_r4.py (prep, DuckDB) and data/analyses/scripts/verify_r4.py (independent check, plain Python) from the source downloads.

Cohort retention (DuckDB, the full cleaned history)

-- Cohort retention: share of each first-purchase month still buying k months later
WITH active AS (            -- one row per customer and month with a purchase
    SELECT DISTINCT customer_id, date_trunc('month', invoice_date) AS month
    FROM retail_lines
    WHERE customer_id IS NOT NULL AND NOT is_cancelled
      AND invoice_date < DATE '2011-12-01'        -- December 2011 is partial (to Dec 9)
),
cohort AS (
    SELECT customer_id, min(month) AS cohort_month FROM active GROUP BY 1
)
SELECT c.cohort_month,
       date_diff('month', c.cohort_month, a.month) AS months_since,
       count(*) AS customers,
       round(100.0 * count(*) / max(s.size), 1) AS retention_pct
FROM active a
JOIN cohort c USING (customer_id)
JOIN (SELECT cohort_month, count(*) AS size FROM cohort GROUP BY 1) s USING (cohort_month)
GROUP BY 1, 2
ORDER BY 1, 2

Time to come back (DuckDB)

-- Time to come back: days from a customer's first purchase day to the next one
WITH days AS (              -- several invoices on one day count as one purchase day
    SELECT DISTINCT customer_id, invoice_date::DATE AS d
    FROM retail_lines
    WHERE customer_id IS NOT NULL AND NOT is_cancelled
),
nexts AS (
    SELECT f.customer_id, f.first_day, min(d.d) AS next_day
    FROM (SELECT customer_id, min(d) AS first_day FROM days GROUP BY 1) f
    LEFT JOIN days d ON d.customer_id = f.customer_id AND d.d > f.first_day
    GROUP BY 1, 2
)
SELECT CASE WHEN first_day < DATE '2010-01-01' THEN 'Dec 2009 cohort'
            ELSE 'First purchase Jan 1 to Dec 9, 2010' END AS grp,
       count(*) AS customers,
       round(100.0 * count(*) FILTER (WHERE next_day - first_day <= 90) / count(*), 1) AS back_within_90_days_pct,
       median(next_day - first_day) FILTER (WHERE next_day - first_day <= 365) AS median_days_if_back_within_a_year
FROM nexts
WHERE first_day <= DATE '2010-12-09'          -- every customer here has at least 365 days to come back
GROUP BY 1
ORDER BY 1

Caveats

  • A UK online gift retailer selling mostly to wholesale customers, so repeat buying runs higher than at a typical consumer shop. Customers without a Customer ID are left out. The data starts on Dec 1, 2009, so the December 2009 cohort includes customers who first bought earlier.
  • The weighted curve's later months rest on fewer and older cohorts; the table under chart 1 gives the count for each month.
  • New customers here are customers first seen in the data from January 2010; some may have bought before December 2009 under the same Customer ID, which the data cannot show.
  • The repeat ladder covers the whole history, so customers who first bought in late 2011 had little time to reach a second order.
  • The December 2009 cohort is shown on its own because it mixes new and established customers; the live Online retail page includes it in its 12-cohort averages (23.3% at month 3, 19.6% at month 12).

Releases and revisions

  • This is a fixed historical dataset (as of December 2011); it is not revised.

03Sources

Sources and licence.

Licence: CC BY 4.0. Public data.

Download the chart data

Each CSV is made in your browser from the rows in that chart's table.

All twenty-eight analyses on the Dashboard

04Contact

Want this kind of breakdown on your own data?

Open to e-commerce, data and operations roles. Los Angeles or remote.