Writing · Marketing systems
Keeping lead lists clean
Lead lists have two cleanliness problems that get confused. The same person arrives twice, and some people must never be contacted at all. Both come down to keeping the decision and not the data.
A lead list has two cleanliness problems, and they are often treated as one.
The first is that the same person arrives twice. They fill in the form, wait, wonder if it worked, and fill it in again with a capital letter in their email address. If you pay per lead you have now paid twice. If you sell leads, your buyer has.
The second is that some people must never be on the list. They unsubscribed, or complained, or are a partner’s existing customer. Contacting one of them breaks a promise, and it can be a legal problem.
The first is deduplication and the second is suppression. They feel similar because both ask “is this address already known”. They differ in what you are allowed to keep.
Duplicates: the hard part is the question afterward
Removing duplicates from a list is one line in most languages. The hard part comes later, when someone asks about one record.
Say a partner writes in: we sent you lead 812 and you did not pay for it. Why?
If all you did was drop the duplicates, your answer is “it was a duplicate, trust me”. The better answer is that 812 had the same email as lead 640, which arrived 42 minutes earlier. You can only give it if you wrote it down at the time.
So the package I wrote for this returns two things: the records that survive, and one entry for every record that did not, naming the record it lost to and why.
use Keaton\Dedupe\Deduper;
use Keaton\Dedupe\Normalizers\EmailCanonical;
$signups = [
['id' => 1, 'email' => 'jane@example.com', 'created_at' => '2026-11-05 09:00:00'],
['id' => 2, 'email' => 'jane@example.com', 'created_at' => '2026-11-05 09:42:00'],
['id' => 3, 'email' => 'jane@example.com', 'created_at' => '2026-11-07 10:15:00'],
];
$result = Deduper::make()
->key('email', new EmailCanonical)
->timestamp('created_at')
->window(86_400) // 24 hours, in seconds
->run($signups);
echo implode(', ', array_column($result->survivors, 'id')), PHP_EOL;
foreach ($result->audit as $entry) {
$minutes = intdiv($entry->secondsApart, 60);
echo "dropped {$entry->droppedId}: same {$entry->matchedKey} as {$entry->survivorId}, {$minutes} minutes apart", PHP_EOL;
}
1, 3
dropped 2: same email as 1, 42 minutes apart
Two details in there carry most of the weight.
The normalizer. “Same email” is not string equality. EmailCanonical lowercases the address and strips a +tag, and for Gmail it ignores dots and folds the older googlemail.com domain, so Jane.Doe+news@GMAIL.com and janedoe@gmail.com are one person. A phone normalizer does the same job: PhoneDigits(10) reduces both +1 (512) 555-0100 and 5125550100 to the same ten digits. Which normalizer you pick is a business decision, so the code names it.
The window. The same email twice in an hour is one person clicking twice. The same email a week apart may be someone coming back. Record 3 above has the same address and arrives two days later, so it is kept. Without a window, a person who signed up last year can never sign up again.
Keep the decision, not the data
When you record why a lead was dropped, the tempting thing is to store the dropped lead. Then you hold a second copy of personal data whose only purpose is to explain why you threw the first away.
The audit entry stores less: the ids of the two records, the name of the key that matched, how far apart they were, and a hash of the dropped record. The matched value itself is not stored unless you ask for it.
In a Laravel app the entries go to a table and can be read back by run or by record:
Dedupe::run($leads, 'signups-2026-11-05');
// months later, when the partner asks
$entry = Dedupe::auditFor(812)[0];
$entry->survivorId; // '640'
$entry->matchedKey; // 'email'
$entry->secondsApart; // 2520
The hash is there for the dispute. If the partner sends you the record they say you dropped, you can hash it and show that it is the one in your entry. You have proved which record it was without having kept it.
Suppression: do not store the address at all
The second problem has a stricter version of the same rule.
A do-not-contact list is a list of people who asked you to forget them. Keeping their addresses in plain text so that you can avoid them is an odd way to honor that. It gets worse when the list is a partner’s. They are often not allowed to hand you their customers’ addresses, and you would not want to be holding them.
The usual answer is to trade hashes. Each side normalizes the address, hashes it, and shares only the hash. You can ask “is this person on the list” without either side seeing the other’s addresses.
use Keaton\HashList\Facades\HashList;
HashList::add('jane@example.com');
// A partner sent you this: the sha256 of an address you have never seen.
HashList::addHash('CD25A6171969F2A3C6E35C7667E3908EF1BD2424241DB04411A0EEC454CA6C16');
foreach (['Jane@Example.com', 'Jane Doe <jane@example.com>', 'Sam@Example.com', 'riley@example.com'] as $email) {
printf("%-30s %s\n", "'{$email}'", HashList::has($email) ? 'skip' : 'send');
}
'Jane@Example.com' skip
'Jane Doe <jane@example.com>' skip
'Sam@Example.com' skip
'riley@example.com' send
Sam is skipped because of the partner’s hash. You never learned Sam’s address from the partner. You only learned that when Sam turns up, you should not send.
The details that matter here are dull ones. Every spelling of an address has to normalize to the same hash, or the list leaks. The table has no column for an address, so nothing can write one by accident. A check is one indexed query, not a list loaded into memory. And a broken import file should be rejected whole, with the previous entries left in place. The strict import run inside a transaction does that. Left to its defaults, an import keeps the good lines and counts the bad ones. A half-imported suppression list is worse than yesterday’s.
Where each one belongs
Deduplication belongs at intake, at the moment you decide whether to accept and pay for a record. It needs a window and a record of the decision.
Suppression belongs as late as possible, immediately before the send. A person can unsubscribe between the day they entered your list and the day you email them. The package has a send-time guard that removes listed recipients from every outgoing message. It is off until you switch it on, because a library that silently drops mail is not something to discover in production.
One caution: a suppression file is only a promise. Handing a list over is not the same as knowing it was applied. The way to know is to check what comes back against the file that went out.
The packages
Both are small, open-source Laravel packages, and both install with Composer. The pages for Laravel Dedupe and Laravel Hash List have the details.
If you only need to block a few addresses you already hold in plain text, a table with a unique index is simpler than either. I would rather say that than have you install something you do not need.