> ## Documentation Index
> Fetch the complete documentation index at: https://docs.queryful.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Customers

> One row per customer, dated by their first order: lifetime spend and orders, location, marketing consent, cohorts and Shopify's RFM groups.

One row per customer, dated by their first order: lifetime spend and orders, location, marketing consent, cohorts and Shopify's RFM groups.

## Example

```sql theme={null}
FROM customers
  SHOW new_customer_records, total_amount_spent
  GROUP BY customer_id
  SINCE startOfMonth(-1m) UNTIL today
  ORDER BY new_customer_records DESC
```

## Metrics

| Metric | Type | Description |
| - | - | - |
| `new_customer_records` | Number | Customers whose first order was in the period. |
| `total_amount_spent` | Currency | The customers' combined all-time spend. |
| `total_number_of_orders` | Number | The customers' combined all-time number of orders. |
| `total_amount_spent_per_order` | Currency | The customers' all-time spend divided by their all-time orders. |
| `days_since_last_order` | Days | The average number of days since the customers' most recent order, in whole days. |
| `average_days_between_orders` | Number | For customers with more than one order, the average days between their first and latest orders per repeat order. |
| `percent_of_customers` | Percent | Each group's share of all the customers in the results. |
| `amount_spent_per_customer` | Currency | The customers' average all-time spend: their lifetime value. |
| `repeat_customers` | Number | Customers with more than one order. |
| `repeat_customer_rate` | Percent | Customers with more than one order, as a share of the customers. |
| `average_days_to_second_order` | Number | For customers who came back, the average days between their first and second orders. |
| `overdue_customers` | Number | Repeat customers whose time since their last order is past twice their usual gap. |
| `return_rate` | Percent | The customers' returns as a share of their gross sales, all time. |
| `discount_rate` | Percent | The customers' discounts as a share of their gross sales, all time. |

## Dimensions

| Dimension | Description |
| - | - |
| `customer_id` | The customer's Shopify ID. |
| `customer_name` | The customer's full name. |
| `customer_email` | The customer's email address. |
| `customer_email_domain` | The part of the customer's email after the @, such as gmail.com. |
| `customer_country` | The country of each of the customer's addresses: a customer with several counts under each. |
| `customer_region` | The state or province of each of the customer's addresses, such as US-CA. |
| `customer_city` | The city of each of the customer's addresses, with its country and region, as Shopify names it (US-MO-StLouis). |
| `customer_tag` | Customer tag. A customer with several tags counts under each, so totals across tags overlap. |
| `customer_language` | The customer's language. |
| `customer_account_status` | The customer's account state: DECLINED, DISABLED, ENABLED or INVITED. |
| `customer_email_subscription_status` | The customer's email marketing state, such as SUBSCRIBED or NOT\_SUBSCRIBED. |
| `customer_sms_subscription_status` | The customer's SMS marketing state, such as SUBSCRIBED or NOT\_SUBSCRIBED. |
| `customer_product_subscription_status` | Whether the customer has product subscriptions, such as ACTIVE or NEVER\_SUBSCRIBED. |
| `customer_number_of_orders` | The number of orders the customer has placed, all time. |
| `customer_amount_spent` | The customer's all-time spend, in your store's currency. |
| `customer_added_date` | The day the customer was added, in your store's timezone. |
| `customer_first_order_date` | The day the customer placed their first order, in your store's timezone. |
| `customer_last_order_date` | The day the customer most recently placed an order, in your store's timezone. |
| `customer_cohort_month` | The month of the customer's first order. |
| `customer_cohort_quarter` | The quarter of the customer's first order. |
| `customer_cohort_week` | The week of the customer's first order. |
| `customer_countries` | Every country in the customer's addresses, as codes such as GB, US. |
| `customer_regions` | Every state or province in the customer's addresses, such as US-CA, US-NY. |
| `customer_cities` | Every city in the customer's addresses, with its country and region. |
| `first_order_sales_channel` | The sales channel of the customer's first order. |
| `first_order_product` | A product on the customer's first order. A first order with several products counts under each, so totals across products overlap. |
| `second_order_product` | A product on the customer's second order (None without one). A second order with several products counts under each. |
| `second_order_month` | The month of the customer's second order. |
| `first_order_has_subscription` | Whether the customer's first order included a subscription purchase. |
| `first_order_utm_source` | The UTM source of the visit that led to the customer's first order. |
| `first_order_utm_medium` | The UTM medium of the visit that led to the customer's first order. |
| `first_order_utm_campaign` | The UTM campaign of the visit that led to the customer's first order. |
| `first_order_landing_page_url` | The first page of the visit that led to the customer's first order. |
| `first_order_referrer_url` | The site that sent the customer on the visit that led to their first order. |
| `first_order_delivery` | How the customer's first order arrived: on\_time, late, no\_promise, not\_delivered or not\_fulfilled. Ours: set it beside repeat customer rate to see whether late deliveries cost repeat custom. |
| `customer_churn_risk` | Where a repeat customer stands against their usual gap between orders: on\_track, due (past it) or overdue (past twice it). one\_time for a single order. |
| `customer_expected_next_order_date` | The customer's last order date plus their usual gap between orders. Empty for one-time customers. |
| `rfm_group` | Shopify's customer group by recency, frequency and spend, such as champions, loyal or at\_risk. |
| `predicted_spend_tier` | Shopify's predicted spend for the customer over the next year: low, medium or high. |
| `customer_segment` | Each segment the customer is in. A customer in several counts under each, so totals overlap. |

