Skip to main content
Difficulty: Intermediate
Developer Required: Yes
If your app uses Supabase Auth, track the referral right after Supabase creates the new user. The examples use Next.js (App Router) with @supabase/ssr, but the same steps work in any framework. How it works:
  1. The main tracking script on your website records the visit from a referral link and stores a _fprom_tid cookie on your root domain.
  2. When a new user signs up with Supabase Auth, your server reads the _fprom_tid cookie.
  3. Your server sends the user’s email, Supabase user ID and the _fprom_tid value to the track/signup endpoint.

Main tracking script

Add the main tracking script to the <head> of every page a referral link can land on: your marketing site and your app. Replace <your-account-id-here> with your account ID from Settings > Integrations.

Referral tracking

1

Add your API credentials

Get your API key and Account ID from Settings > Integrations (create a new API key if you don’t have one yet), and add them to your server environment variables.
.env
Never expose the API key in browser code.
2

Add a helper that tracks the signup

lib/firstpromoter.ts
3

Call it when a new user signs up

Pick the tab that matches how users sign up. If you support more than one method, add the code to each.
uid is the Supabase user ID. FirstPromoter matches sales to referrals by email or uid, so send the same values your billing provider will send when the customer pays.

Sales tracking

Supabase handles your users, not payments. Sales are tracked through your billing integration (Stripe, Chargebee, Paddle and others). If you use another billing provider, track sales with the sales tracking API.