Revenue
E-commerce reporting built on the revenue events sent by the tracker. All monetary amounts are integers in the smallest currency unit (cents).
4 endpoints, all relative to https://analytics.appfor.you. Shared rules live in Conventions, Rate limits and Error codes.
Revenue summary
/api/v2/sites/{siteId}/revenuescope: readCounts revenue events of type `purchase`, `subscription` and `one_time`. Refunds are summed separately and subtracted to produce `netRevenue`. `conversionRate` is orders divided by unique pageview sessions in the same window, as a percentage rounded to 2 decimals.
- All amounts are integers in the smallest currency unit (cents), exactly as stored by the tracker.
Path parameters
| siteId | string | The Mongo _id returned as `siteId` by GET /api/v2/sites, or the public `trackingId` embedded in the tracking snippet. Both are accepted everywhere. |
Query parameters
| Name | Type | Description |
|---|---|---|
| range | string | Relative window: `today`, `7d`, `30d`, `90d`, `6m` or `12m`. Default `30d`. Ignored when both `from` and `to` are supplied. |
| from | string (YYYY-MM-DD) | Explicit window start (inclusive), from `T00:00:00.000Z` on that day. Supply together with `to` to override `range`. An unparseable value, a window that ends before it starts, or a window that starts in the future returns 400. |
| to | string (YYYY-MM-DD) | Explicit window end (inclusive) — the WHOLE day, through `T23:59:59.999Z`, clamped to now when it is in the future. `from=X&to=X` is therefore a full 24-hour day. Supply together with `from` to override `range`. An unparseable value, a window that ends before it starts, or a window that starts in the future returns 400. |
Example request
curl -H "Authorization: Bearer $ANALYTICS_API_KEY" \ "https://analytics.appfor.you/api/v2/sites/6507f1f77bcf86cd799439011/revenue?range=30d"
Example response
{
"range": {
"since": "2025-02-19T00:00:00.000Z",
"until": "2025-03-21T00:00:00.000Z"
},
"totalRevenue": 1284500,
"netRevenue": 1230500,
"orderCount": 143,
"avgOrderValue": 8983,
"conversionRate": 2.41,
"refundTotal": 54000,
"totalSessions": 5934,
"trend": [
{ "date": "2025-03-20", "revenue": 42900, "orders": 5 },
{ "date": "2025-03-21", "revenue": 51200, "orders": 6 }
]
}Revenue by source
/api/v2/sites/{siteId}/revenue/sourcesscope: readSource falls back utm_source → referrer → `(direct)`; medium falls back to `(none)`. Sorted by revenue descending.
Path parameters
| siteId | string | The Mongo _id returned as `siteId` by GET /api/v2/sites, or the public `trackingId` embedded in the tracking snippet. Both are accepted everywhere. |
Query parameters
| Name | Type | Description |
|---|---|---|
| range | string | Relative window: `today`, `7d`, `30d`, `90d`, `6m` or `12m`. Default `30d`. Ignored when both `from` and `to` are supplied. |
| from | string (YYYY-MM-DD) | Explicit window start (inclusive), from `T00:00:00.000Z` on that day. Supply together with `to` to override `range`. An unparseable value, a window that ends before it starts, or a window that starts in the future returns 400. |
| to | string (YYYY-MM-DD) | Explicit window end (inclusive) — the WHOLE day, through `T23:59:59.999Z`, clamped to now when it is in the future. `from=X&to=X` is therefore a full 24-hour day. Supply together with `from` to override `range`. An unparseable value, a window that ends before it starts, or a window that starts in the future returns 400. |
| limit | integer | Rows to return. Default 50, minimum 1, maximum 500. |
| offset | integer | Rows to skip, for paging. Default 0. |
Example request
curl -H "Authorization: Bearer $ANALYTICS_API_KEY" \ "https://analytics.appfor.you/api/v2/sites/6507f1f77bcf86cd799439011/revenue/sources?range=30d&limit=10"
Example response
{
"range": {
"since": "2025-02-19T00:00:00.000Z",
"until": "2025-03-21T00:00:00.000Z"
},
"sources": [
{
"source": "google",
"medium": "cpc",
"revenue": 482300,
"orders": 51,
"sessions": 1204,
"avgOrderValue": 9457
}
],
"limit": 10,
"offset": 0
}Revenue by campaign
/api/v2/sites/{siteId}/revenue/campaignsscope: readOnly revenue events that carry a `utm_campaign` are included. `conversionRate` here is orders divided by sessions within the campaign group, rounded to 1 decimal. Sorted by revenue descending.
Path parameters
| siteId | string | The Mongo _id returned as `siteId` by GET /api/v2/sites, or the public `trackingId` embedded in the tracking snippet. Both are accepted everywhere. |
Query parameters
| Name | Type | Description |
|---|---|---|
| range | string | Relative window: `today`, `7d`, `30d`, `90d`, `6m` or `12m`. Default `30d`. Ignored when both `from` and `to` are supplied. |
| from | string (YYYY-MM-DD) | Explicit window start (inclusive), from `T00:00:00.000Z` on that day. Supply together with `to` to override `range`. An unparseable value, a window that ends before it starts, or a window that starts in the future returns 400. |
| to | string (YYYY-MM-DD) | Explicit window end (inclusive) — the WHOLE day, through `T23:59:59.999Z`, clamped to now when it is in the future. `from=X&to=X` is therefore a full 24-hour day. Supply together with `from` to override `range`. An unparseable value, a window that ends before it starts, or a window that starts in the future returns 400. |
| limit | integer | Rows to return. Default 50, minimum 1, maximum 500. |
| offset | integer | Rows to skip, for paging. Default 0. |
Example request
curl -H "Authorization: Bearer $ANALYTICS_API_KEY" \ "https://analytics.appfor.you/api/v2/sites/6507f1f77bcf86cd799439011/revenue/campaigns?range=30d"
Example response
{
"range": {
"since": "2025-02-19T00:00:00.000Z",
"until": "2025-03-21T00:00:00.000Z"
},
"campaigns": [
{
"campaign": "spring_sale",
"source": "google",
"medium": "cpc",
"revenue": 302400,
"orders": 33,
"sessions": 812,
"avgOrderValue": 9163,
"conversionRate": 4.1
}
],
"limit": 50,
"offset": 0
}Revenue by product
/api/v2/sites/{siteId}/revenue/productsscope: readOnly revenue events that carry a `productName` are included; category falls back to `(uncategorized)`. `avgPrice` is revenue divided by quantity. Sorted by revenue descending — this is the best-seller report.
Path parameters
| siteId | string | The Mongo _id returned as `siteId` by GET /api/v2/sites, or the public `trackingId` embedded in the tracking snippet. Both are accepted everywhere. |
Query parameters
| Name | Type | Description |
|---|---|---|
| range | string | Relative window: `today`, `7d`, `30d`, `90d`, `6m` or `12m`. Default `30d`. Ignored when both `from` and `to` are supplied. |
| from | string (YYYY-MM-DD) | Explicit window start (inclusive), from `T00:00:00.000Z` on that day. Supply together with `to` to override `range`. An unparseable value, a window that ends before it starts, or a window that starts in the future returns 400. |
| to | string (YYYY-MM-DD) | Explicit window end (inclusive) — the WHOLE day, through `T23:59:59.999Z`, clamped to now when it is in the future. `from=X&to=X` is therefore a full 24-hour day. Supply together with `from` to override `range`. An unparseable value, a window that ends before it starts, or a window that starts in the future returns 400. |
| limit | integer | Rows to return. Default 50, minimum 1, maximum 500. |
| offset | integer | Rows to skip, for paging. Default 0. |
Example request
curl -H "Authorization: Bearer $ANALYTICS_API_KEY" \ "https://analytics.appfor.you/api/v2/sites/6507f1f77bcf86cd799439011/revenue/products?range=90d&limit=20"
Example response
{
"range": {
"since": "2024-12-21T00:00:00.000Z",
"until": "2025-03-21T00:00:00.000Z"
},
"products": [
{
"name": "Pro annual plan",
"category": "subscriptions",
"revenue": 780000,
"quantity": 65,
"orders": 65,
"avgPrice": 12000
}
],
"limit": 20,
"offset": 0
}