Splitlab

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 projectId you report into. A key from another workspace gets 403.
  • 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>_cookie

Read 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

FieldTypeRequiredNotes
visitorIdstringYesThe value of the visitor cookie
projectIdstringYesYour project key (data-project-key from the install snippet)
campaignIdstringYesSend "" to let Splitlab find the test the visitor was assigned to. Send a campaign ID only to force one
revenueAmountnumberYes0 or more, in the currency's normal units (49.99, not cents)
currencystringYesISO 4217 code, up to 3 characters (USD)
orderIdstringYesYour unique order ID. Reporting the same orderId again does not count twice
eventApiNamestringNoDefaults to purchase
metricIdstringNoCredit a specific revenue metric
pageUrlstringNoThe page where the purchase completed. Helps Splitlab choose the test when a visitor is in several
eventPropertiesobjectNoExtra key-value data stored with the event

Example

curl
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:

200 OK
{
  "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"
  }
}
attributeddeduplicatedMeaning
truefalseCredited to the visitor's test variant
falsefalseRecorded for the project, but the visitor was not in a running test, so no variant was credited
falsetrueThis orderId was already reported. Nothing was counted twice
HTTP statusWhen
200Accepted. Check attributed and deduplicated as above
400The body failed validation. responseDescription lists the fields
401x-api-key is missing, unknown, revoked or expired
403The 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.