Customers
Customer LTV by channel
GET
https://thoughtmetric.io/api/v1/customer_ltv_by_channel
Average total spend of customers whose orders are attributed to each channel. Useful for comparing the long-run value of the customers different channels bring in.
Example request
curl -G https://thoughtmetric.io/api/v1/customer_ltv_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/customer_ltv_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/customer_ltv_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.
| channel string | Marketing channel the customers are attributed to. |
| ltv number | Average lifetime spend of customers attributed to this channel. |
Example response
200 OK
{
"total": [
{ "channel": "facebookad", "ltv": 210.44 },
{ "channel": "googlead", "ltv": 188.10 },
{ "channel": "organic", "ltv": 241.85 }
],
"total_last_period": [],
"over_time": [],
"over_time_last_period": []
}
Notes
- This endpoint looks at customers converting in the 30 days up to
endDate.startDateis required by the API but does not affect the result. - Customers attributed to more than one channel are counted once per channel.