The project
One view of every forecourt customer
The goal was simple to say and hard to do: take three transaction systems that were never designed to talk to each other, and join them into one record per customer, across the UK, Germany and Poland. I brought in the raw data, built the common data model, and wrote the matching models that make the links.
The starting point: one purchase, three records
A single visit could show up in the till system (what was bought), the payment system (how it was paid) and the loyalty system (who bought it, but only if they swiped). Each system had its own IDs, its own clocks and its own idea of a transaction.
- Records / month
- 2.4M baskets
- Knows
- items, value, site
- Records / month
- 1.9M card payments
- Knows
- card token, amount
- Records / month
- 0.7M swipes
- Knows
- member, points
Loyalty only ever covered a minority of spend. Everyone who paid by card but never swiped a loyalty card was, in effect, invisible.
The method: narrow, score, link
There was no list of known matches to train against, so this was an unsupervised problem. I narrowed the search first: a till record could only match a payment from the same site, date, country and basket type. Within that small window, I scored each candidate pair on how closely their time, value and quantity agreed, and kept the best one.
View data
| Item | Exact-key match | Confidence-scored match | Total |
|---|---|---|---|
| EPOS ↔ Payment | 58% | 24% | 82% |
| EPOS ↔ Loyalty | 71% | 17% | 88% |
| Payment ↔ Loyalty | 44% | 21% | 65% |
Exact keys did most of the work, but the scored matches added roughly a fifth more coverage on every pair. That's the slice a simple join would have thrown away.
How sure is each match?
At a busy site, two or three baskets of a similar value can land in the same minute. So every link carries a confidence score: the similarity of the pair, scaled down by how many other candidates were nearly as close. Only links above a threshold are kept.
View data
| Coverage | |
|---|---|
| 0.5 | 84.1% |
| 0.55 | 83.8% |
| 0.6 | 83.5% |
| 0.65 | 83.0% |
| 0.7 | 82.2% |
| 0.75 | 80.4% |
| 0.8 | 76.5% |
| 0.85 | 70.3% |
| 0.9 | 61.0% |
| 0.95 | 44.2% |
Most real matches score very high, so coverage barely moves until the threshold passes 0.7, then falls away fast. That knee is where we set it: strict enough to trust, loose enough to keep almost everything worth keeping.
When two baskets look the same
The dampening step matters most in exactly the cases a join gets wrong. Here, two till records compete for the same card payment:
| Pair | Similarity | Competing with | Confidence | Decision |
|---|---|---|---|---|
| E1 ↔ P1 | 0.85 | none | 0.85 | ✓ Linked |
| E2 ↔ P2 | 0.94 | E3 | 0.61 | ! Linked, flagged |
| E3 ↔ P2 | 0.52 | E2 | 0.19 | ✕ Rejected |
E2 still wins, but its confidence drops from 0.94 to 0.61 because E3 was a plausible rival. Reporting can then treat contested links differently from clean ones, instead of pretending every match is equally certain.
Who we could suddenly see
Once the links were in place, linked transactions rolled up into one record per customer, including the people loyalty data had never captured.
View data
| Item | Value |
|---|---|
| Engaged loyalty | 310k |
| Semi-engaged | 420k |
| Unengaged loyalty | 560k |
| Card-only | 1,840k |
| Fleet | 95k |
The largest group by far was customers who paid by card but never swiped loyalty. They had been shopping with bp all along; the business just couldn't see them.
What I handed over
Results