Skip to content
All writing

73% of my gym's conversions said they came from nowhere

I run ads for Persistence Athletics, and for months the analytics had been quietly useless. People were signing up. Money was landing. But about 73% of the conversions in GA4 came in as "(not set)", filed under Unassigned, with no campaign and no source attached. I was paying for clicks I could not connect to the sign-ups they earned. This week I found out why, and the reason is a trap any business that charges through Stripe can fall into.

The conversions do not happen in the browser. A trial booking, a drop-in, a membership: the intent happens on the site, but the actual charge settles server-side on Stripe, sometimes minutes later, sometimes days. My server was already reporting those conversions to GA4 through the Measurement Protocol. It was just reporting them as a stranger. It sent a synthetic client id, no session id, and no gclid, so GA4 had nothing to stitch the conversion back to the real browser session that started it. Every sale arrived as an orphan.

old: the server fires the conversion with a made-up client id and no session, so GA4 cannot tie the sale to the click that earned it.
new: the browser's real client id, session id, and gclid ride all the way to the Stripe charge, so the conversion lands on the campaign that paid for it.

Carry the identity to where the money lands

The fix starts in the browser, at the moment of intent. I capture the real GA4 client id, the session id, and the gclid, the Google click identifier that ties a visit to a specific ad, and I thread all three through the rest of the flow. The trial-booking endpoint now accepts them and attaches them to the lead event. The drop-in and membership checkout endpoints write them into the Stripe Checkout Session metadata, and the Stripe webhook reads them back out and attaches them to the purchase event. The session id is the one that matters most: it is the key GA4 uses to reconnect a server-side event to the real session and its source. The real client id is used whenever it is present, and the synthetic one is only ever a last-resort fallback.

Memberships charge later, so the conversion is the first charge

Memberships had a second wrinkle that the lead and drop-in paths did not. Membership checkout is setup-mode: the card gets vaulted at signup and the first real charge happens later, on the nightly billing cron, not at checkout. So the webhook's purchase block, which only fires when an amount is actually charged, never ran for a membership. The conversion I actually want to count is the first successful charge.

So the membership path persists those three attribution ids onto the Stripe customer at signup. Then, when an invoice.paid event arrives for a membership invoice and that customer is carrying the ids, the purchase fires there, with the value set to the invoice subtotal plus tax and the transaction id set to the invoice id. The conversion finally lands on the day the money does, attached to the campaign that earned it.

The dedup bug an adversarial review caught

A membership renews every month, and every renewal is a new invoice with a new id. GA4 will not dedupe those for me, so if I re-fired the purchase on every renewal I would be inventing a fresh conversion out of thin air every single month. The first version handled this by clearing the customer's attribution ids right after the first fire, so a renewal would find nothing to fire with.

An adversarial review found the hole. That clear was best-effort, and if it failed, the next renewal would re-fire a phantom conversion. So I hardened it: I set a durable ga4_membership_fired flag on the customer, clear the ids in the same write, and await that write before firing the event. If the mark fails, I skip the fire entirely. Stripe will redeliver the event and I retry, so a failed cleanup can never turn into a duplicate. Renewals see the flag and skip. The transaction id, still set to the invoice id, backstops the case where Stripe redelivers the same invoice. I also capped the gclid at 100 characters, the GA4 event-param limit, so an oversized click id cannot get the whole event rejected.

What I learned

Client-side conversion tracking lies when the conversion is server-side. The browser saw the intent. The charge settled on Stripe later, in a place the browser tag never reaches. The only fix is to carry the browser's identity, the client id, session id, and gclid, all the way down to where the charge actually happens, and fire from there.

If you charge later, the conversion is the charge, not the signup. Setup-mode subscriptions vault the card now and bill later. Firing the purchase at checkout reports a sale that has not happened. Persist the attribution on the customer and fire it at invoice.paid, when the money is real.

A best-effort cleanup is not deduplication. An event you can only send once needs a durable mark set before you send it, and you have to wait for that mark to land. If the thing that prevents a duplicate is allowed to fail silently, the duplicate is not a possibility, it is a certainty on a long enough timeline.

If your business is taking money it cannot trace back to the work that earned it, that is the kind of plumbing Autosterea builds.

First published on ravikantdewangan.com.

Tell us what eats your week.

A free 20-minute call. We'll show you what we would take off your plate.

Book a call