Skip to main content

4.2 Customer Lifetime Value Modeling

Most marketing teams focus on Cost Per Acquisition (CPA), often used interchangeably with CAC (Customer Acquisition Cost): lower CPA means a better campaign. Customer Lifetime Value (CLV), often called LTV in analytics and SaaS contexts, reframes the question. It estimates how much each customer is worth over time, and that estimate sets the CPA ceiling for the segment.

This chapter shows how to predict CLV at the individual level using probabilistic BTYD models (BG/NBD + Gamma-Gamma with PyMC-Marketing), and how to turn those predictions into budget decisions.

Companion notebook: sec4.2_clv_pymc_marketing.ipynb fits the BG/NBD and Gamma-Gamma models, estimates CLV, and analyzes demographic segments on the Dunnhumby dataset.
View on GitHub

Why CLV Changes the Decision

Consider a fashion e-commerce brand acquiring customers through ads and coupons. Say two segments dominate the funnel: college students and working professionals. The first purchase looks like this:

  • College student: $10 acquisition cost, $100 purchase → 10× ROAS.
  • Working professional: $20 acquisition cost, $100 purchase → 5× ROAS.
The student costs less to acquire than the professional and produces the same first-purchase value, so first-order ROAS favors the student.
Figure 1: First-purchase comparison: students vs. professionals.

Day-one ROAS favors the student, but lifetime spend reverses the ranking. College students churn after the first transaction, so their lifetime spend stays near $100. Working professionals return and spend more over time, with an average lifetime spend of $400.

After repeat purchases, the professional produces twice the return on ad spend while the student customer churns.
Figure 2: Profitability once repeat purchases are included.

This is the gap CLV modeling closes. Without it, every customer gets the same CPA ceiling, which means overpaying for low-value customers and underpaying for high-value ones. With it, the ceiling scales to the predicted value, so the same budget acquires more of the right customers.

Without CLV, a fixed CPA over-invests in low-value customers; with CLV, CPA scales to each customer's lifetime value.
Figure 3: Fixed CPA (left) vs. CLV-scaled CPA (right).

CLV is useful at every stage: at Acquisition to spend more on high-value segments, at Growth to prioritize service and exclusive offers for high-value customers, and at Retention to focus save-the-customer campaigns where the math actually works.

The three goals of a CLV model follow directly: (1) predict future value at the individual level, (2) identify what makes high-CLV customers different, and (3) feed both into marketing budget decisions.

Why the Traditional Formula Falls Short

The textbook CLV formula has three components:

\[ \text{CLV} = \text{Average Order Value} \times \text{Purchase Frequency} \times \text{Customer Lifespan} \]

For a fashion brand where customers spend $100 per order, shop 4 times a year, and stay loyal for 3 years: \(\text{CLV} = 100 \times 4 \times 3 = \$1{,}200\). This is useful for rough business sizing but too coarse for customer-level decisions, for three reasons.

The three limitations of the traditional CLV formula: customer heterogeneity, differences in first-purchase timing, and the "dead or alive" ambiguity.
Figure 4: Three limitations of the traditional CLV formula.

Limitation 1: Not all customers are the same. Averaging across the whole base misrepresents both ends of the distribution:

Table 1: The average CLV of $1,090 misrepresents both groups.
Customer group # of Customers Average CLV Total Sales
Normal customers 90 $100 $9,000
Big-shop customers 10 $10,000 $100,000
Total 100 $1,090 $109,000

The overall average of $1,090 hides the difference between the two groups. You need CLV at the individual level.

Limitation 2: Different first-purchase timing. A customer who started a year ago has a full year of observable data; one who started three months ago has much less. Raw frequency counts conflate “low engagement” with “new arrival” unless you adjust for tenure.

Customers who start purchasing at different times have different observable windows, making raw frequency counts misleading.
Figure 5: Tenure bias in observable customer windows.

Limitation 3: churn is not observed. In subscriptions, churn is observable: the customer cancels. In retail and e-commerce, it is not. Whether a customer counts as “alive” depends on their own pattern. Someone who buys monthly going silent for three months is a red flag; someone who buys every six months skipping three is normal.

The same gap since a customer's last purchase can indicate temporary inactivity or permanent dropout, which is not directly observed.
Figure 6: Unobserved churn in purchase patterns.

The model has to account for differences in buying behavior between customers, for the time since each customer’s first purchase, and for the possibility that a customer has stopped buying. BTYD builds all three into one individual-level model.

BTYD: The BG/NBD + Gamma-Gamma Framework

Buy-Till-You-Die (BTYD) modeling combines two probabilistic models:

  1. BG/NBD predicts the probability a customer is still active and their future transaction count.
  2. Gamma-Gamma estimates their average order value.

Multiply the two, discount over time, and you get individual-level CLV with a credible interval around every estimate.

BTYD framework: BG/NBD predicts P(alive) and future transactions, Gamma-Gamma predicts order value; together they give CLV.
Figure 7: The BTYD framework: BG/NBD plus Gamma-Gamma.

BG/NBD Model

