π―Referral Program with Token Rewards
Build a complete referral program where affiliates earn token rewards for each user they bring to your platform. By the end, you'll have tracking links, wallet attribution, a leaderboard, and a claiming flow.
Prerequisites
A Fuul account with a project created
Conversion events and payout rules configured in the dashboard
A funded budget (see How to Add a Budget)
Two API keys:
send:tracking_event(frontend) and optionallysend:trigger_event(backend)
Step 1: Install and initialize the SDK
npm install @fuul/sdkimport { Fuul } from '@fuul/sdk';
Fuul.init({ apiKey: 'your-send-tracking-event-key' });Step 2: Track referral visits
Call sendPageview on every page load. The SDK captures the referrer's affiliate code from the URL (?af=code) automatically.
import { useEffect } from 'react';
import { Fuul } from '@fuul/sdk';
function App() {
useEffect(() => {
Fuul.sendPageview();
}, []);
return <YourApp />;
}Step 3: Identify users on wallet connect
When a user connects their wallet, call identifyUser to link their wallet to the tracking session:
Step 4: Let affiliates create tracking links
Give affiliates a way to generate their referral links:
Affiliates can also create custom branded codes:
See Affiliate Links & Codes for the full API.
Step 5: Display the leaderboard
Show top affiliates ranked by token earnings:
See Leaderboard Data for points and volume leaderboards.
Step 6: Show individual rewards
Display a specific user's earnings:
See Individual Rewards for history and per-conversion breakdowns.
Step 7: Add claiming
Let users claim their token rewards onchain. The full implementation involves fetching signed claim checks and submitting a contract transaction:
Show claimable balances β Claim Flow Integration
Fetch claim checks β Get Claim Checks
Submit the transaction β EVM Claiming, SVM Claiming or Stellar Claiming
Next steps
Add referral codes (user-generated, permanent attribution)
Enable multi-level referrals
Target specific user segments
Get notified on payouts
Add fraud prevention
Last updated