/bubble-tutorials

How to build an affiliate system in Bubble

Learn how to build a powerful affiliate system in Bubble, from tracking referrals to automating payouts, with this clear step-by-step guide.

Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web or mobile app? RapidDev builds Bubble apps with your growth in mind.

Book a Free Consultation

How to build an affiliate system in Bubble

A simple and reliable affiliate system in Bubble works by generating a unique referral URL for each user, storing who referred whom, and triggering backend workflows to record commissions whenever a referred user performs a qualifying action (like making a purchase). Bubble already has everything you need: URL parameters, database fields, backend workflows, and Privacy Rules. No plugins required.

 

Core Structure

 

You create a User field like referral_code (text) and generate a unique code on signup. Then you detect a URL parameter like ?ref=abcd123 when a new visitor arrives. If they sign up, you store the referring user inside a field like referred_by (User). Later, when the referred user pays or completes an action, a backend workflow creates a Commission entry linked to the affiliate.

  • Referral Code: text stored on User
  • Referred By: User field on User
  • Commission: Thing with fields like amount, affiliate (User), referred\_user (User)

 

Generating and Using Referral Links

 

On signup, set User referral_code = Generate random string. To show users their affiliate link, combine your site URL with ?ref=Current User's referral_code. When any visitor lands, use Get data from page URL (parameter: ref) and store it temporarily in a referral\_code field in a state or cookie-equivalent (Bubble stores it until signup as long as you save it in a custom state or Option Set).

 

// Example backend workflow trigger
// When a new User is created:
Only when This User's referred_by is not empty:
Create a new Commission:
    affiliate = This User's referred_by
    referred_user = This User
    amount = 0 // will be updated after payment

 

Tracking Purchases for Commissions

 

If you use Stripe, set a webhook to a Bubble backend workflow. When payment succeeds, look up the paying User, check referred\_by, and create or update a Commission. This avoids front‑end manipulation and keeps logic secure.

  • Stripe webhook → Bubble backend workflow endpoint
  • Search for User by Stripe customer ID
  • If User’s referred\_by is not empty → create Commission

 

Security and Privacy

 

In Privacy Rules allow users to see only commissions where affiliate = Current User. Never calculate commissions on the front end. Always do it in backend workflows so users cannot spoof amounts.

&nbsp

Explore More Valuable No-Code Resources

How to integrate Bubble.io with Git?

Learn how to seamlessly integrate Bubble.io with Git through our comprehensive step-by-step guide. Perfect for beginners and professionals.

Explore

How to integrate Bubble.io with Reddit Ads?

Learn how to seamlessly integrate Bubble.io with Reddit Ads using our easy step-by-step guide. Boost your ad management today!

Explore

How to integrate Bubble.io with AWS S3?

Explore our step-by-step guide on integrating Bubble.io with AWS S3, making your app development process more efficient and secure.

Explore

How to integrate Bubble.io with Lucidchart?

Follow our step-by-step guide to seamlessly integrate Bubble.io with Lucidchart, enhancing your workflow & productivity.

Explore

How to integrate Bubble.io with Kentico?

Learn how to seamlessly integrate Bubble.io and Kentico with our comprehensive, easy to follow step-by-step guide.

Explore

How to integrate Bubble.io with Box?

Discover easy-to-follow steps for integrating Bubble.io with Box. Boost your workflow and secure your files seamlessly today.

Explore

Stuck in Bubble.io? We’re here to help!

Fix broken workflows | Optimize logic | Boost performance | Scale with confidence

4.9
Clutch rating 🌟
600+
Happy partners
17+
Countries served
190+
Team members

By clicking “Accept”, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts. View our Privacy Policy for more information.

Cookie preferences