How to Build a SaaS Referral Program in Bubble.io
Referral programs are the cheapest acquisition channel in SaaS. Customers who sign up through referrals convert better, churn less, and spend more. This guide covers the complete data model, referral tracking flow, and reward system built entirely in Bubble.
The Economics of a Referral Program
A customer who signs up through a referral converts at 3–5× the rate of paid traffic, churns at half the rate, and has a 16% higher lifetime value. Every SaaS that reaches product-market fit should have a referral program — not as a growth hack, but as a structural acquisition channel that compounds over time. Building one in Bubble takes less than a week and requires no third-party tools.
The Referral Data Model
How the Referral Program Works End-to-End
Create ReferralCode:
workspace = new Workspace
code = random 8-char alphanumeric (Toolbox plugin)
created_by = Current User
is_active = yes
Update Workspace:
referral_code = new ReferralCode
Display the referral link prominently in Settings and onboarding: yourapp.com/signup?ref=ABC123. One-click copy button using the Clipboard plugin. Show the referral dashboard: how many signups used the code, total rewards earned, credit balance.
On page load: Store ref code in custom state
On workspace creation:
Only when: ref code state is not empty
Find ReferralCode [code = ref state, is_active = yes]
Update Workspace: referred_by = found ReferralCode’s workspace
Create Referral: code=found, referred_workspace=new, status=Pending
On checkout.session.completed webhook: find any Referral where referred_workspace = this workspace and status = Pending. Set status = Converted, reward_credited = yes. Create Credit records for both referrer and referee. Update ReferralCode’s times_used and total_earned. Update both Workspace credit_balance fields.
Reward on First Payment, Not on Signup
Only credit rewards when the referred workspace makes their first real payment. Rewarding on signup creates fraud — people create fake accounts purely to farm referral credits. First paid invoice is the correct trigger, verified via the Stripe webhook, not the user’s self-reported action.
Ready to Build on Bubble?
Architecture, data model design, Stripe billing, and full SaaS builds — done right from day one.
