Performance
Performance by campaign
GET
https://thoughtmetric.io/api/v1/performance_data_by_campaign
Campaign-level ad performance, including delivery metrics such as impressions, clicks and CTR alongside attributed sales. Only ad-attributed traffic is included, so totals here are lower than the blended endpoint.
Example request
curl -G https://thoughtmetric.io/api/v1/performance_data_by_campaign \
-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_campaign?' . $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_campaign?${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. |
| account_id string, optional | Restrict results to a single ad account. |
Response
total
array
One object per campaign, covering the whole reporting window, ordered by campaign ID.
| campaign_id number | ThoughtMetric identifier for the campaign. |
| campaign_name number | Campaign name as reported by the ad platform. Null if the campaign has no metadata on record. |
| 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. |
| impressions number | Ad impressions. |
| clicks number | Ad clicks. |
| 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. |
| avg_duration number | Average session duration, in seconds. |
| avg_pageviews number | Average pageviews per session. |
| 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. |
| aov number | Average order value, total_sales divided by orders. |
| conversion_rate number | Orders divided by visits, as a percentage. |
| cac number | Customer acquisition cost, converted_spend divided by orders. |
| cpc number | Cost per click, converted_spend divided by clicks. |
| ctr number | Click-through rate, clicks divided by impressions, as a percentage. |
| cpm number | Cost per thousand impressions. |
| 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. |
| 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 campaign per interval bucket. This series carries campaign_id but not campaign_name.
| time string | Start of the interval bucket, as an ISO 8601 timestamp. |
| campaign_id number | ThoughtMetric identifier for the campaign. |
Example response
Abbreviated for readability.
200 OK
{
"total": [
{
"campaign_id": 4482910,
"campaign_name": "Prospecting | Broad | US",
"spend": 12400.55,
"converted_spend": 12400.55,
"impressions": 1840222.0,
"clicks": 24188.0,
"ctr": 1.31,
"cpc": 0.51,
"orders": 288.0,
"total_sales": 31022.19,
"roas": 2.50,
"cac": 43.06
}
],
"over_time": [
{
"time": "2024-01-01T00:00:00.000Z",
"campaign_id": 4482910,
"spend": 402.10,
"impressions": 60114.0,
"clicks": 802.0,
"orders": 9.0,
"total_sales": 1004.22,
"roas": 2.50
}
]
}
Notes
- Campaigns with no metadata on record return a null
campaign_name. reachandengagementare not currently available on this endpoint.