You’re going to need a few things
A way to drop cookies (local storage plug-in)
Browser Cookies Plugin | Bubble
A random generated string or unique Id
that appends to the end of your URL I’d call this something like “ref” (gets saved to the profile of the user) you will use this as a URL param.
A data field inside user for long term tracking of who referred them. Referring user - data type = user
data type “cookies” (expire date, cookie value)
Data field inside your user for referrals (list of “cookies”)
A workflow for on page load when URL parameter “ref” is not empty and the cookie type you drop is not detected
(Action 1) Create a cookie on the visitors browser
(Action 2) Create new cookie (results from step 1)
(Action 3) Make changes to Do search for user ref = url parameter ref value.
Add cookie to list referral in that user
A workflow for on page load when and the cookie type you drop is detected
(Action 1) delete old cookie
(Action 2) drop new cookie
(Action 3) Create a new cookie
(Action 4) Same as action 3 in last workflow.
(This is to ensure your browser cookies don’t expire after 30 days or so like many browsers do)
Now for long term tracking of who referred and signup tracking.
In your signup flow
Only when cookie is not empty and do search for cookies (current cookie) is not empty and do search for cookies (current cookie) first item expiration date > current date and time.
(Action 1) make changes to current user : data type referring user = do search for users referrals list of referrals contains current cookie. (Save the referring user to the user that just signed up)
Now for purchases
Make a data type for referring purchases.
when current user referring user is not empty
(Action 1) normal payment flow.
(Action 2) Create new referring purchase (amount, date, affiliate commission %, buying user, referring user)
(Action 3) add referring purchase to a data type list in the referring user called list of referring purchases.
(Action 4) payout with stripe, PayPal, or whatever API your using.