Posting Conversion Events via the Tracking API
A reference for the /events endpoint: the payload shape, how revenue is parsed, and how events are attributed to variants.
3 min read
The /events endpoint records conversions and other tracked events, together with the experiment variants the visitor was enrolled in at the time. It is how revenue and conversion counts reach the Statistics page when you are reporting from your own code rather than relying on the browser runtime.
The request
POST https://tracking.pertento.ai/events?websiteId=<websiteId>
The websiteId query parameter is required here and must be a number. If it is missing or unparseable the request is accepted and discarded.
Send JSON:
{ "dataPayload": [["purchase", { "revenue": "49.99", "currency": "EUR" }]], "experimentVariantMap": { "7": "102" } }
The payload shape
dataPayload is an array of events, and each event is itself a two-element array of event name and event data. Entries that are not arrays are skipped without an error, which is the most common reason a payload appears to be accepted while nothing is recorded.
The event name is free text. For it to count towards an experiment’s results, it needs to be either purchase or an event configured as a goal — see the article on choosing which events Pertento tracks.
Attributing events to variants
experimentVariantMap maps experiment id to variant id, as strings. It is what ties the conversion to the arm of the test that earned it.
If the body has no map, Pertento falls back to exp-<experimentId>=<variantId> query parameters, in the same form the exposures endpoint takes. The body wins when both are present.
An event with no mapping is still recorded as site activity but contributes to no experiment.
How revenue and currency are read
Financial values are pulled from the event data, checking several field names so that common analytics payloads work unchanged:
- Currency comes from
currencyCode, or failing thatcurrency. With neither, the event is recorded against a placeholder currency, which is what the "All currencies" option on the Statistics page reports on. - Revenue comes from
actionField.revenue,actionField.value,revenueorvalue, in that order. - Tax and shipping are read from their own fields, or from
actionField. - Total value is calculated as revenue plus tax plus shipping. You do not send it.
Amounts are parsed as decimal numbers and stored as minor units, so "49.99" becomes 4999. Anything that is not a plain number is treated as zero rather than rejected — a value like "49,99" or "€49.99" silently records no revenue, so send an unformatted decimal.
Registering event names
For an event name to be selectable as a goal it has to be known to your website. The runtime reports names it sees to a companion endpoint:
POST https://tracking.pertento.ai/event-goals?websiteId=<websiteId>
The body is a plain array of event name strings, for example ["purchase", "signup"]. Names already registered are ignored, so it is safe to send them repeatedly.
Notes
- Events are stamped when they arrive; there is no backdating parameter.
- The success response is returned before the write is attempted. Verify in the dashboard rather than from the response.
- Revenue in a currency you have not selected on the Statistics page will not appear in the revenue figures. Currencies cannot be summed, so revenue needs one currency chosen.
- Exposures must be reported too, or conversions will have no denominator to be measured against.