How to Reward Invited Users in a Referral Campaign
This guide will walk you through the process of rewarding users who join a campaign through a referral link and code using our dashboard feature.
Step 1: Prepare the Prerequisites
First, you need to create a main campaign. This will be the campaign that users will refer their friends to. Follow these steps to create a main campaign: How to Create a Campaign.
Next, create a referral campaign and add the main campaign in step 1. For more details, refer to: Configure the Referral Campaign.
Lastly, set up the Leaderboard App. The Leaderboard App displays the users and the points they have earned in any campaign. In this guide, we will set up a leaderboard for both the main and referral campaigns. For more details, refer to: Configure the Leaderboard App.
Step 2: Set up an Off-chain task to setup the referral reward
In the main campaign created in step 1, you can set up an off-chain task that rewards users who join the campaign through a referral link or code.
Add an Off-chain Task in Main Campaign
Learn how to create an off-chain task: Off-Chain Task Guide.
For example, you can name the task: Used an Invite Code? Claim 20 XP!
Use Referral Stats API
For the API input, use the referral stats API. It gives you the referral details of users who joined through a link or code.
Setup Expression
In the expression field, add the following expression:
function(response) {
if(response.referredBy && response.referredBy.code.length > 0) {
return 1;
} else {
return 0;
}
}
Step 3: Add XP task and trigger to this Off-chain Task
Add an XP App and its trigger to the off-chain task from step 2. Learn how here: XP Reward App.
Step 4: Save and Submit your campaign
After setting up the off-chain task, save and submit your campaign. The users who join the campaign through a referral link or code will be rewarded with the XP points you have set up in the off-chain task.