Skip to the page

Developer GuideTracking

Form tracking

How Venbit picks up forms automatically, which form tools it recognises, and how to report a custom or JavaScript-drawn form with venbit().


Forms need no setup. With the tracker line on the page, Venbit sees a visitor start a form and press send, and it sees whether the send was accepted. An accepted enquiry form turns into a lead in the Inbox, carrying the values the visitor typed. If your own code draws or sends the form, three venbit() calls report the result precisely.

JavaScript
const form = document.getElementById('contact');

// where your code knows the send was accepted
window.venbit?.('form_success', 'contact', { form });

// where it knows the send was refused or failed
window.venbit?.('form_failure', 'contact', { form });

You'll find the tracker line, with your site's key in place of KEY, in the dashboard under Settings, then Tracking.

What happens to a send

A send is never lost because it could not be confirmed

A send is confirmed when the form tool said it worked, the response said so, or the visitor landed on your thank-you page. It failed if the response was an error or the form showed a validation or failure message, and a failed send isn't a lead.

Then there's the send with no readable answer. Nothing confirmed or refused it within about eight seconds, or the visitor left the page first. It still counts. Confirmation makes a lead exact, but silence never makes one disappear.

Classic forms that post and load a new page get settled on the next page. If the site has a thank-you page set as a goal, only an arrival there confirms the send. Without one, landing on any page does.

Forms that work with no code

FormHow the send is confirmed
A plain HTML form (<form method="post">)The page the visitor lands on afterwards, or your thank-you page.
A form sent with fetch or XMLHttpRequestThe response to the request that carried the form's values. A 204, or a body that says success, confirms it. An error status or a body that says failure refuses it. A bare 200 with nothing readable in it counts as unverified.
Contact Form 7, Gravity Forms, WPForms, Elementor, Ninja Forms, Fluent Forms, Forminator, Formidable Forms, AvadaThe plugin's own success and failure events.
Squarespace, Webflow, Wix and Duda form blocksThe builder's own success or failure message.
HubSpot forms, embedded or in a frameHubSpot's submission callback.
ClickFunnelsIts submission event.
Calendly, Typeform, Tally, Cognito Forms, Paperform, ServiceTitan, Housecall Pro, WellnessLiving, GoHighLevel and Marketing 360 embedsThe message the embedded tool sends to the page when a booking or form is completed.

Open shadow roots and same-origin iframes are no obstacle. Forms inside them are tracked like any other form on the page.

An iframe from another domain is different. If the tool that embeds it isn't listed above, the form can't be read from outside the frame. Use a thank-you page, or the frame bridge at the end of this page.

Report a custom form yourself

Reach for the calls when your code owns the send. That covers React or Vue forms, server actions, a response format of your own, and components with no <form> element.

CallWhen to make it
venbit('form_success', name, props)After your server or app has confirmed the send, rather than on the button click.
venbit('form_failure', name, props)In the branch for a failed validation, an error response or a network failure.
venbit('form_attempt', name, props)Before a delayed send, and only when there's no ordinary submit button or submit event to mark the start.
PropertyTypeMeaning
formElement or stringThe <form> element or the container that holds the fields. Pass the element when you have it.
valuesobjectField values as { Label: value }, for values that live in your framework's state rather than the page's inputs. They're added to what the tracker read from the fields.
submissionIdstringYour server's id for the submission. Report a result twice with the same id on a page and it counts once.

The tracker finds the form in this order:

  1. If props.form is an element, that's the form.
  2. A string (props.form or the second argument) is matched against the forms the visitor has touched on this page, by data-venbit-form, id or name, and then against element ids.
  3. With no form given at all, the call applies to the one form that has a send in progress.

Sometimes the tracker has already confirmed the send by itself. Your form_success for that same send won't be counted again.

Never put passwords, payment details or CAPTCHA tokens in values. Keys that look like those get dropped anyway.

Worked example: a fetch-based contact form

This is a complete page. The form posts JSON to /api/contact and reports the result in both branches.

HTML
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Contact Harbor Roofing</title>
    <script>
      window.venbit = window.venbit || function () { (venbit.q = venbit.q || []).push(arguments); };
    </script>
    <script defer crossorigin="anonymous" src="https://vnbt.app/m.js?s=KEY" data-site="KEY"></script>
  </head>
  <body>
    <form id="contact" name="contact">
      <label>Name <input name="name" autocomplete="name" required></label>
      <label>Email <input name="email" type="email" autocomplete="email" required></label>
      <label>Message <textarea name="message" required></textarea></label>
      <button type="submit">Send message</button>
      <p id="contact-status" role="status"></p>
    </form>

    <script>
      const form = document.getElementById('contact');
      const status = document.getElementById('contact-status');

      form.addEventListener('submit', async (event) => {
        event.preventDefault();
        const body = JSON.stringify(Object.fromEntries(new FormData(form)));

        try {
          const response = await fetch('/api/contact', {
            method: 'POST',
            headers: { 'Content-Type': 'application/json' },
            body,
          });
          if (!response.ok) throw new Error('Request failed: ' + response.status);
          const result = await response.json();

          venbit('form_success', 'contact', { form, submissionId: String(result.id || '') || undefined });
          status.textContent = 'Thanks. We will be in touch today.';
          form.reset();
        } catch (error) {
          venbit('form_failure', 'contact', { form });
          status.textContent = 'That did not send. Please call us.';
        }
      });
    </script>
  </body>
