I would like to add referral program to my website. The user is taken from some other page to my homepage with referral url parameter like:
www.example.com?referral=refCode
The thing is, the only time I care about the referral code is at the signup page.
www.example.com/signup
Is there a way to retain the referral code through user journey on my website?
I solved the issue using cookies. Spring Boot provides easy access to cookie operations as described for example in this article.
When an user reaches my home page, I check for the referral parameter and if it exists, I store it in the cookie. I set cookie expiry date for 14 days for example. In the POST controller for the sign-up, I check their cookie and if it contains the referral info, I store it in the DB for the user.