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.
The pattern
Section titled “The pattern”-
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" -
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: sendanonymousIdin the request your page makes to create the session, and set it there.create-session.js // on your server, creating the Checkout Sessionconst session = await stripe.checkout.sessions.create({client_reference_id: req.body.anonymousId,mode: "payment",// …line items and redirect URLs}); -
Send it back on the conversion
When the webhook lands, the ID comes back with it. Send the event with
anonymousIdin place ofuserId:webhook.js // webhook handler for checkout.session.completedconst 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.
Beyond Stripe
Section titled “Beyond Stripe”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.
When they sign up later
Section titled “When they sign up later”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.
Related
Section titled “Related”What the server remembers, and why, is on the platform overview.