Sub topic 3
Consent and Privacy as Design Constraints
This chapter assumes you have read the chapter on the customer data foundation and identity. You should know what a customer profile is and how events link to it. You should also be able to read short Python and basic SQL.
Why consent shapes the design
Consent is a customer's recorded permission to use their data for a stated purpose. Privacy law, such as GDPR in the EU and UK or CCPA in California, limits what you may collect and how you may use it. If you add these limits after building segments, you often have to rebuild them. Treat consent as an input to every pipeline step, in the same way you treat identity.
Three ideas do most of the work:
- Purpose limitation. Data collected for one purpose, such as order delivery, may not be reusable for another, such as marketing.
- Data minimisation. Collect and keep only the fields your segments use.
- Revocability. A customer can withdraw consent, and your systems must honour that quickly.
Where consent enters the pipeline
Consent is checked at three points. Check it when data is collected, when features are built, and when content is activated. A customer might allow analytics but refuse email marketing. Both facts must be stored per purpose and per channel, not as one yes/no flag.
Worked example: filtering by consent
Suppose each customer has one row per purpose in a consent table. The code below keeps only customers who agreed to profiling before any segmentation runs. It uses the most recent decision, so a withdrawal overrides an earlier grant.
import pandas as pd
consent = pd.DataFrame({
"customer_id": [1, 1, 2, 3],
"purpose": ["profiling", "profiling", "profiling", "email"],
"granted": [True, False, True, True],
"updated_at": pd.to_datetime(
["2026-01-05", "2026-09-10", "2026-03-01", "2026-02-02"]
),
})
latest = (
consent[consent["purpose"] == "profiling"]
.sort_values("updated_at")
.groupby("customer_id")
.tail(1)
)
allowed_ids = set(latest.loc[latest["granted"], "customer_id"])
print(sorted(allowed_ids))This prints [2]. Customer 1 withdrew consent in September, so they are excluded. Customer 3 never answered the profiling question, so they are excluded too. Treating a missing record as "no" is the safe default.
Design choices that reduce risk
- Pseudonymise identifiers. Replace emails with internal IDs in analysis tables. Keep the lookup table under tighter access.
- Avoid sensitive attributes. Health, religion, and similar categories carry stricter rules. Proxies for them, such as certain product purchases, can cause the same problem.
- Set retention limits. Delete or aggregate raw events after a fixed period.
- Log decisions. Store which consent version applied when a segment was assigned, so you can audit it later.
Common errors
| Error | Consequence | Fix |
|---|---|---|
| One global "opt-in" flag | Email consent is wrongly used for ad targeting | Store consent per purpose and channel |
| Checking consent only at send time | Profiles are still built from data without permission | Filter before feature building too |
| Slow propagation of withdrawals | Customers receive content after opting out | Sync consent changes to all systems on a short schedule |
| Treating missing consent as yes | Unlawful processing | Default to no |
Exercise
A customer agreed to email marketing but never answered a question about profiling. Should they be included in a clustering run that uses their purchase history? Explain why.
Show answer
No. Consent is per purpose, and there is no recorded permission for profiling. Missing consent is treated as "no". They can still receive non-personalised email, because they agreed to that channel.