Sub topic 8
Using Segments to Decide Who Sees What
This chapter assumes you can send a campaign, know what contact fields are, and have written a basic merge tag and an if/else block from earlier chapters. It covers how segments decide who receives a message or a version of it, and how that differs from logic inside the template.
What a segment is
A segment is a saved rule that selects a group of contacts from your list. The rule reads contact fields, tags, or recorded events. Examples:
planequalsprocountryisDEandlast_order_dateis within 90 days- the contact has the tag
vipor has clicked a link in the last 30 days
The platform checks each contact against the rule. Contacts that match are members. You can then send to the segment, or use it to choose which content version a contact sees.
A segment answers "who?" before the email is written for a specific person. A merge tag answers "what value goes here?" for one person. A conditional block answers "which text goes here?" for one person. The three work together, but they sit at different layers.
Segments versus conditional content
Both segments and conditionals let different people see different things. The choice affects how you maintain the email.
| Question | Segment | Conditional block in the template |
|---|---|---|
| Where is the rule defined? | In the audience tool, reusable across campaigns | Inside this one template |
| What does it control? | Who is sent the email, or which dynamic block is shown | Which text appears for the recipient |
| Who can read the rule? | Anyone who opens the audience tool | Only people who open the template |
| Typical use | "All lapsed customers" | "Show the plan-specific line" |
| Failure mode | Stale or overlapping membership | Missing field falls into the wrong branch |
Use a segment when the rule has a business meaning you will reuse, such as "active customers". Use a conditional when the difference is small and tied to one email, such as one line of text that changes by plan.
Writing segment rules
Most platforms offer the same building blocks, though the labels differ.
- Conditions compare a field to a value: equals, contains, is greater than, is empty, is not empty.
- Combinators join conditions. AND narrows the group, OR widens it.
- Time windows limit event rules, such as "opened an email in the last 60 days".
- Exclusions remove contacts, such as "not in the unsubscribed list".
Be careful with mixed AND and OR. Some builders let you group conditions, and some evaluate all ANDs before ORs. A rule such as "plan is pro OR plan is team AND country is DE" may not mean what you expect. Group the conditions explicitly and check the member count against a number you can estimate.
Static and dynamic segments
A dynamic segment recalculates membership, either continuously or when you send. A static segment is a snapshot taken at creation or import time. Static segments suit one-off sends, such as an event invitation list. For anything that depends on changing data, such as plan or recent activity, use a dynamic segment. A static one will keep sending the "free plan" message to someone who upgraded last week.
Find out when your platform evaluates a dynamic segment. Some recalculate at send time. Others recalculate on a schedule, so a contact who changed plan a few minutes ago may still be in the old group.
How segments choose content
There are two common patterns.
- Send-level targeting. You create a separate campaign or email version per segment. The platform sends each version only to its segment.
- Content-level targeting. One email contains several blocks. Each block is tied to a segment, and the platform shows a block only to members of that segment. This is the "dynamic content block" feature, covered in the next chapter.
The default block is required in practice. Contacts with a missing or unexpected field value match no segment, and without a default they would get an empty space.
Segment membership inside a template
Some platforms expose segment membership or tags as template variables. When they do, you can branch on them in Liquid-style syntax.
{% if customer.tags contains "vip" %}
As a VIP, you get early access to the sale today.
{% else %}
The sale opens to everyone on Friday.
{% endif %}Variable names and the way tags are stored vary. Some platforms give you a list, some a comma-separated string, and some expose no membership information in the template at all. Check your platform's documentation before relying on this pattern. Where templates cannot see segments, the dynamic block feature does the same job through the audience tool.
Modelling segment logic in code
Seeing the first-match logic written out makes its behaviour clear, including what happens to messy data. This Python script assigns each contact to the first segment whose rule matches, and falls back to a default.
SEGMENTS = [
("pro", {"plan": "pro"}),
("free", {"plan": "free"}),
]
def matches(contact, rule):
return all(contact.get(field) == value for field, value in rule.items())
def pick_segment(contact):
for name, rule in SEGMENTS:
if matches(contact, rule):
return name
return "default"
contacts = [
{"name": "Ana", "plan": "pro"},
{"name": "Ben", "plan": "free"},
{"name": "Cy"},
{"name": "Dee", "plan": "Pro"},
]
for contact in contacts:
print(contact["name"], "->", pick_segment(contact))The output is:
Ana -> pro
Ben -> free
Cy -> default
Dee -> defaultCy has no plan, so the rule cannot match. Dee's value is Pro with a capital letter, and the comparison here is case sensitive, so Dee falls to the default too. Some platforms compare case-insensitively and some do not. Either way, inconsistent values like this are why data cleaning matters before you build segments.
Common errors
Overlapping segments
A contact can belong to several segments. If two blocks both target contacts who match, the platform either shows the first block in order or shows both, depending on its rules. Decide which segment wins, then arrange block order to match. Check how your platform handles overlap before relying on it.
Negative conditions and missing data
"Plan is not free" usually includes contacts whose plan is empty. Those contacts may have no plan because the data never arrived, and they are not necessarily paying customers. Pair negative conditions with a positive one, such as "plan is not free AND plan is not empty".
Stale membership
If a segment is static, or recalculates on a schedule, contacts can receive content for a state they have left. For time-sensitive messages, such as a trial-expiry notice, confirm that the segment is evaluated at send time. Spot-check a contact whose data changed recently.
Segments that are too small
Narrow rules can leave a segment with only a few contacts. Each version costs effort to write, review, and test. Small segments also give you too little data to measure results. Start with a few broad segments and split further only when the content truly differs.
Excluding people by accident
Marketing sends should exclude contacts who have not consented or who have unsubscribed. Segment rules should include that exclusion explicitly, or the platform should apply it globally. Do not assume it. The consent chapter returns to this.
Sensitive attributes
A segment such as "contacts with a health condition" or one based on inferred personal traits can be intrusive and may be restricted by law. Segment only on data the contact gave you for this purpose, and keep the number of attributes to what the message needs.
Checking a segment before you use it
- Read the rule aloud as a sentence and confirm it matches the intent.
- Compare the member count with an independent estimate, such as a report or a database query.
- Open the member list and check three or four contacts by hand, including one near the edge of the rule.
- Add a test contact whose fields are empty and one whose values differ only in case, and confirm which segment each lands in.
- Confirm the platform evaluates the segment at send time if the content depends on current data.
Summary of decisions
- Use a segment when the rule is reusable and has business meaning.
- Use a conditional block when one small piece of text changes by one field.
- Always provide a default for contacts who match no segment.
- Prefer dynamic segments for anything that changes over time.
- Decide which segment wins when a contact matches several.
Exercise
A contact has no value in the plan field. Your email has a Pro block for plan equals pro, a Free block for plan equals free, and a third block for plan is not pro. Which blocks might this contact see, and how would you fix the setup?
Show answer
The contact matches the third block, because an empty plan is "not pro", so they might see content meant for free-plan users even though their plan is unknown. They match neither the Pro nor the Free block. To fix it, replace the third block with an explicit default block shown to everyone who matches no other segment, or add the condition "plan is not empty" to any negative rule. Then check the result with a test contact whose plan is empty.
Exercise
Why can a "contacts who bought in the last 30 days" segment send the wrong message if it is static?
Show answer
A static segment is a snapshot taken when it was built. Contacts who bought later are missing from it, and contacts who bought more than 30 days before the send are still in it. A dynamic segment recalculates membership, so it reflects the rule at the time of the send, if the platform evaluates it at send time.