Sub topic 3
Consent and privacy boundaries
This chapter assumes you know what a segment rule is at a basic level, and that you have met the subscriber profile fields and event data from the previous chapter. You should be comfortable reading short SQL queries. The examples use PostgreSQL, but the ideas apply to any email service provider (ESP) or CRM. This chapter is not legal advice. It gives you a working model so you can ask the right questions of your legal or privacy team.
Why consent comes before segmentation
Every segment is built from data about a person. Before you write a rule, ask whether you are allowed to use that data for that purpose. A segment that is technically correct but uses data without permission can lead to complaints, blocked sending domains, and fines.
Three ideas do most of the work in this chapter:
- Consent is a person's recorded, specific agreement to receive a kind of message or to have their data used in a certain way.
- Purpose limitation means data collected for one reason should not quietly be reused for an unrelated one.
- Data minimisation means you collect and use only what the segment needs.
These ideas shape which segments you can build, which data feeds them, and what happens when someone changes their mind.
What the rules generally require
Rules differ by country, and you should check the ones that apply to your subscribers, wherever they live. The table below gives the common patterns, not a full legal summary.
| Regime | Typical model for marketing email | What it means for segmentation |
|---|---|---|
| GDPR (EU) and UK GDPR | You need a lawful basis for processing. For email marketing this is usually consent, and PECR in the UK allows a limited "soft opt-in" for existing customers. | You must tell people about profiling. People can object to direct marketing at any time, and you must then stop. |
| CAN-SPAM (US) | Opt-out. You may send without prior consent if you identify yourself and honour unsubscribes promptly. | Unsubscribes must remove people from every segment, including ones built later. |
| CASL (Canada) | Express or implied consent is required, and you must be able to prove it. | You need consent records you can query, not only a flag. |
The common thread is that a person's current wishes override any segment rule. The segment is a query over the list. The consent state decides who is eligible to be queried in the first place.
Separate the three things people agree to
Intermediate teams often store one boolean such as opted_in = true. That loses information. At least three different permissions exist, and they can vary independently:
- Permission to send a given type of email, such as marketing, product news, or receipts.
- Permission to track behaviour, such as opens and clicks, and to use that tracking to personalise.
- Stated preferences, such as the topics a person chose in a preference centre.
A person can say yes to a monthly newsletter and no to being profiled by their clicks. If your interest segment from earlier uses click behaviour, it relies on the second permission, not just the first.
Notice the default. When consent is unknown, the answer is "exclude". This is called default deny, and it protects you from gaps in your data.
Recording consent so you can query it
A flag tells you the current state but not how you got there. For proof, store each consent decision as its own row. Then derive the current state from the latest row per person and purpose.
-- PostgreSQL: consent history, one row per decision
CREATE TABLE consent_records (
id bigserial PRIMARY KEY,
subscriber_id bigint NOT NULL,
purpose text NOT NULL
CHECK (purpose IN ('email_marketing', 'behavioural_tracking', 'interest_profiling')),
granted boolean NOT NULL,
source text NOT NULL, -- e.g. 'signup_form', 'preference_centre', 'import'
recorded_at timestamptz NOT NULL DEFAULT now()
);
CREATE INDEX consent_records_lookup
ON consent_records (subscriber_id, purpose, recorded_at DESC);
-- Latest decision per subscriber and purpose
CREATE VIEW current_consent AS
SELECT DISTINCT ON (subscriber_id, purpose)
subscriber_id, purpose, granted, source, recorded_at
FROM consent_records
ORDER BY subscriber_id, purpose, recorded_at DESC, id DESC;The view uses DISTINCT ON, a PostgreSQL feature that keeps the first row for each (subscriber_id, purpose) pair under the given ordering. Because the ordering puts the newest decision first, a later withdrawal overrides an earlier grant. The history table stays untouched, so you can still show when and where each decision was made.
Applying consent inside a segment rule
Take the interest segment from the earlier example: subscribers who clicked at least twice on running content in the last 60 days. That rule turns click behaviour into a profile of someone's interests. Add the consent check as a join, so only people who agreed to interest profiling are counted.
-- PostgreSQL: running-interest segment, limited to people who consented to profiling
SELECT e.subscriber_id
FROM events e
JOIN subscribers s
ON s.id = e.subscriber_id
AND s.status = 'subscribed'
JOIN current_consent c
ON c.subscriber_id = s.id
AND c.purpose = 'interest_profiling'
AND c.granted
WHERE e.event_type = 'email_click'
AND e.topic = 'running'
AND e.occurred_at >= now() - interval '60 days'
GROUP BY e.subscriber_id
HAVING COUNT(*) >= 2;The inner join on current_consent is what implements default deny. A subscriber with no consent row has no matching row in the view, so they drop out. If you used a LEFT JOIN and tested granted IS NOT FALSE, people with missing records would slip in. That is a common error.
Stated preferences versus inferred interests
An interest can reach your segments in two ways:
- Declared. The person picked "running" in a preference centre. This is the strongest signal of both interest and consent, because they told you directly.
- Inferred. You concluded it from clicks or page views. This is useful but needs the profiling permission, and it can be wrong.
When the two disagree, declared preferences should win. If someone unticks "running" in the preference centre, a click history that says otherwise must not put them back into the running segment. Model this as a suppression, not as a score you hope will average out.
-- PostgreSQL: remove people who have opted out of a topic they previously clicked on
-- Assumes topic_preferences(subscriber_id, topic, wanted boolean, updated_at)
SELECT s.id
FROM subscribers s
WHERE s.status = 'subscribed'
AND NOT EXISTS (
SELECT 1
FROM topic_preferences p
WHERE p.subscriber_id = s.id
AND p.topic = 'running'
AND p.wanted = false
);You would combine this NOT EXISTS clause with the interest rule above, using AND. The previous chapter's boolean logic applies directly: eligibility conditions are always joined with AND, never OR, so that a single "no" blocks inclusion.
Sensitive topics
Some interests reveal sensitive facts about a person. Under GDPR, categories such as health, religion, sexual orientation, and political opinion get extra protection. This applies even when you only infer them. A segment named diabetes_interest built from clicks on health articles may count as processing health data.
Practical rules:
- Avoid creating segments for sensitive categories unless you have a clear need and explicit consent for that exact purpose.
- Watch for proxies. A topic such as "mobility aids" or "fertility" may reveal the same thing.
- Name segments by what the message offers, not by what you assume about the person.
running_shoe_offersis safer and more accurate thaninjured_runners.
Honouring withdrawal and suppression
Consent can be withdrawn at any time, and the effect should be immediate and complete.
- Unsubscribe removes the person from all marketing segments, current and future. Keep them on a suppression list so an import or sync cannot bring them back.
- Withdrawing profiling consent leaves them on the list, but they must leave interest and behavioural segments that depend on tracking.
- Erasure requests may require deleting events and profile fields, not only hiding the person. Plan how your events table handles this.
The risk is stale copies. Many ESPs build static segments, which are snapshots. If a static segment was exported last week, someone who unsubscribed yesterday is still in it. Before every send, re-apply the eligibility checks to the audience, even for static segments. The next chapter on static and dynamic segments covers how those two kinds age.
Practical safeguards
- Keep a data map. For each field and event type, write down its purpose, the permission it depends on, and how long you keep it.
- Tell people what you do. Your privacy notice and signup form should say that you personalise emails using clicks and preferences.
- Limit retention. A 60-day window in a rule is a query choice. It does not mean data older than 60 days is gone. Set a retention period for raw events and delete on schedule.
- Limit access. Not everyone who builds campaigns needs to see raw consent history or sensitive fields.
- Log changes. Record who edited a segment rule and when, because a rule change can change which data you are using.
- Test with a known case. Create a test subscriber who has withdrawn consent and confirm they never appear in any segment output.
Common errors
| Error | Why it causes harm | Fix |
|---|---|---|
| One `opted_in` flag for everything | Cannot tell send consent from profiling consent | Store consent per purpose |
| Treating missing consent as yes | Includes people who never agreed | Inner join on a recorded yes |
| Overwriting the consent flag | No proof of when or how consent was given | Append rows, derive the current state |
| Sensitive segment names or inferences | Creates special-category data by accident | Name by offer, avoid proxies |
| Checking consent only at segment creation | Withdrawals after creation are missed | Re-check at send time |
| Importing a purchased or old list | Consent is not valid for your purpose | Do not import without verified consent |
Exercises
Exercise
A subscriber agreed to receive your monthly newsletter but never gave a decision about interest profiling. Your running-interest rule uses clicks. Should this person appear in the segment, and what part of the query makes sure of that?
Show answer
No. Having consent to send is separate from consent to profile. The rule should use an inner join to the currentconsent view with purpose = 'interestprofiling' and granted = true. The subscriber has no profiling row, so the join finds nothing and they are excluded. This is default deny.
Exercise
Someone clicked three running links last month, then unticked "running" in the preference centre yesterday. Your segment was exported as a static list last week. What should happen before the next send, and why?
Show answer
They should not receive the running message. The declared preference overrides the inferred click behaviour. Because the exported static list is a snapshot, it still contains them, so the audience must be re-filtered at send time against the topic preference (for example with a NOT EXISTS check on topic_preferences) and against the suppression list.