Issue and manage referral codes, enforce per-code and per-user limits, track every redemption, and optionally require or apply a code at registration, including OAuth and magic-link signup. Shared links like ?ref=CODE are remembered in the visitor's browser for 30 days and filled in at signup. The tables are still created by PhoenixKit core migrations.
Use it when
- You run an invite or referral program and need to know who brought whom
- Registration should be invite-only, requiring a valid code
What it gives you
- Code CRUD with random generation and an optional beneficiary user
- Expiry dates, per-code usage caps and a per-user code limit
- Usage records and stats per code
- Code field in registration, OAuth and magic-link flows
- Referral link capture (?ref=CODE, first-touch, 30-day TTL)
- Admin section Referrals (Overview, Codes) and Settings > Referrals
Example
{:ok, code} =
PhoenixKitReferrals.create_code(%{
code: "WELCOME",
description: "Welcome promotion",
max_uses: 100
})
Referrals news
-
Referrals 0.8.0: Own migrations and support for PhoenixKit 3
Referrals 0.8.0 takes over its two database tables from PhoenixKit core with its own migration chain and works with PhoenixKit 3.x as well as 2.65 or later.
-
Referrals 0.7.0: Module card limits and a correct unique users count
Referrals 0.7.0 shows the per-user and per-code limits on the PhoenixKit Modules page card and fixes the unique users figure in code usage statistics.
-
Referrals 0.6.2: Earlier code users pass the invite-only gate
Referrals 0.6.2 lets PhoenixKit's invite-only gate see that a user once redeemed a code, so accounts that signed up with a code under 0.4 are recognised.
-
Referrals 0.6.1: Dependency updates only
Referrals 0.6.1 changes no code in the referral codes module. Its locked dependencies move to PhoenixKit 2.2.0, Phoenix 1.8.10 and hackney 4.7.3.
-
Referrals 0.6.0: Requires PhoenixKit 2.0
Referrals 0.6.0 moves the referral codes module to PhoenixKit 2.0. No feature change, but check your database migration level before upgrading.
Install
1
Add to mix.exs
{:phoenix_kit_referrals, "~> 0.8"}
2 Fetch it and run its migrations
$ mix deps.get && mix phoenix_kit.update
3
Switch it on in /admin/modules
- Package
- phoenix_kit_referrals
- Releases
-
- 0.8.0
- 0.7.0
- 0.6.2
- Admin
-
/admin/referral-codes - Links
- HexDocs ↗ GitHub ↗ Changelog ↗
Related modules
What it needs, what builds on it, and its neighbours in Commerce.
Billing
Orders, invoices, subscriptions and payments via Stripe, PayPal, Razorpay, EveryPay
No other modules needed
Bookings
Day/night stays, fixed slots and free-form reservations in one model
No other modules needed
Catalogue
Product catalogues with manufacturers, suppliers, categories, items and pricing
Needs AI, Entities
E-commerce
Products, categories, cart, checkout and shipping, paid through Billing
Needs Billing
Manufacturing
A machines reference book with machine types and a dashboard
Needs Comments, Entities, Locations
Warehouse
Stock per item and location, with receipts, issues, transfers and stocktakes
Needs Billing, AI, Catalogue, Comments, Locations