Lucratividade

Get Best Customers vs the Rest

GET
/v1/profitability/customer-segments

Splits the customers who bought in the period into the best ones (best: the top fifth by revenue in the period, NTILE(5) over revenue per customer) and the others (rest), and compares the two: share of customers, share of revenue, orders per customer and average ticket. Aggregates only: no customer identifier or personal data is returned. Revenue is the official one (SUM(revenue) of analytics.fct_transactions, days in UTC). Sales without a customer identity (e.g. marketplace orders) are in no segment: unidentified says how much revenue and how many orders they are, and segment shares are over the identified base (identifiedCustomers, identifiedRevenue). With fewer than 5 identified customers the best group is 1 customer, so read customerShare instead of assuming 20%. Both dates are required; the period spans at most 366 days.

Autorização

ClientIdAuthClientSecretAuth
headerx-client-id<token>

Client ID

headerx-client-secret<token>

Client secret

Parâmetros de query

organizationId*string

Identificador da organização (obrigatório)

startDate*string

First day of the period, inclusive (YYYY-MM-DD, UTC). Required.

Formatodate
endDate*string

Last day of the period, inclusive (YYYY-MM-DD, UTC). Required. At most 366 days from startDate.

Formatodate
gtmMotionId?string

GTM motion da organização (UUID), como listada por GET /v1/gtm-motions. Opcional: sem ele, a resposta cobre a GTM motion padrão da organização. Este endpoint ainda não é recortado por GTM motion: a motion padrão responde com os dados da organização, os mesmos números de quando o parâmetro é omitido, e qualquer outra GTM motion da organização recebe 422 GTM_MOTION_DATA_NOT_AVAILABLE. Não UUID: 400. GTM motion que não é uma motion ativa da organização: 403 GTM_MOTION_NOT_IN_ORGANIZATION.

Formatouuid

Corpo da resposta

Customer segments retrieved successfully

application/json
  1. response
period*
totalRevenue*number

Revenue of every sale of the period: identifiedRevenue + unidentified.revenue

identifiedCustomers*integer

Customers with an identity who bought in the period (the base of the segments)

identifiedRevenue*number

Revenue of the sales with a customer identity

segments*array<>

Always two items, best then rest; zeros when the period has no identified sale

unidentified*

Sales without a customer identity, left out of the segments

curl -X GET "https://example.com/v1/profitability/customer-segments?organizationId=c0ad4763-173e-4a05-9cff-5208c8ea5f6a&startDate=2025-11-01&endDate=2026-10-31&gtmMotionId=019a5b2e-7c4d-7abc-8def-0123456789ab"
{  "period": {    "startDate": "2025-11-01",    "endDate": "2026-10-31"  },  "totalRevenue": 43100000,  "identifiedCustomers": 48200,  "identifiedRevenue": 41047120,  "segments": [    {      "key": "best",      "customers": 9640,      "customerShare": 20,      "revenue": 23807329.6,      "revenueShare": 58,      "orders": 27956,      "ordersPerCustomer": 2.9,      "averageTicket": 851.6    },    {      "key": "rest",      "customers": 38560,      "customerShare": 80,      "revenue": 17239790.4,      "revenueShare": 42,      "orders": 42416,      "ordersPerCustomer": 1.1,      "averageTicket": 406.45    }  ],  "unidentified": {    "revenue": 2052880,    "revenueShare": 4.76,    "orders": 3310  }}