Why track form submissions?
Forms are the most critical moments in any app:- A signup form = a new user
- A checkout form = revenue
- A contact form = a lead
The form submission pattern
There are two moments you want to track:- When the user starts filling the form (optional but valuable)
- When the form submits successfully
components/Forms.js
React — Signup form example
- JavaScript (.jsx)
- TypeScript (.tsx)
components/SignupForm.jsx
Login form example
components/LoginForm.jsx
Contact / enquiry form example
components/ContactForm.jsx
Checkout / payment form example
components/CheckoutForm.jsx
Key rule: Don’t track the ‘Submit’ button directly!
It is very tempting to just addtrack() to the final submit button. Do not do this.
If you track the button click, your dashboard will show a “Signup” or “Purchase” even if the user’s credit card was declined or they typed the wrong password. You will get fake data.
Always add your tracking code after your database or payment system confirms it was successful:
api/users.js
Recommended form events
| Event | When to fire |
|---|---|
signup_form_started | User focuses the first input field |
signup_completed | API returns success |
signup_failed | API returns error |
login | Login API returns success |
login_failed | Login fails |
contact_form_submitted | Contact form sends successfully |
checkout_started | User clicks “Proceed to Checkout” |
purchase | Payment confirmed |
checkout_failed | Payment fails |