Lead Capture
Save everyone who gives you their email address on your site as a person in Quotient, along with the marketing that brought them in
There are many ways to capture leads on your site. Any time someone gives you their email address in exchange for something, you have a chance to capture a lead.
That "something" is called a lead magnet, and it can take many forms: a webinar registration, a newsletter subscription, a product signup, a demo with a salesperson, a whitepaper download, and more.
Capturing a lead in Quotient means three things happen when someone fills in your form:
- They're saved as a person in your audience, so you can email them and add them to flows.
- Quotient records which campaign, post, or ad brought them to the page, so you can see which channels produce leads.
- Their later visits to your site are tied to them, so you can tell an engaged lead from one who never came back.
This guide walks through the setup using one example: a pricing calculator that emails a report to anyone who asks for one. The same steps apply to any lead magnet with a form.
The setup involves a few lines of code on your page. If you build your site with a coding agent such as Claude Code, give it the link to this page and ask it to connect your form to Quotient. The page is written so an agent can follow it from top to bottom.
Before You Start
You need two things in Quotient before touching your page.
First, create a public API key in
Settings → Developers. Give it
the Analytics: write permission and the permission to create and update
people (AUDIENCE_PERSON_WRITE), and add your site's domain to its allowed
origins. The key should begin with pk_.
Second, create a custom event for each step of your lead magnet in Analytics → Custom Events. For the calculator, that's three events:
| Display Name | Event ID | When it happens |
|---|---|---|
| Calculator Started | calculator_started | The visitor enters their first value |
| Calculator Completed | calculator_completed | The visitor sees their result |
| Calculator Report Requested | calculator_report_requested | The visitor submits the email form |
It also helps to create a list for these leads on the
People page, such as "Pricing Calculator
Leads." This is optional, but a list keeps the leads from each lead magnet easy
to find later. If you do use one, create it before your form adds anyone to it.
Your code refers to the list by its slug, which here is
pricing-calculator-leads.
You can also ask Quotient to create the events and the list for you.
Step 1: Add the Tracking Tag
The tracking tag is one script on your page. It records page views, reads the
tags on the link the visitor arrived through, and gives you the client that
the next two steps use.
<script src="https://unpkg.com/@quotientjs/client@0.6.2/dist/quotient.browser.js"></script>
<script>
const client = Quotient.QuotientClient.init({
apiKey: "pk_replace_with_your_public_key",
});
</script>
If your site runs on Webflow, WordPress, Framer, Wix, or a JavaScript framework, follow the matching guide in On-Site Tracking instead.
Step 2: Save the Lead
When the visitor submits your form, call client.audience.people.identify()
with their email address and whatever else the form collected. Leave out lists
if you didn't create a list.
async function handleReportRequest(formData) {
try {
await client.audience.people.identify({
emailAddress: formData.email,
firstName: formData.firstName,
lastName: formData.lastName,
lists: ["pricing-calculator-leads"],
});
} catch (error) {
console.error("Failed to save lead", error);
showSubmissionError();
return;
}
showSuccess();
void client.analytics.event({
eventType: "custom",
customEventId: "calculator_report_requested",
});
}
That one call does the three things described at the top of this page. It creates the person (or updates them if they already exist), records where they came from, and remembers them in the browser so their later activity is attributed to them.
Run this code in the browser, not on your server. The tracking tag can only remember the visitor if the call happens on their device. If your signup has to finish on the server, see Server-Side Conversions.
Quotient calls this identifying a visitor. Identifying Users explains the idea in more depth, including how it works for logins and newsletter forms.
Step 3: Record an Event at Each Step
Most people who start a lead magnet don't finish it. Recording an event at each step shows you where they drop off, which tells you what to fix.
Send each event when its step is complete:
function handleFirstInput() {
void client.analytics.event({
eventType: "custom",
customEventId: "calculator_started",
});
}
function handleResultShown() {
void client.analytics.event({
eventType: "custom",
customEventId: "calculator_completed",
});
}
The first two events happen before you know who the visitor is, and that's fine. Quotient still ties them to the visit and to the marketing that brought the visitor in.
The last event, calculator_report_requested, is the one in Step 2. Send it
only after identify() has finished, as the example there does, so the event
belongs to the new person.
Step 4: Send the Lead Magnet Automatically
The visitor kept their side of the trade, so the report should reach them without anyone on your team sending it. A flow does this.
Ask Quotient to build it:
Create a flow that starts when someone does Calculator Report Requested and sends them the pricing report email.
The flow uses an Analytics Event trigger set to your signup event and a Send Email step. From there you can add delays and more emails to keep new leads engaged.
A Note on Consent
identify() saves the person but doesn't subscribe them to your email. They
start as Not Subscribed, which means they can receive your email unless double
opt-in is turned on for your business, in which case they receive nothing until
they confirm.
If your form tells people they'll get email from you, use
client.audience.people.subscribeToEmail() in place of identify(). It takes
the same details and also marks the person as Subscribed.
Subscriptions covers the rules in full.
If You Use a Form Tool
Some sites collect signups through a form built into Webflow, Framer, or another tool, where you can't run your own code on submit. In that case, have the tool send a webhook to Quotient instead.
Create a flow with a Webhook trigger, then add an Upsert Person step to save the lead and a Record Custom Event step to record the signup. Webflow and Framer webhooks are supported out of the box. See Capturing Events from Other Tools for an example.
Keep the tracking tag on the page either way. One difference to know about: the webhook comes from the form tool, not the visitor's browser, so the browser isn't linked to the new person. Their later visits are tied to them once they click a link in one of your emails.
Check That It Works
Open your page, complete the lead magnet, and submit the form with an email address you can check. Then confirm three things:
- The person appears on the People page, and on your list if you used one.
- The follow-up email arrives.
- Quotient can answer a question about it, such as:
How many people requested the calculator report in the last 7 days, broken down by UTM source?
If nothing shows up, open your browser's developer tools, select Network,
and submit the form again. A 403 response usually means your site's domain is
missing from the API key's allowed origins, or the key lacks a permission. A
422 on the event usually means the event ID doesn't exactly match one you
created in Quotient.
Next Steps
Connect website activity to real people when they share their email address on your site
Record important website conversions and connect them to the marketing that drove them
Automate your marketing with flows that start at the moments that matter and act on them for you.
How Quotient tags your links so website activity can be traced back to the marketing that drove it