---
updatedAt: 2026-09-07T20:12:14.000Z
agentTools:
  projectIndex: https://developers.viral-loops.com/llms.txt
---

# Convert participants using the Server-Side API

When conversion events happen securely in your backend—such as payment processor webhooks, subscription renewals, database updates, or off-line transactions—triggering conversions on the client side with JavaScript is not an option.

By using the **Viral Loops Server-Side / Private API**, you can securely report participant conversions directly from your server.

***

## When to Use API Conversion Tracking

Server-side API conversion tracking is ideal when:

* **Transactions occur on the backend**: Payment processing via Stripe, PayPal, or Paddle, where the final confirmation happens via webhook.
* **Events happen asynchronously:** Subscriptions that convert after a free trial period ends, or delayed manual account approvals.
* **High security is required:** Preventing malicious users from attempting to trigger client-side JavaScript conversion calls artificially.
* **Value Tracking is involved:** Transmitting sensitive transaction amounts or purchase values directly from your secure database.

***

## Prerequisites

1. **Viral Loops API Token:** Your secret API key, available in your **Viral Loops Campaign Settings > API Credentials**. Keep this key secure and never expose it in public client-side code.
2. **Participant Identifier:** You need a way to identify which participant converted. This can be their `email`, `userCode` (referral code), or `refCode`.
3. **Plan & Template:** Conversion API requests are available on the **Growing Plan or higher** across supported templates (*The Milestone Referral*, *The Altruistic Referral*, *Online to Offline*, *The Universal Referral*, and *The Tempting Giveaway*).

***

## How to Make the Conversion API Request

To trigger a conversion, send a `POST` request from your backend to the Viral Loops API endpoint.

### API Endpoint

`POST https://app.viral-loops.com/api/v2/events`<br />`Content-Type: application/json`

### Request Payload

Include your secret API token along with the event name `"conversion"` and the identifying details of the converted participant.

```json
{
  "apiToken": "YOUR_VIRAL_LOOPS_API_TOKEN",
  "params": {
    "event": "conversion",
    "user": {
      "email": "converted_user@example.com"
    }
  }
}
```

## Tracking Conversion Value (Optional)

If your campaign measures purchase volume or revenue generated by referrals, you can pass transaction values alongside the conversion event.

Add the `value` property inside your `params` payload:

```json
{
  "apiToken": "YOUR_VIRAL_LOOPS_API_TOKEN",
  "params": {
    "event": "conversion",
    "user": {
      "email": "converted_user@example.com"
    },
    "options": {
      "value": 49.99
    }
  }
}
```

<br />

## Example Integratoin: Webhook Handler (Node.js)

Here is a practical example of triggering a conversion when receiving a successful payment notification in a Node.js backend:

```node
const express = require('express');
const fetch = require('node-fetch');
const app = express();

app.use(express.json());

app.post('/webhooks/payment-success', async (req, res) => {
  const { customerEmail, orderTotal } = req.body;

  try {
    const response = await fetch('[https://app.viral-loops.com/api/v2/events](https://app.viral-loops.com/api/v2/events)', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        apiToken: process.env.VIRAL_LOOPS_API_TOKEN,
        params: {
          event: 'conversion',
          user: {
            email: customerEmail
          },
          value: orderTotal
        }
      })
    });

    const data = await response.json();

    if (response.ok) {
      console.log('Conversion recorded successfully in Viral Loops:', data);
      res.status(200).send({ status: 'success' });
    } else {
      console.error('Viral Loops API Error:', data);
      res.status(400).send({ status: 'error', details: data });
    }
  } catch (error) {
    console.error('Failed to trigger conversion event:', error);
    res.status(500).send({ status: 'internal_error' });
  }
});
```

<br />

## Best Practices & Tips

* **Idempotency & Duplicate Calls**: The Viral Loops backend handles duplicate conversion events for a given participant based on your campaign settings. However, it's good practice to ensure your server logic only calls the conversion API once per converted action.
* **Keep API Keys Confidential**: Never call the API endpoint using secret tokens directly from frontend JavaScript, mobile apps, or public repositories.
* **Value Tracking Setup**: Ensure that Value Tracking is enabled under the Goals step in your Viral Loops campaign wizard if you intend to send numerical monetary values.
* <Anchor target="_blank" href="https://developers.viral-loops.com/docs/how-to-secure-your-campaign-with-authorized-conversions">**Accept only Authorized Conversions**</Anchor>**:&#x20;**&#x56;iral Loops supports blocking all conversions from public clients using the frontend JavaScript SDK and/or the campaign's public token

## Related Articles

* <Anchor target="_blank" href="https://developers.viral-loops.com/docs/what-is-conversion-tracking">What is Conversion Tracking in Viral Loops & Why You Need it</Anchor>
* <Anchor target="_blank" href="https://developers.viral-loops.com/docs/convert-participants-using-the-javascript-sdk">How to Track Conversions using the JavaScript SDK</Anchor>
* <Anchor target="_blank" href="https://developers.viral-loops.com/docs/how-to-track-conversions-via-page-url">How to Track Conversions via Page URL</Anchor>
* <Anchor target="_blank" href="https://developers.viral-loops.com/reference/post_campaign-participant-convert">Developer Reference: Viral Loops Conversion API Docs</Anchor>