Dynamic Referral App
This guide provides a step-by-step walkthrough for setting up and customizing the Dynamic Referral App. This app allows you to create a referral with custom reward distribution based on various factors that can affect the rewards earned.
Step 1: Create a Main Campaign
Start by creating a new campaign that users will refer to. This will be your main campaign. You can follow our guide on How to launch a campaign to learn more about this process.
Step 2: Add the Dynamic Referral App
On the left panel you will see the Referral option. Click on it and select the "Points - Dynamic" option.
Step 3: Configure the Dynamic Referral App
The Dynamic Referral App can be customized in any way you want, based on the logics you want to implement. For example, you can set a multiplier for the points earned based on the no.of referrals, or you can set a fixed reward for the first 10 referrals and then a different reward for the next 10 referrals or any other custom logic you want to implement.
Let's take an example where you want to reward users based on the number of referrals they make and multiplier for each referral.
We will be using this logic for the Dynamic Referral App:
Referral Tiers and Multipliers
Number of Referrals | Point Multiplier |
---|---|
1-3 | 2x |
4-6 | 3x |
The basic point for each referral is 10 points. User can also earn more points based on the multiplier which is set based on the number of referrals as shown in the table above.
Endpoint Configuration
Use the following endpoint to configure the Dynamic Referral App: https://sdk-api-qa-kxwxwe233q-as.a.run.app/apps/referral/439/{WALLET_ADDRESS} (opens in a new tab)
Expression Configuration
Now implement the above logic using this expression:
function (response) {
const xp = 10;
let multiplier = 1;
if (response && response.totalInvites) {
const totalInvites = response.totalInvites;
switch (true) {
case (totalInvites >= 1 && totalInvites <= 3):
multiplier = 2;
break;
case (totalInvites >= 4 && totalInvites <= 6):
multiplier = 3;
break;
default:
multiplier = 1;
}
}
return xp * multiplier;
}
API Method and header
- Select
GET
API method. - For API Header use
X-API-KEY: {API_KEY}
How does it work?
The endpoint responds with stats on referrals, including a totalInvites
field. This field is retrieved by the backend and fed into the expression. Within this expression, the totalInvites
count determines the multiplier to be applied. Based on this multiplier, the points to be awarded to the user are calculated.
Step 3: Save and Submit your campaign
After configuring the Dynamic Referral App, click on the "Save changes" button to finalize your setup. The referral campaign is now ready to be rolled out.