Sub topic 4
Email: Segmentation, Send-Time Choice, and Personalization
This chapter covers how AI features decide who receives an email, when it arrives, and what each person sees. It assumes you know what a contact record, a campaign, and an engagement metric such as an open or click are. It also assumes you have a basic idea of what a machine learning model does.
Chapter 3 covered drafting and subject lines, which are generative features. The features here are mostly predictive and classification features. They do not write text. They choose among options you already have: which group, which hour, which version.
The three decisions
An email campaign involves three audience decisions. AI features can automate each one.
| Decision | Question the feature answers | Typical technique | Typical output |
|---|---|---|---|
| Segmentation | Which contacts belong together? | Clustering or a predictive model | A group label or a propensity score |
| Send-time choice | When will this contact most likely engage? | Statistics on past engagement, or a model | An hour of day or a weekday per contact |
| Personalization | Which content or offer fits this contact? | Rules, recommendation models, or a ranking model | A content block, product, or offer per contact |
All three depend on the data the platform holds about each contact. That data includes past opens, clicks, purchases, sign-up source, and, where the platform is connected to a CRM, deal stage. A feature can only learn from signals that were recorded. A new contact with no history gives it nothing to work with.
Segmentation
A segment is a group of contacts that you treat the same way in a campaign. Rule-based segments are written by hand, such as "bought in the last 90 days and lives in Canada". AI-assisted segmentation comes in two common forms.
Clustering
Clustering is an unsupervised technique. Unsupervised means no one tells the model the right answer. It groups contacts that look alike on features you supply, such as order count, days since last purchase, and average order value. The model returns cluster numbers. A person must then read the clusters and name them, for example "frequent small buyers" or "lapsed big spenders".
Propensity segments
A propensity model is a supervised model. Supervised means it learns from past examples with known outcomes. It predicts how likely a contact is to do something, such as buy or unsubscribe. The platform then offers segments like "likely to churn" or "likely to purchase", built by cutting the score at a threshold. Lead scoring in the CRM chapter uses the same idea.
Here is a minimal clustering example. It groups contacts by recency and spend.
import numpy as np
from sklearn.cluster import KMeans
from sklearn.preprocessing import StandardScaler
# Columns: days_since_last_purchase, total_spend
contacts = np.array([
[5, 900],
[8, 750],
[10, 820],
[200, 40],
[180, 55],
[220, 30],
[60, 300],
[55, 280],
])
scaled = StandardScaler().fit_transform(contacts)
labels = KMeans(n_clusters=3, n_init=10, random_state=0).fit_predict(scaled)
for row, label in zip(contacts, labels):
print(f"cluster {label}: days={row[0]}, spend={row[1]}")The scaling step matters. Without it, spend (hundreds) would dominate recency (tens), and the clusters would reflect almost only spend. The cluster numbers are arbitrary labels. Running the code again with a different random_state can swap them.
Segmentation gotchas
- Stale segments. A dynamic segment recalculates as contacts change. A static one is a snapshot. Check which kind the feature creates before you schedule a campaign weeks later.
- Cluster count. The number of clusters is a choice. Too many gives groups too small to act on. Too few hides differences.
- Meaningless groups. Clusters always form, even when the data has no real structure. Check that a cluster differs from the others on a metric you care about before building content for it.
- Sensitive proxies. Postcode, name, or language can stand in for protected traits. See the risks chapter.
Send-time choice
Send-time optimization, often shortened to STO, picks the delivery time for each contact. The idea is that an email arriving when a person usually checks their inbox is more likely to be opened.
How it works
The simplest version builds a profile of each contact's past engagement by hour and weekday. It then schedules the send for the hour with the most past opens. More advanced versions use a model that also considers time zone, device, and recent behavior. Many platforms treat the choice as a bandit problem. A bandit is a method that mostly picks the time that has worked best but sometimes tries other times to keep learning.
The next example finds each contact's best hour from a log of past opens.
from collections import Counter, defaultdict
# (contact_id, hour_of_day) for each past open
opens = [
("ana", 8), ("ana", 8), ("ana", 9), ("ana", 20),
("ben", 21), ("ben", 21), ("ben", 22),
("cho", 13),
]
by_contact = defaultdict(Counter)
for contact, hour in opens:
by_contact[contact][hour] += 1
MIN_OPENS = 3 # fewer than this is too little evidence
DEFAULT_HOUR = 10
for contact, counts in by_contact.items():
total = sum(counts.values())
if total < MIN_OPENS:
print(f"{contact}: {total} opens, use default hour {DEFAULT_HOUR}")
else:
hour, n = counts.most_common(1)[0]
print(f"{contact}: send at {hour}:00 ({n} of {total} opens)")The MIN_OPENS rule is the important part. Contact "cho" has one open, which is not a pattern. Real features use a fallback like this, usually a send time chosen for the whole audience, for contacts with little history.
Send-time gotchas
- Opens are noisy. Mail privacy features in some email apps pre-load messages, so an open can be recorded when no person looked at the email. Time-of-open data then reflects when the app fetched the message. Clicks are a stronger signal than opens.
- Feedback loops. If the system only sends at the "best" hour, it only collects data for that hour. A feature without exploration never learns that another hour might be better.
- Time zones. Check that the platform delivers in the contact's local time or that its learned hour already accounts for it.
- Urgent or timed messages. A webinar reminder or a sale ending at midnight should not be moved. Turn STO off for these sends.
- Delivery spreading. Sending to everyone at their own best hour spreads load over a day. It can delay time-sensitive campaigns and complicates reporting by send date.
Personalization
Personalization changes what a contact sees. It ranges from simple to model-driven.
- Merge fields. Insert a first name or company. No AI is involved.
- Dynamic content blocks. Show one block or another based on rules, such as the contact's segment or location.
- Recommendations. A model ranks products or articles for each contact, often from past purchases or from what similar contacts bought. The email template has a slot, and the model fills it.
- Generated variants. A language model rewrites copy for a segment. This links back to the drafting chapter and brings its review needs.
Fallbacks and missing data
Every personalization element needs a fallback for missing or unreliable data. A merge field with no value produces "Hi ," or "Hi {{first_name}}" in a real inbox. A recommendation slot with no history needs a default, such as best sellers.
def greeting(first_name: str | None) -> str:
"""Return a greeting that never shows an empty or placeholder name."""
name = (first_name or "").strip()
if not name or "{" in name:
return "Hello,"
return f"Hello {name.title()},"
print(greeting("ana"))
print(greeting(None))
print(greeting(" "))
print(greeting("{{first_name}}"))Personalization gotchas
- Cold start. A contact with no history cannot receive a learned recommendation. Use a default.
- Creepiness. Personalization that reveals how much you know, such as mentioning a page the contact viewed once, can reduce trust. Consent rules may also restrict which behavior data you can use.
- Narrowing. A recommender that only shows what a contact already bought can stop them from seeing other products.
- Too many variants. Each variant needs enough recipients for a fair comparison. Splitting a small list across many versions yields results too noisy to read.
How the pieces fit together
The three features share inputs and can feed each other. A segment may define which content block appears. A propensity score may decide which contacts get a discount. Send time is then chosen for each contact in that segment.
The diagram below shows the flow.
The loop from results back into contact data is what lets these features improve. It is also the source of the feedback problems described above.
Checking that it works
A higher open rate after turning on a feature does not show that the feature caused it. Seasonality, list changes, and subject lines all shift results. Keep a holdout, which is a random group of contacts that receives the standard version. Compare the two groups on the same dates. Prefer clicks, conversions, and revenue per recipient over opens. Unsubscribe and spam-complaint rates belong in the comparison, because a tactic that raises clicks while raising complaints can damage sender reputation. The measurement chapter covers this in full.
Summary of decision criteria
- Use clustering when you do not know what groups exist. Use a propensity segment when you have a specific outcome to predict.
- Use send-time optimization for routine newsletters with enough per-contact history. Turn it off for time-bound messages.
- Use model-driven personalization when you have enough history and variety in content. Otherwise rules and fallbacks are safer.
- Always keep a fallback, a holdout, and a record of consent.
Exercise
A store has 4,000 contacts. 3,000 of them opened at least three past emails, and 1,000 are new with no opens. The team enables send-time optimization for a Black Friday email that must arrive on Friday morning, and reports that opens rose 12% compared with last month's newsletter. Name two problems with this setup and one fix for each.
Show answer
First, the message is time-bound, so per-contact send times can move it away from the Friday-morning window. Fix: turn off send-time optimization for this campaign, or restrict the allowed window. Second, the comparison is against last month's newsletter, so seasonality and content differences are mixed in, and opens can be inflated by email apps that pre-load messages. Fix: hold out a random group that gets the standard send time, run both on the same dates, and compare clicks and conversions. A further point is that the 1,000 new contacts have no history, so they need a default send time.
Exercise
A clustering run on customer data returns three clusters, but the average spend and purchase frequency are almost the same in all three. What should you conclude, and what should you do before building segment-specific content?
Show answer
The clusters probably do not reflect real differences that matter for marketing, since clustering always produces groups even without structure. Do not build content for them yet. Check other features, adjust the number of clusters, or fall back to rule-based segments, and confirm that any chosen segment differs on a metric you care about.