Sub topic 3
Consent and privacy boundaries
This chapter assumes you know basic email marketing terms, have used an email service provider (ESP) or CRM, and can read simple boolean logic. The SQL examples are optional but use the same subscribers and events tables as the rest of the tutorial.
Segmentation makes your list more useful. It also makes it more sensitive. Every rule you write turns stored data into a decision about a person. Consent and privacy limits decide which data you may use and which people you may email at all.
Consent comes before every rule
Consent is a person's recorded permission to receive a specific kind of message from you. A segment can only narrow a list of people who are already allowed to receive the message. It can never widen that list.
In practice, this means every segment query starts with a consent filter. The earlier examples already do this with s.status = 'subscribed'. Treat that filter as required, not optional.
Three common states matter:
| Status | Meaning | Can a segment include them? |
|---|---|---|
| subscribed | Opted in and has not withdrawn | Yes |
| unsubscribed | Withdrew consent | No |
| suppressed | Bounced, complained, or blocked by a legal request | No |
A common error is to build a segment from events alone. A person who clicked a link last week and unsubscribed yesterday still appears in the events table. The segment must join back to subscribers to check current status.
Preferences are a second filter
Consent is not all or nothing. Many people agree to some topics or frequencies and refuse others. A preference is a choice a subscriber makes about what they receive. Examples are "weekly digest only" or "no promotional offers".
Preferences should override inferred data. If someone clicked three running articles but set their preferences to "product news only", the explicit choice wins. Explicit data is what the person told you. Inferred data is what you guessed from their behaviour.
-- PostgreSQL: running-interest subscribers who have not opted out of promotions
SELECT s.id
FROM subscribers s
WHERE s.status = 'subscribed'
AND s.promo_opt_out = false
AND s.id IN (
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
);This query assumes a boolean column promo_opt_out on subscribers. Your own schema may store preferences differently, for example in a separate table or as tags.
The path from data to a segment
Putting the filters first also protects you from mistakes in the rule itself. If a rule is wrong, it can only be wrong among people you were allowed to email.
Data minimisation and sensitive inferences
Data minimisation means collecting and using only the data you need for a stated purpose. Before you add a field or event to a segment, ask what message it supports. If you cannot name one, do not build the segment.
Be careful with sensitive inferences. A click pattern can suggest health conditions, finances, religion, or other personal matters. Privacy laws in many places apply stricter rules to these categories. A segment called "likely diabetic" built from clicks on recipe pages is risky even if the clicks were real. Prefer segments based on stated topics, such as "clicked running content", over segments that label a person's private characteristics.
Also check these points:
- Purpose: use data for the purpose you told people about when they signed up.
- Retention: delete or archive events you no longer need. A 60-day rule does not need three years of history.
- Regional rules: laws such as the GDPR (EU and UK) and CAN-SPAM (US) set different requirements. Ask your legal or privacy team which apply to your list.
Honouring changes quickly
Consent changes over time. A person who unsubscribes must leave every segment, including static ones. A static segment is a fixed list captured at one moment, so it will not update on its own. Before each send, re-check status against the live subscribers table, or use a suppression list that your ESP applies automatically.
Exercise
A teammate builds a segment of everyone who clicked a sale email in the last 14 days, using only the events table. Name two problems with this segment and how to fix each.
Show answer
First, the segment ignores current consent. Someone may have unsubscribed after clicking, so join to subscribers and require status = 'subscribed'. Second, it ignores preferences. A person who opted out of promotions may still have clicked, so also exclude those with an opt-out flag. Applying both filters before the click rule fixes both problems.