Forms and leads examples
How many people start your demo form and how many send it? Where do the others give up? Which newsletter box brings subscribers? Autocapture sees a little of this. Two custom events see all of it, without sending a word anyone types.
Updated
The snippets assume the script tag and the queue stub are in the page’s <head>. The data-… attributes are for your own script; ClickClacks doesn’t read them.
How many people start the demo form, and how many send it?
Fastest: autocapture and a thank-you page
Clicks into form fields arrive as $click with Clicked element input or textarea, on the form’s Page, and never with any text. That is a rough “started”. A submit <button> sends its label as Clicked text, but a click isn’t a successful submission: the browser may refuse the form, or your server may. An <input type="submit"> carries no text at all.
If a successful submission lands on its own page, such as /demo/thanks, that page’s $pageview is a reliable “submitted” with no code.
Precise: “started” and “submitted” events
<form data-form="demo-request" action="/demo" method="post">
<input name="company" autocomplete="organization">
<input name="work_email" type="email" autocomplete="email">
<button type="submit">Request a demo</button>
</form>
<script>
document.querySelectorAll('form[data-form]').forEach(function (form) {
var name = form.dataset.form
var started = false
// The first time anyone moves into a field of this form.
form.addEventListener('focusin', function () {
if (started) return
started = true
window.clickclacks?.('event', 'Form started', { form: name })
})
// Fires after the browser's own validation passes.
form.addEventListener('submit', function () {
window.clickclacks?.('event', 'Form submitted', { form: name })
})
})
</script> Forms sent with fetch never fire a page load, and their submit event fires before your server has answered. Send Form submitted when the request succeeds instead:
async function sendDemoRequest(form) {
const response = await fetch('/api/demo-requests', { method: 'POST', body: new FormData(form) })
if (response.ok) {
window.clickclacks?.('event', 'Form submitted', { form: 'demo-request' })
}
return response
}Read the answer
- In Funnels, click New funnel. Step 1:
Form started, + Filter › Form isdemo-request. - Step 2:
Form submittedwith the same filter. Name it Demo form and click Save funnel, then pick a board or Save without a board. - Read Overall conversion and Median time to convert.
- Click the drop between the steps to open its card. See the people who didn’t continue lists who started and never sent it, and What did they do instead? shows where they went.
- Choose Break down by › Device to check whether one device struggles.
To see how many visitors to /demo start the form at all, add a step before both: $pageview where Page is /demo.
How many people join the newsletter, from which box and which campaign?
Fastest: autocapture, for clicks only
A Subscribe button sends its label as Clicked text, and Page says which page it was on. That counts attempts, including invalid addresses and people already subscribed, not sign-ups.
Precise: an event after the sign-up succeeds
<form id="newsletter" data-placement="footer">…</form>
<script>
var newsletter = document.getElementById('newsletter')
newsletter.addEventListener('submit', function (event) {
event.preventDefault()
fetch('/api/newsletter', { method: 'POST', body: new FormData(newsletter) })
.then(function (response) {
if (!response.ok) return
// After the subscription succeeded, never with the address.
window.clickclacks?.('event', 'Newsletter joined', {
placement: newsletter.dataset.placement,
})
})
})
</script>Read the answer
- In Insights, chart
Newsletter joinedas Unique people, Weekly. - Add breakdown › Placement to compare the footer box with the others.
- Change the breakdown to UTM source or Referrer. They are the visit’s values, so a sign-up three pages after landing still counts toward the campaign that brought the visit.
- For a sign-up rate, set series A to Viewed page (
$pageview) as Unique people, series B toNewsletter joined, and add the formulaB / A * 100.
Keep form data out
- Never send what people type, such as an email address, name or company, as a property. Send which form, which step and whether it worked.
- Autocapture never records field values or the text of anything clicked inside a field. See what autocapture never captures.
- To tie a lead to a person you already know, call identify with your own user ID, not their email.
- Mark anything else sensitive with
data-cc-mask: clicks inside it carry no text, and heatmap captures leave it out.