Skip to main content
RapidDev - Software Development Agency
bubble-tutorial

How to build a user referral system in Bubble

A user referral system in Bubble generates unique referral codes per user, tracks when new users sign up using those codes, awards rewards to both the referrer and referee, and prevents fraud with validation checks. This tutorial covers the complete referral flow from code generation to multi-tier reward distribution.

What you'll learn

  • How to generate and store unique referral codes per user
  • How to track referral signups and attribute them correctly
  • How to implement two-sided rewards for referrer and referee
  • How to prevent referral fraud and self-referrals
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Beginner5 min read20-25 minAll Bubble plansMarch 2026RapidDev Engineering Team
TL;DR

A user referral system in Bubble generates unique referral codes per user, tracks when new users sign up using those codes, awards rewards to both the referrer and referee, and prevents fraud with validation checks. This tutorial covers the complete referral flow from code generation to multi-tier reward distribution.

Overview: Creating a User Referral System in Bubble

Referral programs are one of the most cost-effective growth channels. This tutorial shows how to build a complete referral system where users share unique codes, new signups are attributed to referrers, and both parties receive rewards.

Prerequisites

  • A Bubble app with user registration
  • Basic understanding of Data Types and Workflows
  • Familiarity with URL parameters
  • A reward to offer (credits, discount, features)

Step-by-step guide

1

Create the referral data model

Add fields to the User type: referral_code (text, unique), referred_by (User), referral_count (number default 0), referral_credits (number default 0). Create a Referral type: referrer (User), referee (User), status (text: Pending, Completed, Rewarded), created_at (date), rewarded_at (date). Generate referral codes on signup using a Calculate formula with random characters or the User's Unique ID truncated.

Expected result: Users have unique referral codes and referral tracking is in place.

2

Generate referral codes on user signup

In your signup workflow, after creating the user, add a Make changes to Current User action. Set referral_code to a generated code. You can use Calculate: Arbitrary text with a mix of the user's Unique ID first 8 characters. Alternatively, use a random string generator. The code must be unique — use the user's Unique ID prefix as a base since it is guaranteed unique.

Pro tip: Make referral codes short and memorable: 6-8 characters, alphanumeric, case-insensitive.

Expected result: Every new user automatically gets a unique referral code.

3

Build the referral sharing interface

On the user's dashboard or profile, add a Referral section showing their referral code, a shareable link (yourapp.com/signup?ref=CODE), a copy button, and stats (total referrals, credits earned). Create the shareable URL dynamically: your app URL + /signup?ref= + Current User's referral_code. Add social share buttons for Twitter, Facebook, and WhatsApp with pre-filled messages.

Expected result: Users can see and share their referral code via link or social media.

4

Track referral signups and attribute them

On your signup page, check for a ref URL parameter on page load. Store it in a Custom State. After a new user signs up, check if the ref parameter exists and find the referrer: Do a search for Users where referral_code = ref parameter. If found, set the new user's referred_by field to the referrer, create a Referral record (status=Pending), and increment the referrer's referral_count. Add fraud prevention: check that the referee's email is not the same as the referrer's.

Expected result: New signups from referral links are attributed to the correct referrer.

5

Implement the reward distribution

Decide when rewards trigger — on signup (immediate) or after the referee completes an action (verified). For verified rewards, create a backend workflow that checks if the referee has completed the qualifying action (e.g., first purchase, profile completion). When triggered, update the Referral status to Rewarded, add credits to the referrer's referral_credits, and optionally reward the referee too. Send notification emails to both parties. For complex multi-tier referral programs, RapidDev can help design and implement advanced reward structures.

Expected result: Both referrer and referee receive rewards when qualifying conditions are met.

Complete working example

Workflow summary
1REFERRAL SYSTEM WORKFLOW SUMMARY
2=================================
3
4USER FIELDS: referral_code, referred_by (User),
5 referral_count, referral_credits
6Referral: referrer, referee, status, created_at, rewarded_at
7
8ON SIGNUP:
9 1. Generate referral_code = Unique ID first 8 chars
10 2. Check URL param ref
11 3. If ref exists: find referrer by code
12 4. Set referred_by = referrer
13 5. Create Referral (status=Pending)
14 6. Increment referrer's referral_count
15
16REWARD TRIGGER (after qualifying action):
17 1. Find Referral where referee = this user, status=Pending
18 2. Update status = Rewarded
19 3. Add credits to referrer
20 4. Optionally add credits to referee
21 5. Send notification emails
22
23FRAUD PREVENTION:
24 - No self-referral (referee email referrer email)
25 - One referrer per user (referred_by set once)
26 - Rate limit: max 50 referrals per month

Common mistakes when building a user referral system in Bubble

Why it's a problem: Not preventing self-referrals

How to avoid: Check that the referee's email domain and IP address differ from the referrer's. Block same-email referrals.

Why it's a problem: Awarding rewards immediately on signup

How to avoid: Require the referee to complete a qualifying action (first purchase, profile completion) before triggering rewards.

Why it's a problem: Using sequential or guessable referral codes

How to avoid: Use random alphanumeric strings or UUID-based codes that cannot be guessed.

Best practices

  • Generate unique, non-guessable referral codes
  • Require a qualifying action before awarding rewards
  • Prevent self-referrals by checking email and IP
  • Track referral status through a clear lifecycle (Pending, Completed, Rewarded)
  • Show referral stats prominently on the user dashboard
  • Make sharing easy with copy buttons and pre-filled social share links
  • Set a monthly referral limit to prevent abuse

Still stuck?

Copy one of these prompts to get a personalized, step-by-step explanation.

ChatGPT Prompt

I need a user referral system in Bubble.io with unique codes, referral tracking, two-sided rewards, and fraud prevention. Can you design the data model, signup attribution workflow, and reward distribution logic?

Bubble Prompt

Build a referral system for my app. Generate unique referral codes per user, track signups from referral links, award credits to both referrer and referee after qualifying actions, and prevent fraud.

Frequently asked questions

How do I handle referral links on mobile?

URL parameters work on mobile browsers. The ref parameter persists through the signup flow. For app deep links, store the referral code in local storage.

Can I implement multi-tier referrals?

Yes. Add a referred_by chain. When User C signs up via User B who was referred by User A, award a smaller bonus to User A. Track depth with a referral_level field.

What rewards work best for referrals?

Credits, free months of service, or feature unlocks work well. Two-sided rewards (both parties get something) have the highest conversion rates.

How do I track referral conversion rates?

Compare Referrals created vs Referrals with status=Rewarded. Display this on an admin dashboard with charts showing referral performance over time.

Can I integrate with referral platforms like ReferralCandy?

Yes. Use the API Connector to sync referral data with external platforms. However, building it natively in Bubble gives you full control and avoids third-party costs.

Can RapidDev help build advanced referral programs?

Yes. RapidDev can build multi-tier referral systems, affiliate networks, referral analytics dashboards, and automated fraud detection.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.