Referral links and the sign-up code field
Describes Referrals 0.8.0.
New users can bring a referral code in two ways: by typing it on the registration form, or by arriving through a referral link that fills it in for them.
Where to find it
Nothing to open in the admin: this works on the public registration pages once the Referrals module is enabled on the Modules page. Codes are made on Referrals → Codes.
The Referral Code field
With the module on, the registration form shows a Referral Code field. It is marked with a star and must be filled in when Require Referrals is on in the Referrals settings. The magic-link registration page has the same field.
If the code is wrong, switched off, expired or used up, the form shows an error under the field.
Referral links
Share a link to any page of your site with the code added, such as https://example.com/?ref=SPRING (?referral=SPRING works too). When someone opens it:
- the code is remembered in their browser for 30 days, and removed from the address bar;
- if they already have a remembered code, the new link doesn’t replace it, so the first link they followed counts;
- whenever they reach a registration page, the Referral Code field is filled in;
- when they sign up with a social login instead, the code is passed along with it.
From there the code is checked exactly as if they had typed it.
What it doesn’t do
- It doesn’t count clicks on referral links; only a sign-up that used the code is recorded.
- The remembered code lives in the visitor’s browser. Another browser or device, or a private window, starts without it.
- It doesn’t reward the person who shared the link.
For developers
The link capture is a small script the module adds to PhoenixKit’s JavaScript bundle, picked up on the next compile in any host that has run mix phoenix_kit.install or mix phoenix_kit.update. To change how long a code is remembered, set this before the bundle loads:
<script>window.PhoenixKitReferralsConfig = {ttlDays: 14};</script>