Fuul
  • INTRO
    • ⚑What is Fuul?
    • πŸ’ͺWhy use Fuul?
    • πŸ€”Use Cases
    • βš™οΈIntegration
    • πŸ”—Main Links
  • HOW IT WORKS
    • πŸ’ΈTypes of Rewards
    • βœ…Conversion Events
      • 1️⃣CLAMM LPs (e.g. Uniswap V3)
      • 2️⃣Constant LPs (e.g., Uniswap V2)
      • 3️⃣Lending & Borrowing
      • 4️⃣Staking
      • 5️⃣Token Holders
      • 6️⃣Custom Onchain Events
      • 7️⃣Custom Offchain Events
  • πŸ€‘Incentive Payouts
    • πŸ—ΏFixed Rewards
    • 🌊Variable Rewards
    • πŸ’°Pool Distribution
  • πŸ§‘β€πŸ€β€πŸ§‘Referrals
  • ♾️Attribution Methods
  • πŸ’²Budgets
  • ⚑Fuul Incentives Manager
  • πŸŽ–οΈLeaderboards
  • πŸ’»Incentives Hub
    • πŸ‘¨β€πŸ’»White-Label Implementation
    • πŸ‘No-Code
  • FOR DEVS
    • ⭐Getting started with Fuul Web SDK
    • βš™οΈSending Custom Events through the API
    • πŸ“„Tracking referrals in your app
    • πŸ‘¨β€πŸ’»API Key Management
    • πŸ› οΈBuilding your incentives hub in your app (white-label)
      • ℹ️Getting all incentives information
      • πŸ”—Creating affiliate links or codes
      • πŸ’―Getting Leaderboard Data
        • πŸͺ™Tokens
        • 🌟Points
      • πŸ™‹Getting Individual Rewards
        • πŸͺ™Tokens
        • 🌟Points
      • πŸ€™Claiming Onchain Rewards
    • πŸ”§Building widgets
    • πŸ“’Managing Audiences and Segments
      • πŸ‘€Getting User Audiences using Fuul SDK
      • πŸ‘₯Updating Audience Segments using Fuul API
    • ✈️Migration from older SDK versions
    • πŸ†˜Troubleshooting
  • PROTOCOL
    • ⛓️Smart Contracts
    • 🧡Subgraphs
  • Guides
    • ✏️Getting Started
      • Creating Your First Incentive Program
      • How to Add a Budget in Fuul
  • 🏁Creating Triggers & Conversions
    • Understanding Triggers Types
    • Creating an Event with CSV file
  • 🎨Program Incentive Page
    • Building no code landing pages
  • πŸ“ŠAnalytics
    • Understanding Sybil Detection
Powered by GitBook
On this page
  • Pageview event
  • Connect wallet event
  1. FOR DEVS

Tracking referrals in your app

This guide shows how to send event data through the Fuul Web SDK

PreviousSending Custom Events through the APINextAPI Key Management

Last updated 17 days ago

For Fuul to attribute conversion events to your visitors, you'll need to report the pageview and connect_wallet events.

You can find an example of two landing pages (one for creators and another one for end users) with the Fuul SDK integrated using next JS and RainbowKit in

Pageview event

Projects must send this event every time a user visits a page on their website. This should be implemented on all pages of the site.

import { Fuul } from ('@fuul/sdk');

await Fuul.sendPageview();

The Fuul SDK will get the parameters from the URL once a user enters the site. There is no need to persist these parameters when navigating through the app.

Connect wallet event

Projects must send this event every time users connect a wallet to their website (both when connecting a wallet for the first time and when changing wallets during the session).

For this type of event, projects must send the user address that is being connected to the website along with the signature and signed message as arguments.

import { Fuul } from ('@fuul/sdk');

await Fuul.sendConnectWallet({
  address: "0x12345",
  signature: "0x123485090123",
  message: "Accept affiliate on 18-Aug 2023 00:00:00",
});

For smart contract accounts, the accountChainId must be added as follows:

import { Fuul } from ('@fuul/sdk');

await Fuul.sendConnectWallet({
  address: "0x12345",
  signature: "0x123485090123",
  message: "Accept affiliate on 18-Aug 2023 00:00:00",
  accountChainId: 1
});

The following networks are supported for smart contract wallets:

  • Mainnet

  • Arbitrum

  • Optimism

  • Polygon

  • Base

  • zkSync Era

  • BNB chain

  • Fantom

  • Avalanche

  • Mode

  • Abstract

Sending event through the API

If you are sending the connect wallet event from the backend, you will have to use the API following this pattern:

import requests

url = "https://api.fuul.xyz/api/v1/events"

payload = {
    "metadata": {
    	"tracking_id": "abc123"
    },
    "name": "connect_wallet",
    "user_address": "0x12345",
    "signature": "0x123485090123"
    "signature_message": "Accept affiliate on 18-Aug 2023 00:00:00",
    "account_chain_id": 1 # Only for smart contract wallets
}

headers = {
    "content-type": "application/json",
    "authorization": "Bearer my-fuul-key"
}

response = requests.post(url, json=payload, headers=headers)

In this case, you will need to get the fuul.tracking_id from the browser's local storage. Remember that it must be the same one that was sent on the pageview event.

Message & Signature

Fuul allows two different types of signatures.

In the case of typed data signatures, the payload should be the following:

import { Fuul } from ('@fuul/sdk');

const typedData = {
    address, domain, types, primaryType, message
}

await Fuul.sendConnectWallet({ 
    address: '0x12345',
    message: JSON.stringify(typedData),
    signature: '0x123485090123',
});

Requiring users to sign a message ensures event validity and disclosure to the user. This is mandatory as it prevents attribution fraud.

To validate regular signatures we use and in the case of typed data signatures, we use .

πŸ“„
this repo
Viem verifyMessage
Viem verifyTypedData