Sub topic 8
Writing the sunset policy
This chapter assumes you know basic email marketing terms (list, campaign, bounce, unsubscribe) and can read simple SQL and Python. It also assumes you have already chosen a definition of engagement and an inactivity window. Here you turn those choices into a written policy that your team and your tooling can both follow.
Why write the policy down
A sunset policy is a short document that states who gets removed from active sending, when, and how. Without one, each marketer decides case by case. Decisions drift, exceptions pile up, and nobody can explain later why an address stopped receiving mail.
A good policy has four parts:
- Definitions. What counts as engagement, and which window applies.
- Stages. The steps a subscriber moves through, with the time limits for each.
- Exceptions. Who is exempt, and who approves that.
- Records. What you log and how long you keep it.
Define the stages
Keep the flow small. Four stages cover most senders:
| Stage | Meaning | What happens |
|---|---|---|
| active | Engaged inside the window | Normal sending |
| send_reengagement | Window passed, no attempt yet | Send the re-engagement message |
| waiting | Attempt sent, grace period still running | Pause regular campaigns, watch for clicks |
| suppress | Grace period ended with no response | Stop all marketing mail |
Note that the only way back from suppress is a new, deliberate opt-in. A late click on an old email is not enough, because your policy has already stopped sending to that person.
Turn thresholds into numbers
The policy must name exact values. Vague wording such as "inactive for a while" cannot be automated or audited. For a weekly sender, a reasonable starting point is a 180-day window and a 30-day grace period. A daily sender may choose a shorter window, and a quarterly sender a much longer one.
The function below encodes those stages. It uses the last click or purchase if one exists, and falls back to the signup date for people who never engaged.
from datetime import datetime, timedelta
def sunset_stage(
subscribed_at: datetime,
last_engaged_at: datetime | None,
reengagement_sent_at: datetime | None,
now: datetime,
window_days: int = 180,
grace_days: int = 30,
) -> str:
reference = last_engaged_at or subscribed_at
if now - reference < timedelta(days=window_days):
return "active"
if reengagement_sent_at is None:
return "send_reengagement"
if now - reengagement_sent_at < timedelta(days=grace_days):
return "waiting"
return "suppress"Because window_days and grace_days are parameters, the document and the code can share the same two numbers.
Find the candidates
The query below lists subscribed addresses that joined more than 180 days ago and have no click or purchase in that period. It counts clicks and purchases, not opens, because open data is unreliable.
SELECT s.id,
s.email,
MAX(e.occurred_at) AS last_engaged_at
FROM subscribers s
LEFT JOIN engagement_events e
ON e.subscriber_id = s.id
AND e.event_type IN ('click', 'purchase')
WHERE s.status = 'subscribed'
AND s.subscribed_at < now() - interval '180 days'
GROUP BY s.id, s.email
HAVING MAX(e.occurred_at) IS NULL
OR MAX(e.occurred_at) < now() - interval '180 days';The s.subscribed_at filter protects new subscribers. The LEFT JOIN keeps people with no events at all, and the HAVING clause then selects them.
Common errors
- Counting opens as engagement. Privacy features that prefetch images can record opens that no person made. Someone may then look active when they are not.
- Resetting the clock on every send. Measure from the last engagement, not the last message.
- Skipping the grace period. Without it, a subscriber who was simply away gets no chance to respond.
- Letting a policy and its code disagree. If the document says 180 days and the job runs at 120, the document is wrong in practice.
Policy checklist
Before you publish the policy, confirm that it states the engagement signals, the window, the grace period, the re-engagement success criterion, the exception owners, and the record-keeping rules. Give it a version number and a review date so changes are traceable.
Exercise
A subscriber joined 200 days ago, has never clicked, and received a re-engagement email 10 days ago. With a 180-day window and a 30-day grace period, what does sunset_stage return, and why?
Show answer
It returns "waiting". The reference date is the signup date (200 days ago), which is past the 180-day window, so the subscriber is not active. A re-engagement message was already sent, and 10 days is less than the 30-day grace period, so the subscriber stays in the waiting stage until the grace period ends.
Exercise
Why should the only route from the suppress stage back to active be a fresh opt-in rather than any later click?
Show answer
A suppressed address no longer receives marketing mail, so a later click usually comes from an old message or an automated scanner rather than a clear choice to resume. A fresh opt-in is an explicit signal that the person wants the mail, and it gives you a record of that consent.