Which one to use
Record a click
Everything else is optional context, stored on the click and surfaced in your reporting:
fullLandingUrl, pathname, queryString, the UTM fields (utmSource, utmMedium, utmCampaign, utmTerm, utmContent), the ad click IDs (gclid, gbraid, wbraid, fbclid, msclkid, ttclid, twclid, liFatId), your own extClickId, referrer fields (documentReferrer, referrerDomain, referrerType), device fields (userAgent, browserName, browserVersion, osName, osVersion, deviceType), screen fields (screenWidth, screenHeight, colorDepth, pixelRatio, viewportWidth, viewportHeight), and language (language, languages).
IP address and geolocation are not accepted from the body. Referly reads them from the request itself, so a click recorded from your server carries your server’s location rather than the visitor’s — worth knowing before you move click recording off the browser.
Response
click.id is the click ID. Store it — as a string — against the visitor’s session and then their user record.
When the referral code doesn’t belong to any affiliate in the program, the response is { "exists": false } with a 200. There is no error status: a bad code is treated as “nothing to track” rather than a failure. Check for the click key rather than the status code.
See click data for everything a click stores, and external click IDs for how
extClickId connects Referly to an ad network or partner.Capture an email
Response
404 with Affiliate not found means the affiliateId matched neither a click nor a link in that program. 400 means a required field was missing.
Calling this twice for the same person doesn’t create two customers — the referral is matched on email within your program. What it will not do is move an existing customer to a different affiliate. First attribution wins.
Capture a sale
createPushLapSale() calls from the browser.
Response
Record an add-to-cart
Response
externalEventId that Referly has already stored for that source returns { "ok": true, "id": 5512, "deduped": true } instead of creating a second event. This is the one capture endpoint that is safe to retry — and only when you send externalEventId.
400 means programId or clickId was missing or malformed; 404 means the click doesn’t exist in that program.
Read your program’s tracking config
{ "exists": false } comes back for an unknown program ID, and also when the account behind it has no active subscription. Responses are cached for a day, so a settings change can take that long to reach a cached response.
Calling these from your own code
Reasonable uses:- A mobile app. Record the click when someone opens a referral deep link, keep the click ID with the account, then report purchases through the API.
- A platform that won’t let you inject scripts. Post the click yourself from wherever you can run code.
- A redirect service of your own. Record the click as you redirect, then hand the click ID on to your site.
- Recording a click server-side loses the visitor’s context. The IP and location come from whatever machine makes the request, and the browser and device fields are only as good as what you pass in.
- Store the click ID, not the referral code. A click ID ties everything to one specific visit; a code only identifies the affiliate.
- Treat
200with{"exists": false}as a failure. It means the code matched no affiliate. - Don’t record money here if the call can repeat. Only
add-to-cartdeduplicates, and only withexternalEventId.
Related
Report a sale
The authenticated way to record revenue.
JavaScript API
The browser helpers that wrap these endpoints.
Click data
Everything a click record holds.
Idempotency
Why retries need an external identifier.