Skip to content

Connecting anonymous → server

Most server events carry a userId, and that’s the whole connection: the event joins the person’s profile and picks up their context. The case that needs a hand is a conversion that fires while your backend doesn’t yet know who’s converting. A guest checkout is the classic example – the payment lands before any account exists, so the webhook has nothing to identify the buyer by.

The browser side is already handled. From the first page view, the Fidero SDK gives every visitor an anonymous ID, with their captured context sitting behind it. Your backend just needs that ID in hand when the conversion fires, and the pattern on this page is how it gets there.

  1. Read the anonymous ID in the browser

    The ID is a UUID, created on the visitor’s first page view and persisted in the browser.

    await fidero.ready;
    const { anonymousId } = fidero.getIdentity();
    // e.g. "9f2c4d1e-7a83-4b6f-a2d4-31c98e5f7b20"
  2. Carry it through your flow

    Attach the ID to whatever object makes the round trip to your backend. For Stripe Checkout that’s client_reference_id: send anonymousId in the request your page makes to create the session, and set it there.

    create-session.js
    // on your server, creating the Checkout Session
    const session = await stripe.checkout.sessions.create({
    client_reference_id: req.body.anonymousId,
    mode: "payment",
    // …line items and redirect URLs
    });
  3. Send it back on the conversion

    When the webhook lands, the ID comes back with it. Send the event with anonymousId in place of userId:

    webhook.js
    // webhook handler for checkout.session.completed
    const session = stripeEvent.data.object;
    await fetch("https://api.datahappy.co/v1/t", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
    authToken: process.env.FIDERO_API_TOKEN,
    projectId: "YOUR_PROJECT_ID",
    type: "track",
    event: "purchase_completed",
    anonymousId: session.client_reference_id,
    properties: {
    transaction_id: session.payment_intent,
    value: session.amount_total / 100,
    currency: session.currency.toUpperCase(),
    },
    messageId: session.payment_intent,
    }),
    });

    Fidero finds the visitor’s profile by the anonymous ID, and the conversion goes out with the click IDs and campaign context captured in the browser. Authentication, responses and the rest of the envelope are on the HTTP API.

Stripe is the worked example, not the limit. Any system that can carry a string through a round trip supports the same pattern: metadata on a payment or an order, a hidden field on a lead form, a custom field on the CRM record your integration reads back. Two things need to hold: the field survives to wherever the conversion fires, and your handler sends its value back as anonymousId.

Guest customers often become account holders. When that happens, identify them in the browser as usual (a userId set with updateIdentity or on any event), and Fidero merges the anonymous profile into the known one. The guest purchase, and everything before it, stays on their record.

If they never sign up, nothing changes: the conversion connected the moment it landed. Identity covers how anonymous and known profiles fit together.

What the server remembers, and why, is on the platform overview.