The BG/NBD model (Fader et al. 2005) assumes two latent processes in a customer’s lifecycle:

  • Purchase process. While the customer is alive, purchases follow a Poisson process with rate \(\lambda\).
  • Dropout process. After each purchase, there is a probability \(p\) that the customer becomes permanently inactive.
BG/NBD models observed purchases as a transaction process that continues until an unobserved dropout process makes the customer inactive.
Figure 8: BG/NBD: a purchase process with dropout.

Both \(\lambda\) and \(p\) vary across customers. A Bayesian hierarchical structure handles this: \(\lambda\) values follow a Gamma distribution across the base, \(p\) values follow a Beta distribution. The model learns population-level patterns while still producing individual estimates.

A useful consequence: the probability a customer is alive evolves over time. It drops as the gap since the last purchase grows, then jumps back up the moment a new purchase comes in.

A customer's probability of being active falls as time passes without a purchase, then rises sharply when another purchase occurs.
Figure 9: P(alive) decays between purchases and resets.

Gamma-Gamma Model

The Gamma-Gamma model (Fader and Hardie 2013) estimates average order value. It uses a two-layer Bayesian hierarchy: one Gamma distribution per customer (their own spending pattern), and another Gamma over the customer base (variation across customers).

When BTYD Is Not the Right Tool

BTYD assumes a non-contractual setting: churn is never observed, so the model infers it from purchase gaps. Table 2 lists the settings where another model fits better.

Table 2: Lifetime-value models by setting.
Setting Churn Model
Retail and e-commerce (non-contractual) Inferred from purchase gaps BG/NBD + Gamma-Gamma
SaaS and subscriptions (contractual) An explicit cancel event Shifted Beta-Geometric (sBG)
Explaining churn drivers with time-dependent covariates Observed, or defined by a rule Survival analysis (Cox proportional hazards)
Rich behavioral features and a production ML pipeline Either ML regression (e.g., LightGBM) on a fixed-horizon target

Implementation with PyMC-Marketing

PyMC-Marketing is built on PyMC and replaces the lifetimes library (now in maintenance mode). The headline feature is built-in uncertainty quantification: every CLV estimate comes with HDI bounds, so you can see how much uncertainty surrounds each customer’s estimate.

The CLV model needs only sales transactions: customer ID, transaction date, transaction value. Two to three years of history is usually enough.

CLV modeling starts from transaction-level records containing a customer identifier, transaction date, and transaction value.
Figure 10: Required input data for CLV modeling.

Data and RFM-T Summary

We use the Dunnhumby “The Complete Journey” grocery-retail dataset, the same dataset used in the traditional segmentation notebook (sec4.1_traditional_segmentation.ipynb). This lets you carry the same roughly 2,500 households from the traditional segmentation pipeline into CLV; after standard cleaning (removing negative-value transactions and zero-quantity rows) and RFM-T construction, the companion notebook fits BG/NBD on all 2,500 households, and the Gamma-Gamma spend model uses the 2,497 of them with at least one repeat purchase.

Table 3: RFM-T metrics used in the BTYD model.
Metric Definition
Recency Duration between a customer’s first and most recent purchase
Frequency Number of repeat purchases (total purchases minus one)
Monetary Average value of a customer’s repeat purchases (the first purchase is excluded)
Tenure Duration between a customer’s first purchase and the end of the study period
NoteRecency here is not RFM recency

In Section 4.1, recency meant days since the last purchase. In the BTYD convention, which PyMC-Marketing’s rfm_summary follows, it is the span from a customer’s first to most recent purchase, so higher means more recently active.

from pymc_marketing import clv

data_summary = clv.utils.rfm_summary(
    data,                              # one row per purchase
    customer_id_col="CustomerID",
    datetime_col="date",
    monetary_value_col="TotalSales",
    time_unit="D",
)

Fitting and Estimating CLV

# BG/NBD: purchase frequency and P(alive)
bgm = clv.BetaGeoModel()
bgm.fit(data=data_summary)

# Gamma-Gamma: average order value, fit on repeat customers only
repeat = data_summary.query("frequency > 0 and monetary_value > 0")
gg = clv.GammaGammaModel()
gg.fit(data=repeat)

# CLV: expected purchases times expected spend, discounted at 1% a month
clv_estimate = gg.expected_customer_lifetime_value(
    transaction_model=bgm,
    data=data_summary,
    future_t=120,       # 120 months = 10 years
    discount_rate=0.01,
    time_unit="D",
)

The output includes not just point estimates but HDI (Highest Density Interval) bounds. In this API, future_t is measured in months, while time_unit="D" tells the model that the RFM-T inputs are measured in days. The bounds quantify uncertainty in purchase timing only: the spend posterior is summarized to its mean before discounting, so treat them as a lower bound on the real uncertainty.

Choose the horizon explicitly; future_t=120 is not a default to accept. This dataset covers about 23 months, so a 120-month projection runs roughly five times past the observed window. The estimate stays bounded, because BG/NBD builds customer dropout into the projection, but that dropout rate is itself estimated from those 23 months. The companion notebook re-discounts the same posterior at 3, 5, and 10 years. On this dataset, customer ranking barely moves across the three, so rank-based targeting is insensitive to these tested horizons; the median 10-year estimate is about 2.23 times the 3-year estimate, so anything that turns CLV into a dollar ceiling has to state the horizon it used.

