Track events

Form submissions

Signup, contact and lead forms are usually your highest-value events. Track them by firing on the form's submit.

The simple case

Attach a submit listener and call track():

document.querySelector('#signup-form')?.addEventListener('submit', function () {
  window.servoki.track('signup');
});

This fires as the form submits. For a classic full-page POST that's perfect — the event leaves via sendBeacon, which survives the navigation.

Only count valid submissions

If you validate client-side, fire only when the form is actually valid so you don't count rejected attempts:

form.addEventListener('submit', function (e) {
  if (!form.checkValidity()) return;        // browser validation failed
  window.servoki.track('contact_submit', { form: 'contact' });
});

AJAX / fetch forms

When you submit with fetch and stay on the page, fire the event after a successful response so you only count real successes:

async function onSubmit(e) {
  e.preventDefault();
  const res = await fetch('/api/lead', { method: 'POST', body: new FormData(form) });
  if (res.ok) {
    window.servoki.track('lead', { source: 'pricing-page' });
  }
}

Don't send the form's contents. Track that a signup happened, not who signed up — never pass email, name or phone as event properties. For server-confirmed leads with hashed identifiers, use server events.

Verify it works

Submit the form, then watch the event land in Realtime. Make it a measured conversion in Goals.