Skip to main content

Affiliate Tracking Script

The caBRAPI clicks.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

  1. The affiliate shares a link like https://sualoja.com/?ref=CODIGO
  2. The visitor accesses the link
  3. The script detects ?ref=, saves the affiliate_id cookie and sends the click to the API
  4. Even if the visitor browses to other pages without ?ref=, the cookie keeps attributing visits to the affiliate
  5. 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

The script detects the affiliate by any of these formats: The affiliate code must be between 2 and 64 characters (letters, numbers, _ or -).
  • 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 the affiliate_id cookie at payment time: