Sub topic 9
Segmenting by lifecycle stage
A lifecycle segment groups subscribers by where they are in their relationship with you: just joined, buying regularly, or gone quiet. This chapter assumes you have read the chapters on segment rules and on static and dynamic segments. It also assumes you can read basic SQL (SELECT, WHERE, CASE, CTE) and are comfortable with AND, OR and NOT. The SQL targets PostgreSQL. In a visual segment builder the logic is the same, only the syntax differs.
What a lifecycle stage is
Behavioural and interest segments describe what a subscriber did or cares about. A lifecycle stage describes the subscriber's overall position in the relationship, and it answers one question: what does this person need from us right now?
- A brand-new subscriber needs a welcome and an explanation of what to expect.
- A prospect who has subscribed but never bought needs a reason to make a first purchase.
- An active customer needs relevant offers and little pressure.
- A lapsed customer needs a reason to return, or eventually a graceful exit.
Each stage calls for a different message, which is why the stage is worth modelling explicitly. Sending the same promotion to all four groups usually helps none of them.
Three properties of a good stage definition
A set of lifecycle stages works when it has these properties:
- Mutually exclusive. Each subscriber is in exactly one stage at any moment. Overlap causes duplicate emails and makes results hard to read.
- Collectively exhaustive. Every subscribed contact lands in some stage, including the awkward cases such as missing data.
- Defined by data you actually have. A stage rule must be computable from fields you store, such as
created_atandlast_purchase_at. A stage like "loyal advocate" fails if you do not record the data that would identify one.
Behavioural and interest segments are allowed to overlap, because one person can click often and like running. Lifecycle stages are different because they describe a single position, so you should enforce exclusivity in the rules rather than hope for it.
The stage model used in this chapter
The examples use four stages and a subscribers table with these columns:
| Column | Meaning |
|---|---|
| `id` | Subscriber identifier |
| `status` | Consent state, for example `subscribed` or `unsubscribed` |
| `created_at` | When the person joined the list |
| `last_purchase_at` | Timestamp of the most recent purchase, or `NULL` if none |
| Stage | Entry rule | Typical goal of the message |
|---|---|---|
| `active_customer` | Purchased within the last 90 days | Cross-sell, loyalty, referrals |
| `lapsed_customer` | Purchased at some point, but not in the last 90 days | Win-back |
| `new_subscriber` | Never purchased, joined within the last 14 days | Welcome, set expectations |
| `prospect` | Never purchased, joined more than 14 days ago | First-purchase offer, education |
The 90-day and 14-day thresholds are examples. Pick them from your own data, as described later in this chapter.
Stages move over time
Subscribers do not stay in one stage. They move between stages as time passes and as they act, and the segment has to follow them.
Two transitions in the diagram are driven by the clock rather than by an action: new_subscriber to prospect, and active_customer to lapsed_customer. Nothing happens in your data when they fire. The subscriber simply stops matching one rule and starts matching another. This is why lifecycle segments should be dynamic, which the next section explains.
Why lifecycle segments should be dynamic
A static segment is a snapshot taken once. If you build "new subscribers" as a static list on Monday, the people in it are no longer new three weeks later, but they are still in the list. A dynamic segment re-evaluates its rules each time it is used, so membership follows the rules.
For lifecycle stages, use dynamic evaluation by default. Use a static snapshot only for a purpose that needs a frozen audience, such as the treatment group of an experiment (see the final chapter on measurement).
Writing the stage rules with CASE
In SQL, CASE is the natural tool for exclusive stages. It tests the branches from top to bottom and returns the result of the first one that matches. Because evaluation stops at the first match, a subscriber cannot receive two stages.
-- PostgreSQL: assign each subscribed contact exactly one lifecycle stage
SELECT id,
CASE
WHEN last_purchase_at >= now() - interval '90 days' THEN 'active_customer'
WHEN last_purchase_at IS NOT NULL THEN 'lapsed_customer'
WHEN created_at >= now() - interval '14 days' THEN 'new_subscriber'
ELSE 'prospect'
END AS lifecycle_stage
FROM subscribers
WHERE status = 'subscribed';Walk through how this query reaches each stage:
- A recent purchase matches the first branch, so the subscriber is
active_customer. This applies even to someone who joined yesterday. A person who subscribed and bought on the same day is a customer first. - A subscriber with any older purchase fails the first branch but passes the second, so they are
lapsed_customer. The second branch does not repeat the 90-day check, because reaching it already means the first one failed. - A subscriber with no purchase and a recent
created_atisnew_subscriber. - Everyone left, with no purchase and an older join date, falls into
ELSEand becomesprospect.
The ELSE branch is what makes the stages collectively exhaustive. Without it, any unmatched row would get NULL as its stage and silently drop out of every campaign.
The WHERE status = 'subscribed' filter keeps unsubscribed and suppressed contacts out of every stage. Consent applies before any segmentation logic, so keep it at the top of each query.
Why the order of branches matters
If you moved the new_subscriber branch to the top, a subscriber who joined last week and already bought would be classed as new, and your customer messaging would miss them. If you wrote the stages as independent WHERE conditions instead of one CASE, a recent buyer would match both active_customer and new_subscriber. When you design rules, decide the priority order on purpose and write it down. Put the most specific or highest-value state first.
Handling edge cases in the data
Stage rules fail quietly when the underlying fields are wrong. Check these cases before you trust a segment:
NULLinlast_purchase_at. In SQL,NULL >= somethingevaluates to unknown, not true, so the first branch skips it. TheIS NOT NULLtest in the second branch then separates buyers from non-buyers. If your system stores "no purchase" as a zero date or an empty string instead ofNULL, these rules will misclassify people.- Future timestamps. A
last_purchase_atlater thannow()is a data error, perhaps from a timezone bug. It passes the first branch and makes the subscriber look active. Add a data-quality check for it. - Refunds and cancellations. Decide whether a refunded order still counts as a purchase. If it does not,
last_purchase_atmust be computed from valid orders only. - Subscribers who rejoin. If a person unsubscribes and signs up again,
created_atmay reset. They then appear as anew_subscribereven though they have a purchase history. In the CASE above, the purchase branches run first, so a returning buyer is still treated as a customer, but a returning non-buyer is treated as new. - Boundary timing.
now() - interval '90 days'moves every second. A subscriber who purchased exactly 90 days ago can change stage between two queries run a minute apart. For a campaign, evaluate once and use that result for the whole send. Do not re-evaluate it halfway through.
Reusing the stage logic in a view
You will want the same stage definition in many segments. Copying the CASE into every query creates drift: one copy gets the threshold changed and the others do not. Define it once as a view.
-- PostgreSQL: one shared definition of lifecycle stage
CREATE OR REPLACE VIEW subscriber_lifecycle AS
SELECT id,
CASE
WHEN last_purchase_at >= now() - interval '90 days' THEN 'active_customer'
WHEN last_purchase_at IS NOT NULL THEN 'lapsed_customer'
WHEN created_at >= now() - interval '14 days' THEN 'new_subscriber'
ELSE 'prospect'
END AS lifecycle_stage
FROM subscribers
WHERE status = 'subscribed';
-- Sanity check: stage sizes should add up to the number of subscribed contacts
SELECT lifecycle_stage, COUNT(*) AS contacts
FROM subscriber_lifecycle
GROUP BY lifecycle_stage
ORDER BY contacts DESC;The second query is a useful habit. The counts must sum to the number of rows in subscribers with status = 'subscribed'. If they do not, or if a NULL stage appears, the rules have a gap.
Choosing thresholds
The 90-day and 14-day values are not universal. Choose them from how your customers behave.
- The active window should be a little longer than your typical gap between purchases. A shop where people reorder monthly might use 60 or 90 days. A business selling annual products needs 12 months or more. If the window is too short, loyal customers are called lapsed and receive win-back offers. If it is too long, you miss people who are drifting away.
- The new window should match the length of your welcome series. If the series runs for ten days, a 14-day window lets everyone finish it before becoming a prospect.
- A way to check: compute the distribution of days between a customer's first and second purchase, and set the active window near its upper range, for example the 80th percentile.
Treat the first values as a hypothesis and adjust them after you see how the stage sizes and results come out.
Combining a lifecycle stage with another dimension
A stage on its own is broad. Its real value shows when you join it with interest or behaviour, so that a message fits both who the person is in the relationship and what they care about. This query selects active customers who clicked running content at least twice in the last 60 days.
-- PostgreSQL: active customers interested in running
WITH staged AS (
SELECT id,
CASE
WHEN last_purchase_at >= now() - interval '90 days' THEN 'active_customer'
WHEN last_purchase_at IS NOT NULL THEN 'lapsed_customer'
WHEN created_at >= now() - interval '14 days' THEN 'new_subscriber'
ELSE 'prospect'
END AS lifecycle_stage
FROM subscribers
WHERE status = 'subscribed'
),
running_interest AS (
SELECT subscriber_id
FROM events
WHERE event_type = 'email_click'
AND topic = 'running'
AND occurred_at >= now() - interval '60 days'
GROUP BY subscriber_id
HAVING COUNT(*) >= 2
)
SELECT st.id
FROM staged st
JOIN running_interest ri ON ri.subscriber_id = st.id
WHERE st.lifecycle_stage = 'active_customer';The join is an AND: the person must be an active customer and have the interest. Each added condition shrinks the result. Check the size before you commit to a campaign. If the combined segment has only a handful of people, you may get results too noisy to learn from. In that case relax one condition, for example by using a 90-day interest window, or send the broader stage-level message.
A message plan per stage
Here is how stages translate into campaigns. Treat it as a starting point, not a rule.
| Stage | Message | What to avoid |
|---|---|---|
| `new_subscriber` | Welcome series, what to expect, preference centre link | Heavy discounts before they know you |
| `prospect` | Education, social proof, a first-purchase incentive | Language that assumes they have bought |
| `active_customer` | Related products, new arrivals, loyalty | Discounts that train buyers to wait for sales |
| `lapsed_customer` | Win-back with a reason to return, then a sunset step | Pretending you have not heard from them for years |
For lapsed customers, plan an exit. If a win-back sequence gets no response, stop mailing them or move them to a low-frequency stream. Continuing to send to people who never engage lowers your engagement rates and can hurt deliverability.
Common mistakes
- Writing stages as separate overlapping filters instead of one ordered rule, which leads to duplicate sends.
- Forgetting an
ELSE, so some contacts have no stage. - Using a static list for a stage that changes with time.
- Setting thresholds by habit instead of from your purchase gaps.
- Skipping the consent filter when building a stage view for convenience.
Exercise
A subscriber joined 5 days ago and bought something yesterday. Using the CASE query in this chapter, which stage do they get, and what would change if you moved the new_subscriber branch to the top of the CASE?
Show answer
They get active_customer, because their last_purchase_at is within 90 days and that branch is tested first. If new_subscriber were first, they would match it instead (they joined within 14 days), and the CASE would stop there. Their purchase would be ignored and they would receive welcome messaging rather than customer messaging. Branch order sets the priority.
Exercise
The stage-size check returns 12,400 contacts in total, but subscribers has 12,650 rows with status = 'subscribed'. Name two likely causes in the rules or the data.
Show answer
Likely causes include a missing ELSE branch (the CASE returns NULL and the rows are not counted under a named stage, or are dropped by a later filter), or a NULL in a field such as created_at so that a comparison evaluates to unknown and no branch matches. Another cause is a join in the view that drops rows with no match. The fix is to keep an ELSE branch, clean the null or invalid fields, and use a left join where rows must be preserved.