Setup and data
How to track form submissions without sending what people typed
Count a completed form as a conversion without sending names, emails or message text, and do not treat a click on Submit as a success.
The CrispStats team · · 8 min read
In short
The form is often the only conversion a marketing site has. It is also the easiest place to copy an email address into an analytics tool by accident, because the interesting part of the submit is exactly the data you should not collect. This page is the narrow version: count the completed submit, and leave every field where it was typed. The rate that sits on top of the count is in how to calculate conversion rate. What counts as personal data is in PII examples in analytics.
What is a form submission in analytics?
A completed send of the form, counted once per success, with a name you chose and no field values. It is a conversion if that send is the outcome you care about, and it is just an event if you are only watching volume.
Three moments get called a submission, and only the last two are one:
- The button click. The person pressed Submit. The browser may still block the send because a required field is empty.
- The submit event. The browser accepted the form and is about to send it. HTML validation has already passed. You do not yet know that the server stored it.
- The accepted result. The server responded with success, or the browser landed on the thank-you page that only exists after a real send.
Pick the latest moment you can observe. A contact form that posts and redirects can use the thank-you page. A form that stays on the same page and shows an error from the server should wait for that response. Counting the button is how a form with strict validation looks more popular than it is.
Why should the event leave out every field?
Because the fields are the person’s data, and the analytics question does not need them. “How many people asked for a demo” is a count. The address, the name and the message are a record that belongs in the inbox or the CRM, not in a traffic tool.
The usual leaks are dull. A property named email is the obvious one. So is name, phone, company when the company is a sole trader, and the free-text message, which often contains a phone number in the second sentence. A hidden field that your form plugin fills with the address is still a field. So is the label of the control, if the label is the address the person typed.
URLs leak the same way. A form with method="get" puts every field in the query string of the next page. Analytics that records the page URL then stores the address even though you never wrote an event. Use post. Give the thank-you page a path with no query string. PII examples covers the other places a form value hides, including page titles.
How do you count a submit that succeeded?
Use the thank-you page when the form navigates, and the submit event or the server response when it does not. Never copy the form into the event.
A thank-you page
If a successful send always lands on /thanks, and nothing else links there, a pageview of that path is the conversion. You add no form code. The fields were posted to your server and are not in the address.
<form id="contact" method="post" action="/thanks"> <!-- fields stay in the form. Nothing here is copied into analytics. --></form>The goal is a page rule for /thanks. People who open that URL from a bookmark are also counted, so do not publish the path, and do not use a page people visit for other reasons, such as the homepage.
The submit event, with an empty payload
When the form does not navigate, send one event from the submit listener. crispstats("contact form") has a name and no properties. The browser only fires submit after its own checks pass, so empty required fields do not count.
var form = document.getElementById("contact");form.addEventListener("submit", function () { crispstats("contact form");});If your code calls preventDefault and sends the form itself, the submit event has fired before you know the server accepted it. Wait for the response:
form.addEventListener("submit", function (event) { event.preventDefault(); submitContactForm().then(function (ok) { if (ok) crispstats("contact form"); });});submitContactForm is your code. It may read the fields, because it is the product, not the analytics. The analytics call on the next line takes no fields. A property is allowed only when it cannot identify someone: form: "footer" is fine, plan: "team" is fine if they picked it from a list that is not personal, and the message text is not.
Why is a click on Submit the wrong event?
A click fires when validation fails, when the person presses the button twice, and when a script button is not a submit at all. It over-counts the conversion and under-describes it.
A data-cs-event attribute on the button counts the click, which is what you want for a control that does not send a form. On a submit button it counts attempts. Button clicks is the right guide for those controls. For a form, prefer the submit listener or the thank-you page, and do not also tag the button, or each success is stored twice.
| Signal | Fires when | Includes failed attempts | Sees field values |
|---|---|---|---|
| Click on the Submit button | The pointer hits the button | Yes | Only if you copy them |
| submit event | The browser accepts the form | No, for HTML validation | Only if you copy them |
| Server responded OK | Your handler got a success | No | Only if you copy them |
| Thank-you page | The browser loaded that path | No, if only success redirects there | Only if the URL contains them |
How do you turn submits into a conversion rate?
Divide the people who completed the form by the people who could have, over the same dates. Do not divide by the number of attempts.
The denominator is usually the visitors or the sessions that saw the form, not the whole site. A homepage that contains no form will crush the rate if you include it. The numerator is unique people if one person can submit twice and you care about people, or completions if every send matters. Conversion rate is that fraction, and the calculation guide covers the choices that change the result. Mark the event or the thank-you path as a goal so the rate is computed for you instead of from an export.
- Write down the success: “the server accepted the contact form”, not “clicked Submit”.
- Count it once per success. A double click that sends one email is one conversion.
- Use the same period and the same audience for the denominator.
- Keep field values out, so a later audit of the event does not become an audit of the inbox.
What does a month of a contact form look like?
Attempts, accepted submits and the rate are three different numbers. Reporting the largest one makes the form look healthier than the inbox.
A worked example: attempts against accepted sends
This example uses made-up numbers. The contact page has 2,000 visitors in a month. The Submit button receives 260 clicks. HTML validation blocks 70 of them. The submit listener fires 190 times. The server rejects 30 as spam and accepts 160. The thank-you page, shown only after acceptance, is viewed 160 times.
The conversion rate against visitors is 160 ÷ 2,000 = 8%. The button-click rate is 260 ÷ 2,000 = 13%. Both use the same visitors. The 13% figure counts people who never reached you. If the event had included the email field, those 160 addresses would now sit in the analytics database as well as in the inbox. The event contact form with no properties has the 160 and none of the addresses.
How does CrispStats record a form submission?
CrispStats does not read forms. Nothing is sent unless you send it, or the visitor lands on a page. Call crispstats("contact form") from the submit path above, or make a goal whose rule is the thank-you path. A data-cs-event attribute is the click, so leave it off the Submit button when the submit event is already in place.
Properties are optional and flat. Use them for the form’s location or the plan someone picked from a list. Do not put an address, a name or the message in a property. The script sets no cookies and does not identify the visitor. A goal’s conversion rate is completing visitors divided by visitors, which matches the 8% in the example when the goal is the accepted send. Goals and the event list are described on the funnels page.
Terms in this guide
Free tools
- A/B test significance and sample size calculatorCheck if an A/B test result is statistically significant, with the p-value and lift, or work out the sample size a test needs before you start it.
- Conversion rate calculatorWork out your conversion rate from visitors and conversions: conversions ÷ visitors × 100. With the formula, a worked example and what a target rate needs.
- Revenue per visitor calculatorEnter visitors, conversion rate and average order value to get revenue per visitor, monthly revenue, and what a 10% improvement is worth.
Use cases
- CrispStats for startupsFunnels, retention, revenue attribution and uptime from the first day, on a price that stays small while you find your market.
- CrispStats for SaaSSee which channels bring paying customers, where trials stall in the funnel, and how your app performs for real users, from one cookieless script.
- CrispStats for ecommerceTie orders to the campaign, page and source they came from, find where checkout loses people, and watch page speed, without cookies.
More guides
All guides- Revenue · 11 minHow to calculate conversion rate, with worked examplesConversion rate is conversions divided by visitors, times 100. Worked examples for funnels, delayed conversions, channel mix and how many visitors you need.
- Privacy · 13 minPII examples: what counts as personal data in analytics, by regulatorPII examples from NIST, the GDPR and the CCPA side by side: names, emails, IP addresses, cookie ids and more, and where each one leaks into analytics.
- Engagement · 9 minHow to track button clicksGA4 does not track button clicks by default. Three ways to add them: a gtag call, a Tag Manager trigger, or one HTML attribute, with the steps for each.