Engineering5 min read

GA4 form_submit is not a lead: count real enquiries

GA4 counts a form_submit on every attempt, including the ones your server rejects. How to report accepted leads and confirmed calendar bookings instead.

Google Analytics sent us a cheerful email: key events up 500%. The inbox did not agree.

Both were telling the truth. The site was counting something, and it was not leads. This is what it was counting, how we replaced it, and how to check whether your own conversion number has the same problem. It takes about ten minutes to find out.

What form_submit actually measures

GA4 has a feature called enhanced measurement, and one of its options is form interactions. With it on, Analytics sends two events without any code from you: form_start and form_submit. Google's definition of the second is short: it fires when the user submits a form.

Read that literally, because GA4 does. It fires when the browser submits. Not when your server accepts the message. Not when validation passes on the back end. Not when the email reaches anyone. A visitor who presses the button, gets "something went wrong" and leaves has produced a form_submit. So has a bot. So has a retry.

Then it gets worse in a way that is easy to miss. Our own code also sent an event after a successful submission, and at some point somebody named it form_submit. Two different things were now arriving under one name: Google's automatic event on every attempt and ours on every success. In the reports they are one line. Nobody can separate them afterwards.

That one line was starred as the key event. Every conversion report, and every "up 500%" email, was built on it.

An event that only fires on success

The fix is not clever. The lead event has to be sent from the one place in the code that knows the server said yes, and it needs a name the automatic measurement does not use.

GA4 has a recommended event for exactly this, generate_lead.

export const trackLead = () =>
  gtagEvent('generate_lead', {
    event_category: 'contact',
    event_label: 'contact_form',
  });
// In the form's submit handler
await sendForm(values); // throws if the server rejects it
trackLead();            // reached only when it did not

The order is the whole point. If sendForm throws, the line after it never runs, and a failed attempt is not counted as a customer.

We left the automatic form_submit switched on. It is a useful number once it is no longer pretending to be something else: the gap between attempts and accepted leads is how you find out the form is failing for real people.

Bookings inside an embedded calendar

The second blind spot was the calendar. Our contact page embeds Calendly, and an embedded widget is an iframe from another origin. The page cannot see inside it. A visitor could book a call and Analytics would record a page view and nothing else.

What we had instead was calendly_click, a click on a booking link. A click is intent. It is not a booking, and most clicks do not become one.

Calendly posts a message to the parent page when a slot is confirmed. Listening for it is a few lines:

useEffect(() => {
  const onMessage = (event: MessageEvent) => {
    if (event.origin !== 'https://calendly.com') return;
    if (event.data?.event === 'calendly.event_scheduled') {
      trackCalendlyBooked();
    }
  };

  window.addEventListener('message', onMessage);
  return () => window.removeEventListener('message', onMessage);
}, []);

The origin check is not decoration. Any frame and any browser extension can post a message to your window, and without that line any of them can book imaginary calls in your reports.

Most embedded tools have an equivalent: scheduling widgets, payment forms, chat widgets. If a conversion happens inside an iframe, look for the message it posts before deciding it cannot be tracked.

The rule that had never matched

GA4 lets you create events in the admin interface from conditions on other events. We had one, meant to mark a visit to the contact page.

Its condition was a page path starting with /#contact. That was an anchor on the one-page site this one replaced. The contact page has had its own URL for a long time. The rule had matched nothing for months, reported no error, and sat in the list of key events looking like the others.

Rules made in an admin panel are not in the repository. Nothing reviews them when a URL changes, and a rule that matches nothing is indistinguishable from a quiet week. If you have any, read their conditions against the URLs the site has today.

Star only what you would pay for

A key event is a statement that this action is worth money. Ours are now:

  • generate_lead: the server accepted a contact form
  • calendly_booked: a call was actually scheduled
  • contact_click: a click on one of the direct contact links
  • contact_us_page: a visit to the contact page, with the rule repaired

The automatic form_submit lost its star. None of the four has a default value: a made-up number multiplied by a miscounted event gives a revenue figure with nothing behind it.

One cost is worth stating. Conversion counts from before the change cannot be compared with those after it. The old number included attempts, the new one does not, so the chart drops on the day of the fix. Write the date down somewhere the next person will find it.

Check yours in ten minutes

  1. In GA4, open Admin, then Data streams, your stream, and Enhanced measurement. See whether form interactions is on.
  2. Open Admin, then Key events. If form_submit is starred, your conversion number counts attempts.
  3. Search the codebase for form_submit. If your own code sends an event with that name, the two are already mixed.
  4. Open the Realtime report and submit the form once. Note which events appear, then ask one question about the starred one: is it sent before the server answers, or after?
  5. Take last month's conversion count and last month's real enquiries from the inbox or the CRM. The two numbers should be close. If Analytics shows five times more, the gap is not good news.

And when you fix it, test with a real submission, after telling whoever reads the sales inbox that a test is coming.

Tracking that reports success while measuring something else is one of the six areas we cover in a website audit. It is also the area where the finding most often changes a marketing budget.