Ranks USA Marketing Agency
Menu

How to capture the lead source in your forms

To capture lead source in forms: on a visitor's first page view, store the referrer, landing page and any UTM tags in a first-party cookie, and keep that first value on later visits; add hidden fields to every form for first source and last source; fill them from the cookie when the form is sent; do the same for call taps and booking links; and ask "how did you hear about us?" as a visible field. Test it with tagged links in a private window.

Step by step

  1. 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.
  2. Keep the first: on later visits, do not overwrite the first touch; update a separate last touch.
  3. 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.
  4. Hidden fields: every form gets fields for first source, last source and landing page, filled when the form is sent.
  5. Visible question: "How did you hear about us?" with a short list.
  6. Calls and bookings: send the same source with call-tap events and booking links.
  7. 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.

Where this leads

Ranks USA: Lead tracking. Plans from $3,900 a month; or start with the $500 audit.

Questions owners ask

What are hidden fields in a form?

Fields the visitor does not see, filled by a script with data like the source, sent with the form.

Should I capture first touch or last touch?

Both. First touch shows what found the buyer; last touch helps ad platforms.

How do I record ChatGPT as a source?

Read the referrer (chatgpt.com) or the utm_source tag on the first visit and store it; label it as an AI assistant.

Order the Growth Audit, $500

About 300 of your customers' questions asked 3 times, a 9-point Google Maps grid, your Google competitors and a 90-day plan, in 2 business days.