</html>

Call form_success before you reset or remove the form. Otherwise the fields are empty by the time the tracker reads them.

A coding agent can wire this into your own forms:

Find every form in this codebase that is sent with fetch, axios, a server action, or a component with no <form> element, and report its result to Venbit. Call window.venbit?.('form_success', 'name', { form, submissionId }) only after the server confirms the send, before the form is reset. Call window.venbit?.('form_failure', 'name', { form }) in the error branch. For a container with no <form>, add data-venbit-form="name" and pass that element as form. Never put passwords, card data or CAPTCHA tokens in values.

Forms without a form element

Give the container holding the fields and the send button a data-venbit-form attribute, then pass that element to the calls.

HTML
<div id="quote" data-venbit-form="quote">
  <input name="email" type="email" placeholder="Email">
  <input name="phone" type="tel" placeholder="Phone">
  <button type="button" id="quote-send">Get my quote</button>
</div>

<script>
  const quote = document.getElementById('quote');
  document.getElementById('quote-send').addEventListener('click', async () => {
    window.venbit?.('form_attempt', 'quote', { form: quote });
    const response = await fetch('/api/quote', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        email: quote.querySelector('[name=email]').value,
        phone: quote.querySelector('[name=phone]').value,
      }),
    });
    window.venbit?.(response.ok ? 'form_success' : 'form_failure', 'quote', { form: quote });
  });
</script>

In reports, a form's name comes from its name, id or aria-label attribute, in that order.

Multi-step forms

If a form swaps its fields between steps, it's still one form as long as every step keeps the same data-venbit-form, id or name. Values typed on earlier steps are kept and go out with the final step. Two forms on the page at the same time are always separate.

Say what kind of form it is

Only enquiry forms become leads. The tracker guesses the kind from the form itself, and data-venbit-form-kind overrides that guess.

ValueMeaningCounted as a lead
enquiryA form that asks the business for something: contact, quote, booking request.Yes
searchA search box.No
furniturePart of the site's furniture: newsletter sign-up, log-in, cart, coupon, filter, sort, language picker.No
HTML
<!-- a product finder that must never create leads -->
<form action="/find" data-venbit-form-kind="search">
  <input name="q" placeholder="Find a product">
  <button>Search</button>
</form>

<!-- a callback box the tracker would otherwise read as a newsletter form -->
<form id="callback" data-venbit-form-kind="enquiry">
  <input name="phone" type="tel" placeholder="Your number">
  <button>Subscribe to a callback</button>
</form>

To label every form on a site in one go:

Review the forms in this codebase for Venbit. Add data-venbit-form-kind="enquiry" to contact, quote, callback and booking forms, data-venbit-form-kind="search" to search boxes and store finders, and data-venbit-form-kind="furniture" to newsletter sign-up, log-in, cart, coupon, filter, sort and language forms. Add data-venbit-private to any sensitive field that isn't a password or card field. List each change.

Keep fields private

Password, card number, security code, expiry and social security number fields are never captured, and neither are hidden or file inputs. For anything else sensitive, add data-venbit-private to the field (or to any element wrapping several fields) and those values are left out.

To capture nothing typed on any form, put data-capture="off" on the tracker's script tag. Sends are still counted.

Privacy controls lists every control, and Data attributes has the HTML.

Forms in a cross-origin iframe

When you host a form on another origin and embed it in a frame, the page and the frame can work together. Mark the frame on the parent page:

HTML
<iframe src="https://forms.harborroofing.example/contact" data-venbit-form="contact"></iframe>

Inside the frame, after the send is confirmed, post the result to the parent. The second argument is the parent page's origin.

JavaScript
parent.postMessage({
  type: 'venbit:form-result',
  status: 'success',
  submissionId: 'msg_20931',
  values: { Name: 'Dana Whitfield', Email: 'dana@example.com', Message: 'Leak over the garage.' },
}, 'https://harborroofing.example');

status is attempt, success or failure. Venbit only accepts the message from the frame carrying data-venbit-form, and only when it comes from the origin in that frame's src. Put the tracker line on the parent page. The frame doesn't need it.

Common questions

Does Venbit track Contact Form 7 and Gravity Forms?

Yes, without any code. Venbit reads the plugin's own success and failure events for Contact Form 7, Gravity Forms, WPForms, Elementor, Ninja Forms, Fluent Forms, Forminator, Formidable Forms and Avada.

Can Venbit track a form inside an iframe?

Same-origin iframes are tracked like any other form. A form embedded from another domain can only be read when it comes from a tool Venbit recognises, such as Calendly, Typeform or HubSpot. For other cross-origin forms, use a thank-you page or have the frame post a venbit:form-result message to the parent page.

Why is my form send marked unverified in Venbit?

Nothing confirmed or refused the send within about eight seconds, or the visitor left the page first. It still counts. Report the result with venbit('form_success') or use a thank-you page and it becomes exact.

Does a newsletter sign-up count as a lead in Venbit?

No. Only enquiry forms become leads. Newsletter sign-ups, log-ins, carts and the like are treated as site furniture. If the tracker reads a form wrongly, set data-venbit-form-kind to enquiry, search or furniture.

Last updated . Something wrong or missing on this page? Tell us from Settings, then Support.