Capture UTM params and attribute on signup
attribution plumbing across an anonymous-to-known transition.
parse UTMs on landing, persist them in a cookie tied to an anonymous ID, then stamp them onto the account at signup.
What's really being asked
This probes attribution mechanics across the anonymous-to-authenticated boundary, where the data exists at landing but the account does not yet exist.
The full answer
On landing, read the UTM parameters from the URL query string. Persist them, because the user may browse and sign up days later when the URL no longer carries them. Store in a first-party cookie or local storage tied to a generated anonymous id, and decide a policy: first-touch keeps the original campaign and only sets if empty, last-touch overwrites. Also capture landing page and timestamp. At signup, read the stored attribution and write it onto the new account record, and emit a signup event carrying both the anonymous id and the new user id so the analytics layer stitches the pre-signup history to the account. Respect consent before setting cookies.
The mistakes people make
Trying to grab UTMs at the signup request, when they are long gone from the URL. Relying on document.referrer, which is frequently empty, stripped, or spoofed. Storing only in memory so a refresh loses them. No identity stitch, so the anonymous journey never connects to the account.
What usually comes next
First-touch versus last-touch, and when each is appropriate? How do you handle a user landing multiple times from different campaigns? How does consent and privacy regulation constrain cookie storage?
A concrete example
A visitor lands via a link with utm_source equals google and utm_campaign equals summer_sale. The client parses these, stores them in a first-party cookie under anonymous id anon_55 with a first-touch policy, and tags subsequent events. Three days later they sign up; the backend copies summer_sale onto the new account and emits a signup event with both anon_55 and the new user id, attributing the conversion to the summer_sale campaign.
Interview question
Why must UTM parameters be persisted on landing rather than read at signup time?
- a.Signup forms strip query parameters for security reasons
- b.The referrer header always carries the UTMs to signup
- c.UTM parameters are only valid for a single HTTP request by spec
- d.The user may sign up later from a URL that no longer contains the parametersCorrect
Why? this is the answer
Attribution data lives in the landing URL; by signup the user has navigated away, so it must be stored client-side first. The referrer is unreliable and does not preserve UTMs.
Just read this? Test yourself on what you have been reading.
- #attribution
- #utm
- #marketing-analytics
- #identity-stitching
- #cookies
Put your scrolling time to good use
Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.
See open roles