The problem
A visitor lands on /?utm_source=newsletter&utm_campaign=march, reads for a while and pays on /checkout. By then the tags are gone from the URL.
Doing it yourself
Save the tags on landing, pass them into the session’s metadata, and read them in your webhook. You’ll also need to handle renewals, refunds and visitors who return days later without tags.
const tags = Object.fromEntries(
[...new URLSearchParams(location.search)].filter(([key]) => key.startsWith('utm_')),
);
sessionStorage.setItem('tags', JSON.stringify(tags));
With DataPenny
You don’t pass the tags at all. The script records them on the visit, and only the visitor id goes through checkout. When the payment arrives, DataPenny finds the visit, and the tags come with it. The credit follows your attribution model, so a buyer’s earlier campaign isn’t lost when they come back typing your address.
Set up the id with the Stripe guide.