> For the complete documentation index, see [llms.txt](https://referral-rocket.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://referral-rocket.gitbook.io/docs/getting-started/campaigns/installing-tracking-your-referral-campaign/referral-tracking/track-referral-on-payments.md).

# Track referral on Payments

Capturing and tracking referrals requires integrating Referral Rocket's tracking system into your website or application. This guide walks you through the complete implementation process for capturing referrals on payments.

### Step-by-Step Referral Tracking Implementation

Step 1: Add the following script in the Head tag (**replace with your campaign id**) on payment/checkout page.

```
// Add this script in the HEAD tag
<script type="text/javascript" campaign-id="YOUR-CAMPAIGN-ID" defer src="https://app.referralrocket.io/widget/widgetIndex.js"></script>
```

Step 2: On successful payment, call `qualifyParticipant` to capture the referral and mark the referrer eligible for their reward.

**Using the JavaScript SDK:**

```javascript
const campaign = window.Rocket.getCampaign();

campaign.qualifyParticipant({
  email: 'newuser@example.com',   // required — the referred user's email
  amountPaid: 49.00,              // optional — used for percentage-based rewards
  rewardReferee: false            // optional — set true to also reward the referee
}).then(function(participant) {
  console.log('Referral qualified. Reward triggered for referrer.');
  console.log('Reward event completed:', participant.rewardEventCompleted);
}).catch(function(err) {
  console.error('Error qualifying participant:', err);
});
```

**Using the REST API (server-side):**

```bash
curl -X POST 'https://app.referralrocket.io/api/v1/qualifyParticipant' \
  --header 'x-api-key: YOUR-API-KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "id": "YOUR-CAMPAIGN-ID",
    "email": "newuser@example.com",
    "amountPaid": "49.00"
  }'
```

**`qualifyParticipant` parameters:**

| Parameter       | Type    | Required | Description                                                       |
| --------------- | ------- | -------- | ----------------------------------------------------------------- |
| `email`         | string  | Yes      | Email of the referred participant completing the qualifying event |
| `amountPaid`    | number  | No       | Amount paid — used to calculate percentage-based rewards          |
| `rewardReferee` | boolean | No       | If `true`, also generates a reward for the referee (JS SDK only)  |

> **Note:** Only referred participants (those who joined via a referral link) can be qualified. Calling `qualifyParticipant` on a direct (non-referred) participant has no effect.
