Tracking Flow

When a visitor arrives through a referral link (e.g., https://yourdomain.com?fpr=joe13, where fpr is the affiliate’s Referral ID parameter and joe13 is the value), retrieve the referral link token (Referral ID) from the referral link, store it in the browser’s localStorage or as cookie for later use.

The available query parameters are ?fpr, ?via, ?fp_ref, ?deal, ?ref, ?_from, ?_by, ?_go .

<script>
// Function to store referral link token in localStorage
function storeReferralLinkTokenInLocalStorage(referralLinkTokenParam) {
    // Get URL parameters
    const urlParams = new URLSearchParams(window.location.search);
    const referralLinkToken = urlParams.get(referralLinkTokenParam.replace("?",""));

    if (referralLinkToken) {
        localStorage.setItem('_fprom_ref', referralLinkToken);
    }
     else{
        console.log(`No such query parameter '${referralLinkTokenParam.replace("?","")}' or '${referralLinkTokenParam}' found in ${window.location.search}`);
    }
}

// Call the function to store the Referral ID/token when the page loads by passing the query parameter.

storeReferralLinkTokenInLocalStorage('fpr');
</script>

II. Retrive referral ID/token


<script>
// Function to retrieve referral ID/token stored in localStorage
function getReferralLinkToken() {
    return localStorage.getItem('_fprom_ref');
}

// Call the `getReferralLinkToken` function whenever you want to get referral ID/token on any of the pages.

var ref_id = getReferralLinkToken();
</script>

2. Lead/Referral tracking

When a visitor signs up or fills an opt-in form, convert them to a referral by using the track/signup endpoint.

You can send only the email or only the uid or both. You need to ensure that the actual visitor data is passed in the API call.

curl --request POST \
  --url https://v2.firstpromoter.com/api/v2/track/signup \
  --header 'Account-ID: <account-id>' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
	  "email": "[email protected]",
	  "uid": "cus_000001",
	  "ref_id": "joe13",
	  "skip_email_notification": true
}'

3. Sales Tracking

If you are using Stripe, Chargebee, Braintree, Paddle or Recurly we can track sales automatically on our end. You will only need to connect your billing provider to FirstPromoter.

If you use any other billing provider, you will need to track sales using the tracking API. For more information on sales tracking API, see documentation here.

When a sale event is received, FirstPromoter will automatically:

  • Identify the corresponding affiliate to assign the sale to.
  • Assign the corresponding reward/commission to the promoter.

With this in place, you have completed the basic tracking flow. From storing and retrieval of affiliate referral link token (Referral ID) through to assigning the corresponding commissions to the affiliates.