In this episode, we focus on jazzing up our referral page so it's not just a boring code dump anymore. First, we set up a new view for displaying the referral, sticking it outside of the main account area so it feels more welcoming to guests. We use a guest layout rather than an authenticated one, since usually referral links are for users who aren't signed in yet.
On the referral page, instead of just showing the code, we let new users know who referred them—"You've been referred by Alex"—and dress things up with some basic styles to make it look tidy. There's also a call-to-action button encouraging users to sign up and grab their reward (like 20% off). We prep the form, remembering to add a CSRF token for security.
The key functionality here is that, every time someone lands on this referral page, we increment a visits
count in the database for that referral code. A quick check in the DB shows the number ticking up as expected whenever we refresh—so it's easy to keep track of how many people have landed on the referral.
All set! The page now looks friendly, tells visitors who sent them, and is accurately tallying how many have dropped by via referral.