Probability Alive Matrix

A quick way to see what the BG/NBD model has learned is the Probability Alive matrix. Recency on one axis, frequency on the other, color showing P(alive). Remember that recency here is the BTYD definition from the table above, the span from first to last purchase, so high recency means the customer was still buying recently, the opposite of how marketing RFM uses the word. Read the four corners separately. Loyal repeaters (high frequency, high recency) buy often and are still active. At-risk loyalists (high frequency, low recency) used to buy a lot and then went quiet. One-time passersby (low frequency, low recency) made a purchase or two right after acquisition and then stopped. Thin-history customers (low frequency, high recency) have too few purchases to be sure, but the most recent one is fresh, so P(alive) comes out high; the figure labels this corner new customers.

Probability-alive matrix over purchase frequency (x) and recency (y); color shows P(alive) for each customer position.
Figure 11: The Probability Alive matrix.

Revenue CLV → Profit CLV

The Gamma-Gamma model estimates revenue per transaction. To make CLV useful for budget decisions, convert revenue to profit:

\[ \text{CLV}_{\text{profit}} = \text{CLV}_{\text{revenue}} \times \text{Gross Margin} \]

If margins vary a lot across product categories, compute customer-specific margins from purchase history instead of using a flat rate.

Combining Segments and CLV

Join the segment_id from Section 4.1 with each customer’s CLV estimate. This gives you the operating table the part has been building toward: what kind of customer this is, what they are worth, and what the business should do for them.

Table 4 is that table for the grocery households: profit CLV over ten years, at the 28% gross margin the notebook assumes.

Table 4: Behavioral segment × predicted value, from the companion notebook.
Segment Customers Mean profit CLV Conservative profit CLV
Heavy loyalists 610 $5,659 $5,368
Frequent small-basket 567 $2,553 $2,454
Occasional big-basket 539 $1,537 $1,515
Discount-leaning 478 $934 $924
Lapsed 287 $271 $267

A heavy loyalist is worth about twenty times a lapsed household, so a single spend ceiling per customer is too high for the bottom rows and too low for the top one. What to spend under that ceiling depends on the campaign’s incremental effect.

Demographics can still help describe or reach a segment, but the main decision layer is behavioral segment × predicted value. The companion notebook joins CLV estimates with the Dunnhumby hh_demographic.csv so you can profile each segment along demographic dimensions such as income: useful for picking creative and channel, less so for setting budget.

Putting CLV to Work

Once you have a clv_estimate per customer, three applications need no further modeling, though each needs more than the score. A CPA ceiling needs the margin conversion above and a stated horizon; a churn alert needs a CRM join on customer ID and a threshold; a cohort forecast needs each customer’s acquisition date and finance’s planning horizon. The patterns work for any CLV score.

CPA Ceilings for Ad Bidding

Set the maximum CPA as a fraction of predicted profit CLV:

\[ \text{Allowable CPA} = \text{CLV}_{\text{profit}} \times \text{Target acquisition ratio} \]

If a segment has a predicted profit CLV of $200 and your target acquisition ratio is 33%, the max CPA is $66. For bidding under uncertainty, use a conservative lower bound of predicted profit CLV rather than the mean. Many ad platforms can ingest value signals for value-based bidding or audience rules, but the exact implementation depends on the platform.

Churn Alerts for CRM

Flag customers whose P(alive) drops more than 30 points in 30 days. The signal is the rate of change, not the absolute level. A customer whose P(alive) fell from 0.85 to 0.40 in a month is far more urgent than one who has been steady at 0.35 for six months. The first customer is moving away from a previously high engagement level; the second has been a low-frequency buyer all along.

Cohort Forecasts for Finance

Finance plans on budget cycles, not lifetimes, so aggregate individual CLV estimates by acquisition cohort and project revenue at 12, 24, and 36 months. Include HDI bounds so Finance knows these are probabilistic estimates, not fixed targets. This answers the finance question of expected return on a quarter’s acquisition spend, in the units and the time frame finance plans in.

Monitoring

Compare predicted to actual revenue per cohort at 3, 6, and 12 months. If the ratio drifts more than ±20%, retrain. Also check CLV predictions for bias against protected groups: models trained on under-served segments will perpetuate that bias by predicting lower CLV and setting lower acquisition bids.

Key Takeaways

  • CLV replaces a uniform CPA target with spend proportional to what each customer is worth; a single ceiling overpays for low-value customers and underpays for high-value ones.
  • In non-contractual settings, BG/NBD models future purchases and Gamma-Gamma models spend, from transaction data alone. Every customer gets a credible interval, so set the bid from a conservative lower bound of the interval.
  • Convert revenue CLV to profit CLV before it sets a CPA ceiling, and state the horizon: the median ten-year estimate runs about 2.23 times the three-year one, though the ranking barely moves.