Orders and surveys
Survey results
GET
https://thoughtmetric.io/api/v1/survey_results
Responses to the post-purchase “how did you hear about us” survey, along with the order count over the same window so you can calculate a response rate.
Example request
curl -G https://thoughtmetric.io/api/v1/survey_results \
-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/survey_results?' . $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/survey_results?${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. |
Response
total
number
Total survey responses in the window.
total_orders
number
Orders placed in the window, counted from the date your first survey response was recorded. Use this as the denominator for a response rate.
total_by_channel
array
One object per survey answer.
| channel_result string | The answer the customer selected. |
| surveys number | Number of responses with this answer. |
Example response
200 OK
{
"total": 412,
"total_orders": 1284.0,
"total_by_channel": [
{ "channel_result": "Instagram", "surveys": 148 },
{ "channel_result": "Friend or family", "surveys": 96 },
{ "channel_result": "Google search", "surveys": 88 },
{ "channel_result": "Podcast", "surveys": 80 }
]
}
Notes
intervalis required by the API but does not affect the result.