Sub topic 7
Segmenting by behaviour
This chapter assumes you know basic email marketing terms (campaign, open rate, click rate), have used an email service provider or CRM, and can read boolean logic. The SQL examples use PostgreSQL and are optional.
A behavioural segment groups subscribers by what they did, not by who they are. The rule is a condition on recent events, such as clicks, purchases, or site visits. Behaviour changes often, so these segments are usually dynamic: membership is recalculated, and people move in and out as their actions age.
What a behavioural rule contains
Every behavioural rule has four parts.
- Event type. The action you count, for example
email_click. - Time window. How far back you look, for example 30 days. Without a window, one click from three years ago counts as current behaviour.
- Threshold. How many times the event must occur. "At least once" is the simplest. Higher counts filter out accidental actions.
- Eligibility. A check that the person is still subscribed. Consent comes before behaviour, so a recent click never overrides an unsubscribe.
Worked example: recent clickers
The query below selects subscribed contacts who clicked any email in the last 30 days.
-- PostgreSQL: subscribers who clicked an email in the last 30 days
SELECT s.id
FROM subscribers s
WHERE s.status = 'subscribed'
AND EXISTS (
SELECT 1
FROM events e
WHERE e.subscriber_id = s.id
AND e.event_type = 'email_click'
AND e.occurred_at >= now() - interval '30 days'
);Here is how it works:
s.status = 'subscribed'is the eligibility check.EXISTSasks whether at least one matching event is present. It stops at the first match, so it does not count every click.now() - interval '30 days'makes the window rolling. It moves forward each time the query runs, which is what makes the segment dynamic.
In an email service provider's visual builder, the same rule reads like this: "Status is subscribed AND has clicked an email in the last 30 days."
Choosing the window and threshold
The right window depends on how often you send and how often people buy. A weekly newsletter suits a 14 or 30 day window. A product people buy twice a year needs a much longer one.
| Choice | Effect | Risk |
|---|---|---|
| Short window (7 days) | Very current, highly engaged | Segment may be too small |
| Long window (90 days) | Larger, steadier segment | Includes people who have lost interest |
| Threshold of 1 | Easy to reach | Picks up accidental clicks |
| Threshold of 3 or more | Shows clear intent | Fewer people qualify |
Start with the window that matches your sending rhythm. Then check the segment size before you build a campaign on it.
Behaviours worth segmenting on
- Clicked recently. Reward them with more detailed content or an offer.
- Opened but never clicked. They read your emails but nothing prompts action. Test a clearer call to action.
- Visited a product page but did not buy. This needs a web event feed, not just email data.
- Purchased recently. Often excluded from promotions for the product they just bought.
- No activity for 90 days. A candidate for a re-engagement series.
Limits of behavioural data
Two more points apply. A person who does not click may still read your emails, so absence of a click is weak evidence. And a click shows interest in that one link, not in a whole topic. Interest segments, covered in the next chapter, handle topic-level inference.
Common errors
- Forgetting the eligibility check. The segment then includes unsubscribed people.
- No time window. Old behaviour keeps people in the segment indefinitely.
- Overlapping behavioural segments. "Clicked in 30 days" and "clicked in 90 days" overlap, so one person can get two messages. Make the rules exclusive, or set a priority order.
- Building before checking size. Count the members first. A segment of 40 people rarely justifies a dedicated campaign.
Exercise
You want to send a re-engagement email to subscribers who have not clicked any email in 90 days. Which parts of the rule do you need, and what must you do about people who joined 10 days ago?
Show answer
You need the eligibility check (status is subscribed), the event type (emailclick), a 90 day window, and a threshold of zero clicks, written as NOT EXISTS or a click count of 0. People who joined 10 days ago have had no chance to click for 90 days, so they would match by default. Exclude them with a condition such as createdat being older than 90 days.
Exercise
Why is a rolling window such as now() - interval '30 days' a good fit for a dynamic segment, and what would go wrong if you used a fixed date such as 2026-10-01?
Show answer
A rolling window moves forward each time the segment is recalculated, so people drop out when their last click ages past 30 days and join when they click. A fixed date never moves, so the segment would slowly stop reflecting recent behaviour and would behave like a static list.