Skip to main content
This guide walks you through integrating a refer-a-friend program using the Partnero REST API. Your existing customers share referral links with friends and earn rewards when those friends sign up or make a purchase.
Before proceeding, you should have a program created on Partnero. If you haven’t created one yet, refer to the Knowledge Base for guidance.

How it works

  1. A customer signs up on your site and receives a unique referral link from Partnero
  2. They share the link with friends
  3. When a friend visits via the link, PartneroJS stores the referrer’s key in a partnero_referral cookie
  4. When the friend signs up, your backend reads the cookie and sends it to Partnero to link them as a referred customer
  5. When the referred customer makes a purchase, your backend records the transaction
  6. The referring customer earns a reward

Step 1: Install PartneroJS

PartneroJS tracks referral visits by reading the referrer’s key from the URL and storing it in a first-party cookie. This cookie is what your backend reads later during sign-up.
1

Get your snippet

  1. Log in to Partnero
  2. Go to Programs and select your program
  3. Navigate to Integration in the sidebar
  4. Copy the PartneroJS snippet
2

Install the snippet

Paste the snippet into your website’s HTML just before the closing </head> tag:
When a visitor arrives via a referral URL (e.g., yoursite.com?ref=REFERRAL_KEY), the script creates a partnero_referral cookie containing the referrer’s key.

Step 2: Track sign-ups

In a refer-a-friend program, every customer should be created in Partnero—both referrers and referred customers. The only difference is whether you include a referring_customer field.

How to get the referral key

The partnero_referral cookie is set by PartneroJS when a visitor arrives via a referral link. Read it on your server:

Create a customer

Send a POST /v1/customers call for every sign-up. If the partnero_referral cookie exists, include it as referring_customer.key. If it doesn’t, omit the referring_customer field—the customer is still created and can share their own referral link.

Request body

*If referring_customer is provided, at least one of referring_customer.key or referring_customer.id is required.

Response

The response includes the customer’s referral link, which you can display in your UI:

Step 3: Track sales

When a referred customer makes a purchase, record the transaction so Partnero can calculate rewards for the referring customer.
Prefer automatic tracking? If you use Stripe, Paddle, or Chargebee, transactions are tracked automatically through Partnero’s integrations—no API call needed. Set up integrations in Program settings → Integrations.

Request body

Multiple transactions

Send multiple transactions for the same customer in a single request:

Step 4: Display referral data

Show customers their referral link, stats, and rewards in your application. Fetch this data from your backend using the Partnero API.
Use the referral_link from the response to display a “Share your link” section in your app.

Get referral stats

Returns click counts, referral counts, and social sharing links.

Get reward balance

Returns the customer’s accumulated rewards.

Get referred friends

Returns a list of customers who signed up via this customer’s referral link.

Step 5: Credit rewards

If your reward configuration requires manual crediting, add credit to a referring customer’s balance:
If rewards are configured to be applied automatically in your program settings, you don’t need to call this endpoint manually.

Complete integration example

Here’s the full flow in a Node.js/Express backend:

Next steps

Webhooks

Get real-time notifications when referrals convert

Customer API

Full customer endpoint documentation

Mobile apps

Integrate tracking in iOS and Android apps

Refer-a-friend forms

No-code embeddable referral forms