How to track a SaaS sign-up funnel with server-side events

Send sign-up, activation and first payment from your backend, so each step is recorded when your system confirms it, not when a page loads.

Emircan Üye
4 min read
Server-Side Tracking

A browser sign-up event depends on a page loading and the tracker running on it. Your backend knows the moment the account is actually created. Hardal's guide to measuring sign-up completion puts it plainly: a click on a sign-up button does not establish that an account was created.

So send each business step from the system that confirms it. For a SaaS funnel, the web tracker records page visits, and your backend sends sign-up, activation and first payment.

Decide which system sends each step

Give every step one sender. Hardal's guide to server-confirmed purchases is explicit that a shared ID alone does not deduplicate submissions. If both the browser and the server send sign_up, it is recorded twice.

StepRecorded whenSenderEvent
Pricing and sign-up page visitsThe page loadsWeb trackerpage_view, collected automatically
Sign-upYour backend creates the accountSign-up handlersign_up
ActivationYour activation rule is met for the first timeBackend job or handlerA custom event you name, e.g. activated
First paymentYour payment provider confirms the first paid invoiceWebhook handlerA custom event you name, e.g. first_payment

sign_up is one of Hardal's standard events. Activation and first payment are specific to your product, so you send them as custom events. Hardal asks for lowercase snake_case names that you keep stable, because renaming an event splits its history. activated and first_payment are example names; choose your own.

Send sign_up from the server

Hardal takes server events as an HTTP POST to the collection URL shown in Setup, with tenantId at the top level of the body and sourceId inside the payload. The API & Server-side Setup page lists every field. One helper keeps all calls the same:

// Node 18+. One helper for every server-side funnel event.
async function sendHardalEvent({ eventName, occurredAt, url, data, consent, userId, userAgent }) {
  const granted = consent === "granted";
  const res = await fetch(process.env.HARDAL_COLLECT_URL, {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "User-Agent": userAgent, // the visitor's UA when forwarding their request, your app's UA for backend jobs
      "x-hrd-consent": granted ? "granted" : "denied",
    },
    body: JSON.stringify({
      tenantId: process.env.HARDAL_TENANT_ID,
      type: "event",
      eventName,
      payload: {
        sourceId: process.env.HARDAL_SOURCE_ID,
        url,
        timestamp: occurredAt, // when the step happened, in Unix milliseconds
        ...(granted && userId && { userId }),
        data,
      },
    }),
  });
  const body = await res.json();
  if (res.status !== 202 || body.data?.accepted !== 1) {
    throw new Error(`Hardal did not accept ${eventName}: ${res.status}`);
  }
}

Call it right after the account is saved, with eventName: "sign_up" and data: { method: "email" }. Three details come straight from the docs:

  • Timestamp. Send the time the step happened, in Unix milliseconds. If you retry a delayed event, reuse the stored time.
  • Consent. You can send server events without a known identity. Send x-hrd-consent: granted and a userId only when your consent rules allow identification. Otherwise send denied and leave identity out.
  • User-Agent. It is required. Forward the original client user agent when you are forwarding a request, and use your application's user agent for backend events.

Send activation and first payment once

These two steps run in a different code path from sign-up: a background job or a webhook. Make each one fire once per account.

  1. Activation. Store an activated_at value on the account. Send activated only in the same step that sets it for the first time.
  2. First payment. Stripe, for example, retries webhook delivery for up to three days in live mode, and its docs note that an endpoint may receive the same event more than once. Record the invoice ID before you send first_payment, and skip invoices you have already sent.

Put the value and currency in data, and keep the same keys and types every time. Hardal's custom event docs ask for that consistency, so the parameter stays usable in reports.

Check each step in Hardal

Open Engagement → Events. To compare the steps, pick sign_up, activated and first_payment in the timeline's Events picker so they chart side by side over the same report range. To check one step's parameters, find it in the Event Log and open it. To scope the scorecards to these events, use Filters → Behavior → Event name. Hardal's Events report docs describe each control.

Test with one account first

  1. Sign up with a test account. Expect HTTP 202 with data.accepted: 1.
  2. Find sign_up in the Event Log and check its time and parameters.
  3. Trigger activation twice and confirm that only one activated event arrives.
  4. Pay with a test card, deliver the same webhook event to your handler twice, and confirm that only one first_payment arrives.

Once all four pass, every step comes from the system that confirmed it, and each one is recorded once. The full endpoint and payload reference is in Hardal's API & Server-side Setup docs.

Never miss a resource.

Subscribe to our newsletter.