Skip to content

Referrals 0.3.0: Referral links with ?ref=CODE

Referrals 0.3.0 adds shareable referral links. A link like https://yoursite.com/?ref=CODE to any page of the site remembers the code in the visitor’s browser and fills it in when they register later, so nobody has to type it.

How a referral link works

The module now ships a small script that runs on every page. When the address has ?ref=CODE (or ?referral=CODE), it saves the code in the browser’s local storage for 30 days and removes the parameter from the address bar. The first code wins: while a saved code is still valid, a later link does not replace it.

When the visitor reaches the registration or magic-link registration page, the script fills the existing referral code field if it is empty. On social sign-in links (Google, Apple, GitHub, Facebook) it adds the code to the link. From there PhoenixKit handles the code as if the visitor had typed it.

To keep codes for a different number of days, set window.PhoenixKitReferralsConfig = {ttlDays: 14} before the script bundle loads.

Upgrading

No migration and no core change. The script reaches the site through PhoenixKit’s module script bundle, so a site that has run mix phoenix_kit.install or mix phoenix_kit.update before picks it up on the next compile. If local storage is blocked in a browser, nothing is saved and the visitor can still enter the code by hand.

Full release notes: Referrals 0.3.0

0.3.0 · 5 July 2026

Added

  • Referral link capture via URL query param. Share https://yourapp.com/?ref=CODE (?referral=CODE also accepted) — a client-side script (shipped via js_sources/0, the same mechanism phoenix_kit_crm uses) stores the code in the visitor’s localStorage for 30 days (first-touch attribution, configurable via window.PhoenixKitReferralsConfig = {ttlDays: N}) and strips the param from the address bar. At registration, magic-link registration, or OAuth sign-in (Google/Apple/GitHub/Facebook), the stored code auto-fills the existing referral_code field or is appended to the OAuth link — using fields/links PhoenixKit core already renders and reads server-side, so no core changes are required.

Referrals 0.3.0. Install or update: {:phoenix_kit_referrals, "~> 0.3"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.