Affiliate Tracking Script
The caBRAPIclicks.js script tracks affiliates’ clicks and visits to your store. When a visitor accesses with ?ref= in the URL, the script registers the click and saves the affiliate code in a cookie for future attribution.
How it works
- The affiliate shares a link like
https://sualoja.com/?ref=CODIGO - The visitor accesses the link
- The script detects
?ref=, saves theaffiliate_idcookie and sends the click to the API - Even if the visitor browses to other pages without
?ref=, the cookie keeps attributing visits to the affiliate - If the visitor makes a purchase, checkout sends the affiliate code for commission
Installation
Add the script before</body> in your HTML page:
Parameters
Complete example
Accepted link formats
The script detects the affiliate by any of these formats:
The affiliate code must be between 2 and 64 characters (letters, numbers,
_ or -).
Cookie
- Name:
affiliate_id - Duration: 30 days (or the value defined in
data-days) - Property:
SameSite=Lax,path=/ - The cookie is updated whenever a new
?ref=is detected
Checkout (purchase attribution)
For checkout to attribute the purchase to the affiliate, read theaffiliate_id cookie at payment time: