Step by step
- First visit: a small script reads document.referrer, the landing URL and UTM tags (and ad click IDs), and stores them in a first-party cookie.
- Keep the first: on later visits, do not overwrite the first touch; update a separate last touch.
- Classify: turn the raw referrer into a channel: ChatGPT and other assistants, Google search, Google Maps (via the profile's tagged link), ads, social, referral, direct.
- Hidden fields: every form gets fields for first source, last source and landing page, filled when the form is sent.
- Visible question: "How did you hear about us?" with a short list.
- Calls and bookings: send the same source with call-tap events and booking links.
- Store: the lead record in your CRM or sheet keeps the fields.
Classification examples
| Referrer or tag | Channel |
|---|---|
| chatgpt.com, utm_source=chatgpt.com | ChatGPT |
| perplexity.ai | Perplexity |
| google.com, no tags | Google search |
| utm_campaign=gbp | Google Business Profile |
| gclid present | Google Ads |
| instagram.com | Social |
| none | Direct |
Test it
Open a private window, visit with ?utm_source=test&utm_medium=check, browse, send a form, and confirm the lead shows the source. Check monthly; a report of leads with an empty source is a known-false control that should stay near zero.
Privacy
Use a first-party cookie, describe it in your privacy policy, and follow consent rules where they apply.
Every Ranks USA site does this through one shared tracker; our lead tracking service adds it to yours.