There are three pieces to wire up. All three are optional in the sense that Smler works without them, but each one you skip is attribution you are leaving on the table.
Before any of this: attribution needs a domain of your own (Branded Domains), and it needs to be turned on for that domain from the Attribution page. Once it is on, the Connect your site tab has a live checklist that tracks all three steps below in real time, with your exact site key already filled into every snippet.

Step 1: add the snippet
Paste this into the <head> of every page on your site, including checkout and any thank you page:
<script async src="https://yourdomain.com/api/v2/attribution/sm.js?key=sm_pk_..."></script>Use the exact snippet shown on your Connect your site tab, it already has your real site key in it. The script binds an attribution id to the visitor's browser the moment it loads, and sets a first party cookie when the domain the script is loaded from matches your link domain, which is what gets you the full 400 day window instead of the 7 day cap some browsers put on script written cookies.
Loading any page once after this step is enough for the checklist to flip green by itself, usually within a few seconds.
Step 2: identify visitors
Call this the moment you know who someone is: on signup, on login, or when they type their email at checkout.
sm.identify({ email: user.email, externalId: user.id })This is the piece that makes long window attribution actually work. A visitor cookie can be cleared, or the purchase can happen on a different device or browser entirely. Once you have identified them once, a later purchase can still be matched back to the original click through the hashed email or external id, not just the cookie. Emails are hashed before storage, Smler never keeps the plain address.
Step 3: send purchases from your server
Revenue is only ever trusted when it comes from your server, never the browser, so this call has to happen from your backend, in the handler that runs after a payment succeeds.
curl -X POST https://yourdomain.com/api/v2/conversion/track/sale \
-H "x-code: <your api key>" \
-H "Content-Type: application/json" \
-d '{
"domain": "yourdomain.com",
"customerExternalId": "<your user id>",
"customerEmail": "<their email>",
"amount": 4999,
"currency": "usd",
"invoiceId": "<order id>",
"smid": "<value of the sm_id cookie, if you have it>"
}'Forward the sm_id cookie as smid whenever your frontend has access to it, that is the strongest signal and gets ranked first. If you cannot get the cookie to your server, sending customerExternalId or customerEmail alone still works, Smler falls back to whatever it already knows about that identity.
Only pass domain if the request is coming from a shared backend that serves more than one attribution domain. Omitting it is fine for a single domain account, but on a multi domain account it silently falls back to the oldest one, which is wrong and unattributed for every other domain.
If you would rather not write this call at all, connecting your payment processor on the Integrations tab does the same thing with no code.
Handing this off
The Connect your site tab has two buttons that save you from retyping any of this:
Copy instructions for a developer, a plain text version of the three steps above with your real site key and domain filled in, ready to paste into a message.
Copy prompt for agent, the same three steps rewritten as a task for a coding agent (Claude Code, Cursor, and similar), telling it where each piece typically belongs in a codebase instead of just handing it the code.
Getting credit to a specific creator
None of the above mentions creators directly, because it does not need to. Any link visited with a ?ref=<name> query parameter automatically tags every click, and later every sale, with that creator's name. The easiest way to hand these out is the Campaigns tab, which generates one per influencer for you.
Next
For the raw HTTP endpoints behind all of this, including the ones the snippet calls for you, see the API Reference.
Published with LeafPad