Tracking a multi-step booking form with no form element, no field names and fields that vanish between steps

Black and white photo of Ron Geronimo Posted by: Ronel Geronimo Date Posted: September 4, 2026
Back to Case Studies

Issue

NeuMed’s booking flow at app.neumed.com/#/book is a React single-page app with no real <form> element and no name or id attributes on any of the inputs. On top of that, fields entered in earlier steps of the booking flow get unmounted from the DOM as the user moves forward, so by the time you’d normally want to grab the data, it’s already gone.

Solution

Created a custom script using the virtual-form pattern: build a stand-in <form> element ourselves and hand it to mcfx('capture', formEl) instead.

To pull that off with fields disappearing between steps, we set up two tags. The first sits at the document level with a blur listener (fires when you click or tab away from an input) running in capture phase so it catches events before the SPA can intercept them. It matches each input to its label by looking at the previousElementSibling, then stashes an allow-listed set of fields — phone, name, email only — into sessionStorage as the user moves through the flow. The second tag fires on a booking_confirmed custom event, rebuilds the virtual form from whatever’s sitting in sessionStorage, calls mcfx('capture', virtualForm), then clears storage.

The gotcha that ate the most time: booking_confirmed looks like a real browser event, but it’s actually just a dataLayer push (GTM’s internal event log), not a true window.CustomEvent. Wrapping the second tag’s logic in window.addEventListener for it silently did nothing — no errors, no data, just a no-op. Had to run the capture logic directly in the tag body instead. To debug faster, injecting the blur-listener snippet straight into the console via was the move — it let us confirm the capture logic itself worked before chasing whether the problem was in GTM’s publish/trigger setup.

Achievement

Full lead capture on a booking flow that gave us nothing to work with natively — no form element, no field names, fields that vanish between steps. The virtual-form-plus-sessionStorage pattern is reusable for any React SPA booking or multi-step flow that behaves similarly, and the dataLayer-vs-CustomEvent gotcha is worth remembering whenever a GTM custom event trigger is involved.

Snippet/Screenshot/Link

Used two custom scripts:

  1. Tag 1 — Blur Listener (fires on all pages of the booking flow)
  2. Tag 2 — Capture on booking_confirmed (Custom Event trigger, NOT wrapped in addEventListener)

Custom scripts can be found in NeuMed’s GTM (GTM-P34Q4NQ).