Orders by repeat customer
How to use the Metrics API to get the total number of orders of your organization, grouped by customers that bought from you more than once
The problem
The solution
Query
Key
Value
Filter
Example
curl -g -X POST \
'https://{{your_domain}}.commercelayer.io/metrics/orders/breakdown' \
-H 'Accept: application/vnd.api.v1+json' \
-H 'Content-Type: application/vnd.api+json' \
-H 'Authorization: Bearer {{your_access_token}}' \
-d '{
"breakdown": {
"by": "customer.email",
"field": "order.id",
"operator": "value_count",
"condition": {
"gte": 2
},
"sort": "desc",
"limit": 100
},
"filter": {
"order": {
"date_from": "2021-01-01T00:00:00Z",
"date_to": "2021-12-31T23:59:00Z",
"date_field": "placed_at"
}
}
}'Similar cases
Last updated