Performance
Performance by channel
GET
https://thoughtmetric.io/api/v1/performance_data_by_channel
Performance broken down by marketing channel, so you can compare paid, organic, direct and referral traffic side by side. Rows are attributed, so the attribution model affects the split.
Example request
curl -G https://thoughtmetric.io/api/v1/performance_data_by_channel \
-H "Authorization: Bearer 2019962dcf7a7b1fedc4563b9aaf9fc87426f278" \
-d projectId=ID-bcd0aa692ce7e6b2 \
-d startDate=2024-01-01 \
-d endDate=2024-01-31 \
-d interval=day
<?php
$query = http_build_query([
'projectId' => 'ID-bcd0aa692ce7e6b2',
'startDate' => '2024-01-01',
'endDate' => '2024-01-31',
'interval' => 'day',
]);
$ch = curl_init('https://thoughtmetric.io/api/v1/performance_data_by_channel?' . $query);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer 2019962dcf7a7b1fedc4563b9aaf9fc87426f278',
]);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
const params = new URLSearchParams({
projectId: 'ID-bcd0aa692ce7e6b2',
startDate: '2024-01-01',
endDate: '2024-01-31',
interval: 'day',
});
const response = await fetch(
`https://thoughtmetric.io/api/v1/performance_data_by_channel?${params}`,
{ headers: { Authorization: 'Bearer 2019962dcf7a7b1fedc4563b9aaf9fc87426f278' } }
);
const data = await response.json();
Query parameters
| projectId string, required | The Project ID of the store you are querying, e.g. ID-bcd0aa692ce7e6b2. Find it under Configure → API in the dashboard. The older numeric project ID is also accepted. |
| startDate string, required | Start of the reporting window, YYYY-MM-DD. Inclusive. |
| endDate string, required | End of the reporting window, YYYY-MM-DD. Inclusive. The window may not exceed six months. |
| interval string, required | Bucket size for the over_time series: day, week, month or year. |
| model string, optional | Attribution model: first, last, position, linearNonDirect or linearPaid. Defaults to the model configured on the project. |
Response
total
array
One object per channel, covering the whole reporting window, ordered by channel.
| channel number | Marketing channel the row is attributed to, e.g. facebookad, googlead, organic, direct. |
| visits number | Sessions recorded by the tracking pixel. |
| total_duration number | Combined duration of all sessions, in seconds. |
| total_pageviews number | Pageviews across all sessions. |
| orders number | Orders attributed to this row. |
| add_to_carts number | Add-to-cart events. |
| leads number | Lead events. |
| gross_sales number | Sales before discounts are applied. |
| total_discounts number | Discounts applied to attributed orders. |
| total_refund number | Amount refunded on attributed orders. |
| net_sales number | Sales after refunds, excluding shipping and tax. |
| total_shipping number | Shipping charged on attributed orders. |
| total_tax number | Tax collected on attributed orders. |
| total_sales number | Total value of attributed orders. |
| net_profit number | total_sales minus converted_spend. |
| item_quantity number | Units sold across attributed orders. |
| spend number | Ad spend as reported by the ad platform, in the platform's own currency. |
| converted_spend number | Ad spend converted into your project's reporting currency. Use this one for cross-platform comparisons. |
| aov number | Average order value, total_sales divided by orders. |
| conversion_rate number | Orders divided by visits, as a percentage. |
| cac_blended number | Blended customer acquisition cost, converted_spend divided by orders. |
| roas number | Return on ad spend, total_sales divided by converted_spend. |
| new_customer_orders number | Orders placed by first-time customers. |
| returning_customer_orders number | Orders placed by returning customers. |
| new_customer_total_sales number | Sales from first-time customers. |
| returning_customer_total_sales number | Sales from returning customers. |
| new_customers number | Duplicate of new_customer_orders, kept for backwards compatibility. |
| cost_per_new_customer_order number | converted_spend divided by new_customer_orders. |
| cost_per_returning_customer_order number | converted_spend divided by returning_customer_orders. |
| roas_new_customer number | new_customer_total_sales divided by converted_spend. |
| roas_returning_customer number | returning_customer_total_sales divided by converted_spend. |
over_time
array
One object per channel per interval bucket, ordered by time then channel. Same metrics as total, plus time.
| time string | Start of the interval bucket, as an ISO 8601 timestamp. |
Example response
Abbreviated for readability.
200 OK
{
"total": [
{
"channel": "facebookad",
"visits": 18402.0,
"orders": 512.0,
"total_sales": 58210.44,
"converted_spend": 24100.10,
"roas": 2.42,
"aov": 113.69
},
{
"channel": "organic",
"visits": 15220.0,
"orders": 388.0,
"total_sales": 41022.85,
"converted_spend": 0.0,
"roas": 0.0,
"aov": 105.73
}
],
"over_time": [
{
"time": "2024-01-01T00:00:00.000Z",
"channel": "facebookad",
"visits": 604.0,
"orders": 17.0,
"total_sales": 1902.55,
"converted_spend": 780.20,
"roas": 2.44
}
]
}
Notes
- This endpoint reports
roaswhere the blended endpoint reportsmer. The calculation is identical. - Channels with no activity in the window are not returned.