customerAnalytics
Requires at least one of the permissions analytics:sales:read or dashboard:main:read.
Customer analytics for a period. Limited to the customers you may see.. Needs the sales analytics or dashboard read permission.
Errors: a failed call returns a GraphQL errors entry, not a field on the result, and data may be null or partial. Read the entry's extensions.code and message; every shape and code is in the Error reference.
Example:
- GraphQL
- cURL
query CustomerAnalytics($period: AnalyticsPeriod!) {
customerAnalytics(period: $period) {
activeCustomers
averageOrdersPerCustomer
churnRate
customerLifetimeValue
newCustomers
totalCustomers
customerGrowth {
newCustomers
period
totalCustomers
}
}
}
curl -X POST "https://<api-host>/graphql" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
--data @- <<'EOF'
{
"query": "query CustomerAnalytics($period: AnalyticsPeriod!) {\n customerAnalytics(period: $period) {\n activeCustomers\n averageOrdersPerCustomer\n churnRate\n customerLifetimeValue\n newCustomers\n totalCustomers\n customerGrowth {\n newCustomers\n period\n totalCustomers\n }\n }\n}",
"variables": {
"period": "LAST_6_MONTHS"
}
}
EOF
Variables:
{
"period": "LAST_6_MONTHS"
}
Response:
{
"data": {
"customerAnalytics": {
"activeCustomers": 0,
"averageOrdersPerCustomer": 0,
"churnRate": 0,
"customerLifetimeValue": 0,
"newCustomers": 0,
"totalCustomers": 0,
"customerGrowth": [
{
"newCustomers": 0,
"period": "string",
"totalCustomers": 0
}
]
}
}
}
customerAnalytics(
period: AnalyticsPeriod!
): CustomerAnalytics!
Arguments
customerAnalytics.period ● AnalyticsPeriod! non-null enum
The reporting period to analyse.
Type
CustomerAnalytics object
Customer figures for the period.