Knowing which ads sell policies, not just clicks
A policy isn't really sold when the customer pays — it's sold minutes later, when it's actually issued, long after the browser has closed. Our marketing numbers never saw that step, so I built the part that reports it back.
An insurance policy isn't sold at the moment someone pays for it. The payment goes through, checks run, the policy gets registered with the state — and only then does the customer own anything. Sometimes that's a minute later. Sometimes it fails.
Our marketing analytics never saw that last step. Analytics tools only watch what happens inside the browser, and by the time a policy is genuinely issued the browser is long gone. So the team was buying ads against a number that wasn't quite real.
The sale that happens after the browser closes
Everything that matters commercially happens after the visit ends:
- A payment can succeed while the policy is never issued, because a check fails further down the line.
- The sum finally charged isn't always the sum shown on the quote.
- Policies sold through the call centre, the mobile app or partners were mixed in with website sales, which quietly flattered the website's numbers.
So the ad budget was being spent against "people who reached the payment page" — a figure that looks like sales and isn't.
Watching for the one moment that counts
The fix has two halves. When someone begins a purchase on the website, we store the anonymous visitor ID that their analytics cookie already carries, attached to that one contract. No names, nothing personal — just a link between "this browser" and "this purchase".
Then the system watches for issuance itself. This was the delicate part: "paid" and "issued" are not the same event, and only the second one is a sale. Every product records it slightly differently, so I found the single write that happens only at real issuance — for motor liability, the status flipping to issued; for everything else, the state registration number being filled in for the first time — and listened for exactly that, across eleven products, from one place.
Two rules made it safe to run:
- Analytics must never break a sale. The whole thing is wrapped so that if it fails, the failure is logged and the purchase carries on untouched. Issuing a policy is money. Measuring it is not.
- No stored ID means no report. A policy sold over the phone never had a browser, so there's no visitor ID to find and it's skipped in silence. That lookup is the filter — website sales report themselves and nothing else gets in.
Sending it back, safely
Every few minutes a scheduled job collects everything newly issued and uploads it to the analytics service in batches, stamped with the real amount paid. That's the whole idea of an "offline conversion": telling the tool after the fact that a visitor from earlier became a paying customer.
The upload format allows one label per row and has no column for the product, so each sale is reported twice — once into a total bucket and once into a per-product one — which is what lets the team compare motor cover against travel cover. Rows are marked as sent only after the service confirms it accepted them, so a failed upload just retries on the next run. Nothing is double-counted, nothing is lost.
Why I'm proud of it
Not one payment service or product was modified. The whole feature hangs off a single listener and a scheduled job, so the code that handles people's money stayed exactly as it was — which is the only acceptable way to bolt measurement onto a system like that.
And the outcome is a plain business one. The team can now see which ads produce policies people actually own, broken down by product, with the real sum paid, instead of counting clicks and hoping.