Sub topic 9
Exceptions: new subscribers, transactional mail, and seasonal senders
This chapter assumes you can read basic SQL and Python, and that you know the earlier steps in this tutorial. You have defined engagement, chosen an inactivity window, and written the core sunset rules. A rule that treats every address the same will make mistakes. This chapter covers three groups that need special handling: new subscribers, transactional recipients, and seasonal buyers.
Why exceptions belong in the policy
A sunset policy asks one question: has this person engaged within the window? That question is unfair to some people. A subscriber who joined last week has had no time to engage. A customer who only gets receipts is not a marketing recipient at all. A buyer who purchases once a year looks inactive for eleven months.
Write each exception into the policy as a named rule with a reason. Unwritten exceptions get applied inconsistently, and no one can audit them later.
New subscribers
A new subscriber has no engagement history, so "no click in 180 days" is true by default. The query from the earlier chapter handles this with s.subscribed_at < now() - interval '180 days'. That condition is the new-subscriber exception. It keeps recent sign-ups out of the candidate list.
The Python function does the same thing differently. It falls back to subscribed_at when last_engaged_at is empty:
reference = last_engaged_at or subscribed_atBoth approaches give a new subscriber a full window before any action. Check that your own pipeline does this too. A common bug is a join that returns no engagement rows and a filter that reads "no rows" as "never engaged."
Consider a longer grace period for subscribers who joined through a single event, such as a webinar. They may wait for the next event before they click anything.
Transactional mail
Transactional mail is sent because of something the recipient did, such as a receipt, a password reset, or a shipping notice. These messages are expected and are usually opened or acted on.
Keep the two streams separate in your sunset logic:
- Marketing suppression stops promotional messages only.
- Transactional messages continue to a customer with an active account, even if they have not clicked a marketing email in a year.
- If a transactional address bounces, treat it as a bad address in both streams.
Do not count transactional engagement as marketing engagement. A password-reset click proves the address works. It does not show interest in your newsletter. Doing so will keep dead marketing contacts on the list. Do the reverse check as well. A suppressed marketing contact should not be blocked from receipts.
Seasonal senders
Some senders mail heavily at certain times: holiday retail, tax services, school supplies, event tickets. Their subscribers may engage once a year. A 180-day window would suppress many of them just before their peak season.
There are two ways to handle this:
- Lengthen the window to cover a full cycle, for example 400 days for an annual buyer.
- Pause the clock during the off-season, and count only the months when you actually send.
The first is simpler to implement. The second is more precise, but it needs a record of which periods count. The Python function below adds a per-segment window:
from datetime import datetime, timedelta
SEGMENT_WINDOWS = {
"default": 180,
"annual_buyer": 400,
"event_attendee": 365,
}
def window_for(segment: str) -> timedelta:
return timedelta(days=SEGMENT_WINDOWS.get(segment, SEGMENT_WINDOWS["default"]))
def is_inactive(
segment: str,
subscribed_at: datetime,
last_engaged_at: datetime | None,
now: datetime,
) -> bool:
reference = last_engaged_at or subscribed_at
return now - reference >= window_for(segment)You can pass the result of window_for into sunset_stage by converting it to days. Store the segment on the subscriber record so the rule is visible in the data.
Keeping exceptions under control
Exceptions can grow until they swallow the policy. Limit them with these checks:
- Each exception has an owner, a written reason, and a review date.
- Count how many subscribers each exception covers. If the total grows past a share you can defend, review the rules.
- Exceptions must not permanently shield addresses that bounce or hit spam traps. Bounce and trap handling comes first.
Summary
New subscribers get a full window. Transactional mail runs in its own stream. Seasonal segments get a window that matches their buying cycle. Write each exception down, give it an owner, and check it after the bounce rules.
Exercise
A customer buys a gift once each December and has not clicked any email since last December. Today is October 20. Your default window is 180 days. What happens under the default rule, and what change fixes it?
Show answer
Under the default rule the customer has been silent for about 320 days, so they enter re-engagement and are likely suppressed, just before their next likely purchase. Give the segment a longer window, such as 400 days (the "annual_buyer" segment), or pause the clock outside the selling season.
Exercise
A subscriber clicked a password-reset link yesterday but has not clicked any marketing email in 300 days. Should that click count as marketing engagement?
Show answer
No. The click shows the address works, but not interest in marketing mail. Keep sending transactional mail, and let the subscriber go through the normal sunset flow for marketing.