## Filters

| Filter | Type | Description |
| - | - | - |
| `customer_id` | Text | The customer's Shopify ID. |
| `customer_email_domain` | Text | The part of the customer's email after the @, such as gmail.com. |
| `customer_language` | Text | The customer's language. |
| `customer_email_subscription_status` | Text | The customer's email marketing state, such as SUBSCRIBED or NOT\_SUBSCRIBED. |
| `customer_sms_subscription_status` | Text | The customer's SMS marketing state, such as SUBSCRIBED or NOT\_SUBSCRIBED. |
| `customer_product_subscription_status` | Text | Whether the customer has product subscriptions, such as ACTIVE or NEVER\_SUBSCRIBED. |
| `customer_number_of_orders` | Number | The number of orders the customer has placed, all time. |
| `customer_amount_spent` | Number | The customer's all-time spend, in your store's currency. |
| `customer_added_date` | Date | The day the customer was added, in your store's timezone. |
| `customer_first_order_date` | Date | The day the customer placed their first order, in your store's timezone. |
| `customer_last_order_date` | Date | The day the customer most recently placed an order, in your store's timezone. |
| `customer_cohort_month` | Date | The month of the customer's first order. |
| `customer_cohort_quarter` | Date | The quarter of the customer's first order. |
| `customer_cohort_week` | Date | The week of the customer's first order. |
| `customer_countries` | Text | Every country in the customer's addresses, as codes such as GB, US. |
| `customer_regions` | Text | Every state or province in the customer's addresses, such as US-CA, US-NY. |
| `customer_cities` | Text | Every city in the customer's addresses, with its country and region. |
| `second_order_month` | Text | The month of the customer's second order. |
| `first_order_has_subscription` | Yes or no | Whether the customer's first order included a subscription purchase. |
| `first_order_utm_medium` | Text | The UTM medium of the visit that led to the customer's first order. |
| `first_order_utm_campaign` | Text | The UTM campaign of the visit that led to the customer's first order. |
| `first_order_landing_page_url` | Text | The first page of the visit that led to the customer's first order. |
| `first_order_referrer_url` | Text | The site that sent the customer on the visit that led to their first order. |
| `first_order_delivery` | Text | How the customer's first order arrived: on\_time, late, no\_promise, not\_delivered or not\_fulfilled. Ours: set it beside repeat customer rate to see whether late deliveries cost repeat custom. |
| `customer_expected_next_order_date` | Date | The customer's last order date plus their usual gap between orders. Empty for one-time customers. |
| `predicted_spend_tier` | Text | Shopify's predicted spend for the customer over the next year: low, medium or high. |
| `customer_name` | Text | The customer's full name. |
| `customer_email` | Text | The customer's email address. |
| `customer_country` | Text | The country of the customer's default address. |
| `customer_tag` | Text | The customer's tags, comma separated. Use contains to match one tag. |
| `rfm_group` | Text | Shopify's RFM group, such as loyal. |
| `first_order_sales_channel` | Text | The sales channel of the customer's first order. |
| `first_order_utm_source` | Text | The UTM source of the visit that led to the customer's first order. |
| `customer_churn_risk` | Text | on\_track, due, overdue or one\_time. |
| `customer_account_status` | Text | The customer's account state, such as ENABLED. |
| `customer_segment` | Text | Customers in the segment: one row per order, so totals stay whole. |

## Linked records

Fields of the records this dataset reaches can be shown, grouped by and filtered on, written with a dot after the record (for example `customer.name`). Each record's page lists its fields.

| Write | Record | Reached through |
| - | - | - |
| `customer.<field>` | [Customer](https://docs.queryful.app/queryfulql/records/customer.md) | Customer |
| `customer.company.<field>` | [Company](https://docs.queryful.app/queryfulql/records/company.md) | Customer › Company |
| `shop.<field>` | [Store](https://docs.queryful.app/queryfulql/records/shop.md) | Store |

## Related datasets

* [Companies](https://docs.queryful.app/queryfulql/datasets/companies.md)
* [Customer segments](https://docs.queryful.app/queryfulql/datasets/segments.md)
* [Customer addresses](https://docs.queryful.app/queryfulql/datasets/customer_addresses.md)
* [Customer journey visits](https://docs.queryful.app/queryfulql/datasets/journey_visits.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.