Referalli: referral attribution and conversions
See referred visitors as the referral_program channel and record Referalli conversions as referral_converted events on the referred person.
Referalli (referalli.com) runs referral programs. Lucida can show where referred visitors come from and record when a referral converts.
Five-line setup
Send visitors to your site with their referral code. The browser SDK (0.1.9 or later) records it as
$referral_codeonce you turn it on:referralParams: { params: ["ref"], category: "referrals" }. It is off by default, and withcategoryset the code is recorded only after the visitor grants that consent-manager category (Cookie Munch: "referrals"; the Cookie Munch and Cookiebot bridges pass it through). Withoutcategoryit follows Lucida's analytics consent.Web analytics then reports those sessions in the channel
referral_program.Create a webhook source with preset
referalliand the modestandard, without a secret: it refuses every delivery until it has one.Register its URL in your Referalli program's webhooks. Referalli answers with the endpoint's
whsec_signing secret.Set that secret on the source with
PATCH. Each conversion (commission.earned) appears asreferral_convertedon the referred person.
Referral code and channel
When an event carries $referral_code, Lucida classifies it into the channel referral_program, ahead of every referrer-based or UTM channel: a referred visit from a search engine counts as referral_program, not as organic search. You can break down and filter events by the $referral_code property. The browser SDK also keeps the first code a person arrived with as initial_referral_code (browser SDK 0.1.8 and later, via referralParams; see the SDK reference).
Conversion webhook
Referalli generates the signing secret when you register a URL, so the order is: source first (no secret), then the Referalli endpoint, then the secret.
# 1. The source. With no secret yet it refuses every delivery (401), so nothing unsigned is ever recorded.
curl -X POST https://<your-lucida>/v1/projects/<project-id>/webhook-sources \
-H "Authorization: Bearer <token>" -H "Content-Type: application/json" \
-d '{"name":"Referalli","mapping":{"preset":"referalli"},"auth":{"mode":"standard"}}'
# 2. Register https://<capture-host><path> (path from the answer above) in Referalli, subscribed to commission.earned.
# Referalli's POST /v1/webhook-endpoints returns the endpoint's whsec_ secret once.
# 3. Give the source that secret.
curl -X PATCH https://<your-lucida>/v1/projects/<project-id>/webhook-sources/<source-id> \
-H "Authorization: Bearer <token>" -H "Content-Type: application/json" \
-d '{"auth":{"mode":"standard","secret":"whsec_..."}}'Creating and changing a source needs a key with connector:write; reading it needs connector:read. A PATCH without secret keeps the stored one, so when Referalli rotates the endpoint secret, send the new one the same way. Deliveries are verified with the Standard Webhooks scheme Referalli signs with (webhook-id, webhook-timestamp in seconds, webhook-signature: v1,..., key = the base64 part of the whsec_ secret, five minutes of skew). The secret is stored envelope-encrypted and never shown again. The operations are in the OpenAPI document under webhook-sources.
One source per event
Lucida drops a repeated event only when it has the same uuid within the project, and in storage also the same event name, distinct_id and UTC day (how dedupe works). Two senders almost never share a uuid, so the same conversion sent twice is counted twice.
Let one source own each event. If your own API already sends referral_converted, do not turn on the Referalli webhook preset for the same conversions. The preset derives the uuid of referral_converted as UUIDv5(namespace, referalli:<event>:<conversion id>), so your API can build the same uuid for the same conversion and Lucida stores it once.
The Referalli preset derives referral_converted's uuid from the conversion itself: UUIDv5 with the namespace 6f1c4a52-9d3e-5b07-8a21-4c7e90b3d5f1 and the name referalli:referral_converted:<commissionId> (commissionId is data.commissionId in Referalli's webhook). Send your own referral_converted with the same uuid and the two collapse into one event (same project, UTC day, event, distinct_id and uuid). Example: commission cme_01JB gives 3fb65c25-3340-55bf-a925-02c45a5dbc2f.
import { v5 as uuidv5 } from "uuid";
const uuid = uuidv5(`referalli:referral_converted:${commissionId}`, "6f1c4a52-9d3e-5b07-8a21-4c7e90b3d5f1");A webhook without data.commissionId falls back to a per-delivery uuid that you cannot reproduce.
If you want to send the event yourself and also keep Referalli connected, use only one of them for referral_converted.
Webhook preset or Referalli's Lucida connector: pick one
Referalli can send conversions to Lucida in two ways. Use one of them, not both, or every conversion is counted twice under two event names.
Lucida's webhook preset (this page): Referalli's
commission.earnedwebhook becomesreferral_convertedon the referred person.Referalli's Lucida connector (referalli.com/docs/lucida): Referalli sends
referalli_referral_createdandreferalli_commission_earnedto Lucida's/v1/batchwith your project key.
The preset puts the conversion on the referred person under one event name and needs no project key stored at Referalli; the connector also records when a referral is created. If you switch, turn the other one off first.
A commission.earned delivery (a referred customer paid, so the partner earned a commission) becomes the event referral_converted on the referred person, with the properties partner_id, partner_external_ref, program_id, referral_id, commission_id, amount_minor and currency. The person is the Lucida distinct id you gave Referalli as the customer's external reference (customerExternalRef, falling back to customerRef), so identify your users with the id you gave Referalli (we recommend the Atlas user id). Sub-affiliate commission lines (level 1 to 5) repeat the same conversion and are skipped; every other topic is acknowledged and ignored. Redelivery keeps the same event uuid.
Payload shape. This follows the Referalli webhook docs: the envelope is {id, topic, orgId, livemode, createdAt, data}, with no type key and no top-level program. Referalli has no separate conversion topic; the conversion is commission.earned, whose data carries commissionId, partnerId, programId, amountMinor, currency, referralId, customerRef, customerExternalRef, partnerExternalRef and level. Subscribe your Lucida endpoint to commission.earned.