
Prerequisites
Before integrating Cello, ensure the following:- Your app uses Supabase Auth for user signup and authentication
- Your app has a Stripe subscription or payment flow (for purchase tracking)
- You have a Cello account with your Product ID, Product Secret, and API access keys from the Access Keys page
Use the Cello Sandbox environment when developing and testing your integration.
Optional: Connect the Cello MCP
Connect the Cello MCP server to your AI coding tool - it gives your tool access to Cello’s docs, health checks, and best practices so your AI can handle the implementation.Cello MCP Server
Setup instructions for Cursor, VS Code, and Lovable
Step 1: Capture referral codes on your landing page
Add the Cello attribution script to your referral landing page to capture the referral code (ucc) when users click referral links:
-
Install the attribution script. Choose the option best suited for your setup:
Embedded Script Tag
Google Tag Manager
-
Verify the installation
To verify, follow these steps:
-
Add
?productId=testand?ucc=testto your website URL -
Make sure that these values are saved in the cookies as
cello-product-idandcello-referral -
Navigate to your signup page and try to access the ucc using the
getUcc()method from the browser consoleThis method should return a promise with valuetest
-
Add
Step 2: Track signups with Supabase Auth + Edge Functions
This is the Supabase-specific step. You will pass the referral code through Supabase Auth, then use a Database Webhook and Edge Function to send the signup event to Cello.2a. Pass the referral code through Supabase Auth signup
During signup, retrieve theucc and store it in the user’s raw_user_meta_data:
2b. Deploy an Edge Function to send signup events to Cello
Create an Edge Function that receives the Database Webhook payload and sends anew-signup event to the Cello POST /events API.
All Cello referral events use eventName: 'ReferralUpdated' - the trigger field inside context.event specifies the event type (new-signup, invoice-paid, etc.).
supabase/functions/cello-track-signup/index.ts
supabase/functions/cello-track-signup/index.ts
The
--no-verify-jwt flag is required because the function is called by a Database Webhook, not by an authenticated user.2c. Create a Database Webhook on auth.users
In your Supabase Dashboard, go to Database → Webhooks and create a new webhook:| Setting | Value |
|---|---|
| Name | cello-track-signup |
| Table | auth.users |
| Events | INSERT |
| Type | Supabase Edge Functions |
| Edge Function | cello-track-signup |
Every time a new user signs up via Supabase Auth, the Edge Function fires automatically and sends the referral attribution to Cello.
Step 3: Connect Stripe Webhook for purchase tracking
To send Cello purchase events, connect your Stripe Webhook to Cello. When creating a Stripe Customer, pass the referral metadata so Cello can attribute conversions:Cello uses the
customer.created event to link the Stripe customer to the referral attribution captured in Step 2. Subsequent invoice.paid events trigger purchase tracking and reward calculation.Stripe Webhook
Send events using Stripe Webhook
Step 4: Integrate the Referral Component
Integrate the Cello Referral Component into your web app so your users can share their referral link. The component is installed using Cello JS - our client-side SDK. You can install it by:- Adding a script tag to the
<head>of your application - Generating a JWT token for user authentication
- Booting the component with the provided token and user details
Referral Component Quickstart
Verify your integration
Use the Event Feed in the Cello Portal to confirm that signup and purchase events are arriving correctly and all required fields pass validation. See the Event Feed guide for details on what to check.Next steps
Referral Component
Customise how the referral widget looks and behaves in your app
Track Purchases
Set up purchase conversion tracking via Stripe webhooks
Apply Discounts
Offer new user discounts as part of your referral program
Cello MCP Server
Connect Cursor or Lovable to Cello for AI-assisted integration