Documentation
Server-side revenue API
Send a purchase to Splitlab from your server after payment succeeds. Splitlab credits the revenue to the test variant the buyer saw. The WooCommerce integration uses this API; use it directly for any other store or backend.
Server-side reporting survives ad blockers and closed tabs, but your server has no visitor context of its own. You must pass the buyer's Splitlab visitor ID, captured from the browser before checkout.
Endpoint
POST https://api.splitlab.io/api/v1/track/revenue
Content-Type: application/json
x-api-key: sl_live_…Authentication
Create an API key in Splitlab under Workspace settings → API keys, and send it in the
x-api-key header.
- The key must belong to the same workspace as the
projectIdyou report into. A key from another workspace gets403. - Any active key works. Read-only keys are fine.
- Revoking a key takes effect immediately. An expired key gets
401, so choose Never for expiry on keys used by integrations, or rotate them before they expire. - Keep the key on your server. Never put it in browser code.
Get the visitor ID
The Splitlab engine stores each visitor's ID in a first-party cookie on your site:
mvtVisitorId_<projectKey>_cookieRead it when the buyer checks out (for example, from the checkout request's cookies) and store it with the order. Payment often completes later in a webhook that has no cookies, so capture it at checkout, not at payment.
If your project requires cookie consent, the cookie only exists once the visitor has consented.
Request body
| Field | Type | Required | Notes |
|---|---|---|---|
visitorId | string | Yes | The value of the visitor cookie |
projectId | string | Yes | Your project key (data-project-key from the install snippet) |
campaignId | string | Yes | Send "" to let Splitlab find the test the visitor was assigned to. Send a campaign ID only to force one |
revenueAmount | number | Yes | 0 or more, in the currency's normal units (49.99, not cents) |
currency | string | Yes | ISO 4217 code, up to 3 characters (USD) |
orderId | string | Yes | Your unique order ID. Reporting the same orderId again does not count twice |
eventApiName | string | No | Defaults to purchase |
metricId | string | No | Credit a specific revenue metric |
pageUrl | string | No | The page where the purchase completed. Helps Splitlab choose the test when a visitor is in several |
eventProperties | object | No | Extra key-value data stored with the event |
Example
curl -X POST https://api.splitlab.io/api/v1/track/revenue \
-H "Content-Type: application/json" \
-H "x-api-key: $SPLITLAB_API_KEY" \
-d '{
"visitorId": "visitor-AbCdEfGhIjKlMnOpQrStUv-k2j9x8q1-1791282230734",
"projectId": "AbCdEfGhIjKlMnOpQrStUv",
"campaignId": "",
"revenueAmount": 49.99,
"currency": "USD",
"orderId": "order_10421",
"pageUrl": "https://shop.example.com/checkout/thank-you"
}'Responses
Every response has a responseHeader. A successful request also has a response:
{
"responseHeader": {
"status": 200,
"statusCode": "SUCCESS",
"responseTitle": "Revenue Tracked Successfully"
},
"response": {
"success": true,
"attributed": true,
"deduplicated": false,
"variantId": "…",
"variantKey": "…",
"revenueAmount": 49.99,
"currency": "USD",
"orderId": "order_10421"
}
}attributed | deduplicated | Meaning |
|---|---|---|
true | false | Credited to the visitor's test variant |
false | false | Recorded for the project, but the visitor was not in a running test, so no variant was credited |
false | true | This orderId was already reported. Nothing was counted twice |
| HTTP status | When |
|---|---|
200 | Accepted. Check attributed and deduplicated as above |
400 | The body failed validation. responseDescription lists the fields |
401 | x-api-key is missing, unknown, revoked or expired |
403 | The key belongs to a different workspace than projectId |
Retry on network errors and 5xx. Retrying a request that already succeeded is safe, because the
orderId is only counted once. Don't retry 400, 401 or 403 without fixing the request.
Not supported yet
Refunds can't be reported through this API. A refunded order still counts in Splitlab.