How to track leads in Ruby on Rails
A lead is a claim about intent, and claims need validation. Half of all form submissions in paid-traffic funnels are bot noise, typo emails, or duplicates — and each one that gets attributed inflates a campaign's apparent performance.
Client event (fast, blockable) + server event (authoritative) → collapsed on the submission id
Send it twice, on purpose. The client event tells you what the person did and when; the server event confirms it happened and carries the context the browser never had. A shared the submission id collapses the two into one record marked confirmed by both sides.
Never send only the client event for anything with money attached — ad blockers see roughly 20–30% of paid-traffic sessions.
The server-side event
This is the one that has to be right. It runs on your infrastructure, so no ad blocker, browser policy or network condition can stop it.
# app/controllers/leads_controller.rb
def create
return head :ok if params[:company].present? # honeypot
lead = Lead.capture(email: params[:email], source: params[:source])
return render_error unless lead.persisted?
signals_identify(params[:email], via: "join_waiting_list")
signals_track_event("lead_captured", { "source" => params[:source] })
end
What goes wrong
Three mistakes account for nearly every broken leads implementation we see.
Counting the form render or focus as a lead instead of the confirmed submission.
No bot filtering, so a scraper's submissions get credited to whichever campaign it landed from.
Losing the campaign context because the form is in a third-party iframe that cannot see your visitor id.
Frequently asked questions
Should I track leads client-side or server-side?
Both. The client event captures behaviour in real time and is cheap; the server event is authoritative and cannot be blocked. Give them a shared de-duplication key (the submission id) and they collapse into one confirmed record instead of double counting.
What is the de-duplication key for leads in Ruby on Rails?
The submission id — a value both sides already know. That is the whole requirement: the browser and your backend must be able to derive the same string independently.
What goes wrong most often?
Counting the form render or focus as a lead instead of the confirmed submission.
Why does the server event matter more here?
A lead is a claim about intent, and claims need validation. Half of all form submissions in paid-traffic funnels are bot noise, typo emails, or duplicates — and each one that gets attributed inflates a campaign's apparent performance.
Related guides
See the receipt for every conversion.
Flowsk Signals stitches the anonymous click to the email to the purchase — first-party, server-side, de-duplicated on a key you choose. One snippet, $29/mo, and a journey you can inspect event by event.
More free tools
Same deal — instant, no signup.