Links and click tracking
Make tracked links, count clicks, and see which page earned each commission.
The API has its own redirector. A visitor clicks a link of yours. The redirector saves the click and sends the visitor to the network. When the visitor buys, the conversion comes back with the same click ID. So you know which link, which page and which SubID earned the commission.
How it works
- You make a link for a program. The API gives you a short URL, for example
https://afffast.link/k3Xa9Qz. - A visitor opens the short URL. The redirector saves the click and sends a
302redirect to the page of the advertiser, through the tracking of the network. - The redirector puts our click ID in a SubID slot of the network. The click ID has 12 characters.
- The network reports the conversion with that SubID. The sync joins the conversion to the click. The conversion gets
click_id,user_subidsandclick_context(site, page, referrer, country and device).
A bot, a prefetch request and a HEAD request get the redirect and no click. Redirects never stop when you reach a limit of your plan.
A network with no SubID slot cannot join a conversion to a click. Read capabilities.subid_slots of the network with GET /v1/networks/{id}.
Make a saved link
A program needs a deeplink template (deeplink_support: true). The host of the destination must be on a domain that the program allows. You need the scope links:write.
curl -X POST https://api.afffast.com/v1/links \
-H "Authorization: Bearer $AFFFAST_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"program": "prog_...",
"destination": "https://shop.example/products/boots",
"site": "site_...",
"subids": { "s1": "blog-post-12" }
}'The response has url, the short URL that you share. The code of the link has 7 or 8 characters.
subidsare your own labelss1tos5. A value has 255 characters at most. The redirector stores them with the click. It sends them to the network when the network has a slot for them.active: falsepauses the link. A paused link does not redirect.POST /v1/links/batchmakes up to 100 links. It returns the results in the order of the items.- Read the clicks of a link with
GET /v1/links/{id}?include_clicks=true.
Errors that you can get: program_deeplinks_unsupported and link_destination_not_allowed.
Make a deeplink without saving it
POST /v1/deeplinks makes up to 100 deeplinks in one request. By default the API saves nothing. Each item gives a signed URL: <redirector>/r?p=...&u=...&sig=.... Use "save": true to save the link and get a short URL (this needs the scope links:write too). You need the scope deeplinks:write.
The API checks each item alone. An item that is not valid has an error in its result. The other items still succeed.
Track the page
The page of a click is the value of the query parameter page of the link, or the Referer header when the link has no page. Add the parameter to the link when you know the page and the referrer is not sent:
https://afffast.link/k3Xa9Qz?page=https://blog.example/boots-reviewThe redirector normalizes the page. It removes the fragment, the slash at the end of the path and all query parameters except utm_*. So all clicks from one article have one page value.
Read the clicks and the revenue
GET /v1/clickslists the clicks, newest first. Filter bylink,program,site,country,deviceand time. It needs the scopeclicks:read. The API keeps raw clicks for 13 months.GET /v1/stats/clickscounts the clicks. Usegroup_bywithday,week,month,country,deviceorlink.GET /v1/stats?group_by=pageshows the revenue of each page.group_by=subidshows the revenue of each SubID. Choose the slot withsubid_slot. A conversion with no click is in the groupunattributed.- Bot clicks are not counted. Use
include_bots=trueonGET /v1/clicksto see them.
Listen to the event click.attributed with a webhook to know when a conversion is joined to a click.
Test the attribution
Use a test key. Make a test link and open it. Then send POST /v1/test/conversions with the click_id of the click. The conversion goes through the same join as a conversion of a sync. See Test mode.