I’m pretty sure I’ve seen forum posts about how to do this in the past (although probably more to wo with shopping carts than referral links, although the process is basically the same).
But to briefly summarise, here’s how I do it (no doubt there are other ways).
Firstly, I have datatypes in my database for ‘Referral Link’ which contains data about the actual referral link itself (such as the User who created it, as well as the URL parameter value itself), and also a datatype for ‘User-Ref-Link’ which is a connecting datatype linking a User with a pre-existing ‘Referral Link’, including data like when it was set, when it expires, and the User it relates to etc.
When a new User lands on the page using the ‘Referral Link’ parameter value in the URL, if they are logged in and don’t already have a ‘User-Ref-Link’ for that particular ‘Referral Link’ in the DB, then I’ll simply create a new one for them. If they already have it then I won’t.
If they are not logged in, then I’ll create a new ‘User-Ref-Link’ and save its Unique ID in a cookie on their browser (assuming they don’t already have such a cookie saved). Then if/when they log in I’ll check to see if the logged in User has a ‘User-Ref-Link’ already containing that ‘Referral Link’, and if not I’ll modify the ‘User-Ref-Link’ stored in their cookies to link the the User.
That way I don’t have to keep passing URL parameters from page to page, I wont lose the referral if the user already has an account and I can set the expiry on the cookie to whatever i like, so can keep it valid for more than the 3-day standard Bubble cookie.
Update: here’s a more in-depth explanation of the process from an old thread: How to attach anonymous data to existing user after they log in? - Need help / Database - Bubble Forum