---
title: campaign_sales
description: >-
  Reference for the ShopifyQL `campaign_sales` table. Every metric and
  dimension, paired with worked example queries.
api_version: 2026-07
source_url:
  html: >-
    https://shopify.dev/docs/api/shopifyql/latest/schemas/marketing/campaign_sales
  md: >-
    https://shopify.dev/docs/api/shopifyql/latest/schemas/marketing/campaign_sales.md
api_name: shopifyql
---

# campaign\_​sales

The `campaign_sales` [schema](https://shopify.dev/docs/api/shopifyql/latest/schemas) captures order-level sales and customer outcomes attributed to marketing campaigns. It supports campaign order reporting across attribution models and traffic-source dimensions.

### Use cases

* **Attribution models**: Compare [`campaign_first_click_order_count`](#campaignsalesmetric-propertydetail-campaignfirstclickordercount), [`campaign_last_click_order_count`](#campaignsalesmetric-propertydetail-campaignlastclickordercount), and [`campaign_linear_order_count`](#campaignsalesmetric-propertydetail-campaignlinearordercount) for each campaign to see how the attribution model you pick shifts the orders credited to it.
* **UTM breakdown**: Group [`campaign_last_non_direct_click_order_count`](#campaignsalesmetric-propertydetail-campaignlastnondirectclickordercount) by [`utm_campaign`](#campaignsalesdimension-propertydetail-utmcampaign), [`utm_source`](#campaignsalesdimension-propertydetail-utmsource), or [`utm_medium`](#campaignsalesdimension-propertydetail-utmmedium) to see which sources and mediums drive attributed orders.
* **Customer type**: Split [`campaign_last_click_order_count`](#campaignsalesmetric-propertydetail-campaignlastclickordercount) by [`new_or_returning_customer`](#campaignsalesdimension-propertydetail-neworreturningcustomer) or [`customer_repeat_order`](#campaignsalesdimension-propertydetail-customerrepeatorder) to see whether a campaign wins new customers or repeat buyers.
* **Traffic source**: Use [`referring_channel`](#campaignsalesdimension-propertydetail-referringchannel), [`referring_platform`](#campaignsalesdimension-propertydetail-referringplatform), and [`traffic_type`](#campaignsalesdimension-propertydetail-traffictype) to classify campaign-attributed orders by traffic source.

Examples

### Examples

* ####

  ##### Description

  Compare one campaign's monthly orders under all four attribution models this year, with last-click plotted as a line. This example shows every model in the table for comparison while charting only \[\`campaign\_last\_click\_order\_count\`]\(#campaignsalesmetric-propertydetail-campaignlastclickordercount).

  ##### ShopifyQL

  ```shopifyql
  FROM campaign_sales
    SHOW campaign_last_non_direct_click_order_count,
      campaign_last_click_order_count, campaign_first_click_order_count,
      campaign_linear_order_count
    WHERE campaign_id = 12345678
    TIMESERIES month WITH TOTALS
    SINCE startOfYear(0y) UNTIL today
    ORDER BY month ASC
  VISUALIZE campaign_last_click_order_count TYPE line
  ```

* ####

  ##### Description

  Rank one campaign's top 20 referring channels this year by \`campaign\_last\_non\_direct\_click\_order\_count\`. This example uses \[\`WITH TOTALS\`]\(/docs/api/shopifyql/latest/syntax/with#total-columns) to add the campaign total to every row.

  ##### ShopifyQL

  ```shopifyql
  FROM campaign_sales
    SHOW campaign_last_non_direct_click_order_count,
      campaign_last_click_order_count, campaign_first_click_order_count,
      campaign_linear_order_count
    WHERE campaign_id = 12345678
    GROUP BY referring_channel WITH TOTALS
    SINCE startOfYear(0y) UNTIL today
    ORDER BY campaign_last_non_direct_click_order_count DESC
    LIMIT 20
  VISUALIZE campaign_last_non_direct_click_order_count TYPE horizontal_bar
  ```

* ####

  ##### Description

  Compare weekly order counts across all four attribution models this quarter, with last-click charted and the rest in the table beside it. This example uses \[\`WITH PERCENT\_CHANGE\`]\(/docs/api/shopifyql/latest/syntax/with#percent-change-columns) with \[\`COMPARE TO previous\_period\`]\(/docs/api/shopifyql/latest/syntax/compare-to) to show each week's change from the quarter before.

  ##### ShopifyQL

  ```shopifyql
  FROM campaign_sales
    SHOW campaign_last_click_order_count,
      campaign_last_non_direct_click_order_count, campaign_first_click_order_count,
      campaign_linear_order_count
    TIMESERIES week WITH PERCENT_CHANGE
    DURING this_quarter
    COMPARE TO previous_period
    ORDER BY week ASC
  VISUALIZE campaign_last_click_order_count TYPE line
  ```

* ####

  ##### Description

  Rank the 10 \`utm\_source\` values driving the most \`campaign\_last\_click\_order\_count\` last month. This example pairs \[\`ORDER BY\`]\(/docs/api/shopifyql/latest/syntax/order-by) \`campaign\_last\_click\_order\_count DESC\` with \`LIMIT 10\`, so the sort decides which 10 sources survive the cut.

  ##### ShopifyQL

  ```shopifyql
  FROM campaign_sales
    SHOW campaign_last_click_order_count
    GROUP BY utm_source WITH TOTALS
    DURING last_month
    ORDER BY campaign_last_click_order_count DESC
    LIMIT 10
  VISUALIZE campaign_last_click_order_count TYPE horizontal_bar
  ```

***

## Metrics

Counts and calculations that let you track key business indicators. Metrics show up as the columns when queried.

Metrics you can use when querying `FROM campaign_sales`.

* **campaign\_​first\_​click\_​order\_​count**

  **INTEGER**

  Count of orders for the first cross-device attribution model

* **campaign\_​first\_​click\_​total\_​average\_​order\_​value**

  **MONEY**

  Total average order value for the first click cross-device attribution model

* **campaign\_​first\_​click\_​total\_​sales**

  **MONEY**

  Total sales for the first cross-device attribution model

* **campaign\_​last\_​click\_​order\_​count**

  **INTEGER**

  The number of orders credited by last click attribution to the final marketing touchpoint before purchase.

* **campaign\_​last\_​click\_​total\_​average\_​order\_​value**

  **MONEY**

  Total average order value for the last click attribution model

* **campaign\_​last\_​click\_​total\_​sales**

  **MONEY**

  Total sales for the last click attribution model

* **campaign\_​last\_​non\_​direct\_​click\_​order\_​count**

  **INTEGER**

  Count of orders for the last non-direct click cross-device attribution model

* **campaign\_​last\_​non\_​direct\_​click\_​total\_​average\_​order\_​value**

  **MONEY**

  Total average order value for the last non-direct click cross-device attribution model

* **campaign\_​last\_​non\_​direct\_​click\_​total\_​sales**

  **MONEY**

  Total sales for the last non-direct cross-device attribution model

* **campaign\_​linear\_​order\_​count**

  **DECIMAL**

  The weighted number of orders under linear cross-device attribution. Values can include fractional order credit because linear attribution shares credit across campaign sessions.

* **campaign\_​linear\_​total\_​average\_​order\_​value**

  **MONEY**

  Total average order value using the linear cross-device attribution model

* **campaign\_​linear\_​total\_​sales**

  **MONEY**

  Total sales using the linear cross-device attribution model

* **campaign\_​first\_​click\_​average\_​order\_​value**

  **MONEY**

  **deprecated**

  Average order value for the first click cross-device attribution model

  `First click average order value = (gross sales - discounts) / orders`

  **Deprecated:**

  Deprecated since `2026-07`. Replaced by [`campaign_first_click_total_average_order_value`](#campaignsalesmetric-propertydetail-campaignfirstclicktotalaverageordervalue)

* **campaign\_​first\_​click\_​sales**

  **MONEY**

  **deprecated**

  Sales for the first cross-device attribution model

  `First click sales = gross sales - discounts`

  **Deprecated:**

  Deprecated since `2026-07`. Replaced by [`campaign_first_click_total_sales`](#campaignsalesmetric-propertydetail-campaignfirstclicktotalsales)

* **campaign\_​last\_​click\_​average\_​order\_​value**

  **MONEY**

  **deprecated**

  Average order value for the last click attribution model

  `Last click average order value = (gross sales - discounts) / orders`

  **Deprecated:**

  Deprecated since `2026-07`. Replaced by [`campaign_last_click_total_average_order_value`](#campaignsalesmetric-propertydetail-campaignlastclicktotalaverageordervalue)

* **campaign\_​last\_​click\_​sales**

  **MONEY**

  **deprecated**

  Sales for the last click attribution model

  `Last click sales = gross sales - discounts`

  **Deprecated:**

  Deprecated since `2026-07`. Replaced by [`campaign_last_click_total_sales`](#campaignsalesmetric-propertydetail-campaignlastclicktotalsales)

* **campaign\_​last\_​non\_​direct\_​click\_​average\_​order\_​value**

  **MONEY**

  **deprecated**

  Average order value for the last non-direct click cross-device attribution model

  `Last non-direct click average order value = (gross sales - discounts) / orders`

  **Deprecated:**

  Deprecated since `2026-07`. Replaced by [`campaign_last_non_direct_click_total_average_order_value`](#campaignsalesmetric-propertydetail-campaignlastnondirectclicktotalaverageordervalue)

* **campaign\_​last\_​non\_​direct\_​click\_​sales**

  **MONEY**

  **deprecated**

  Sales for the last non-direct cross-device attribution model

  `Last non-direct click sales = gross sales - discounts`

  **Deprecated:**

  Deprecated since `2026-07`. Replaced by [`campaign_last_non_direct_click_total_sales`](#campaignsalesmetric-propertydetail-campaignlastnondirectclicktotalsales)

* **campaign\_​linear\_​average\_​order\_​value**

  **MONEY**

  **deprecated**

  Average order value using the linear cross-device attribution model

  `Linear average order value = (gross sales - discounts) / orders`

  **Deprecated:**

  Deprecated since `2026-07`. Replaced by [`campaign_linear_total_average_order_value`](#campaignsalesmetric-propertydetail-campaignlineartotalaverageordervalue)

* **campaign\_​linear\_​sales**

  **MONEY**

  **deprecated**

  Sales using the linear cross-device attribution model

  `Linear sales = gross sales - discounts`

  **Deprecated:**

  Deprecated since `2026-07`. Replaced by [`campaign_linear_total_sales`](#campaignsalesmetric-propertydetail-campaignlineartotalsales)

### MONEY

A monetary amount representing currency values such as prices, revenue, costs, and discounts.

```ts
```

### INTEGER

A whole number without decimal places, used for counts, quantities, and other discrete numeric values.

```ts
```

### DECIMAL

A precise decimal number used for calculations where fixed-point precision matters.

```ts
```

***

## Dimensions

Attributes of your data that let you look more granularly at aspects of the data. Group and filter by dimensions to shape the rows your query returns.

Dimensions you can use when querying `FROM campaign_sales`.

* **campaign\_​id**

  **IDENTITY**

  The campaign identifier tied to the session that led to the order.

* **click\_​id\_​tag**

  **STRING**

  The tracking tag associated with the click ID for the campaign-driven session.

* **customer\_​id**

  **IDENTITY**

  The unique Shopify identifier for the customer on the order.

* **customer\_​repeat\_​order**

  **BOOLEAN**

  Indicates if this is a repeat order from the customer

* **day**

  **DAY\_TIMESTAMP**

  The day an order from a campaign-driven session was processed.

* **day\_​of\_​week**

  **DAY\_OF\_WEEK**

  The day of the week an order from a campaign-driven session was processed, with values Monday through Sunday.

* **hour**

  **HOUR\_TIMESTAMP**

  The hour an order from a campaign-driven session was processed.

* **hour\_​of\_​day**

  **HOUR\_OF\_DAY**

  The hour of day an order from a campaign-driven session was processed, with values 0 through 23.

* **is\_​first\_​cross\_​device**

  **BOOLEAN**

  Indicates if this is the first session in the customer journey across devices

* **is\_​last**

  **BOOLEAN**

  Indicates if this is the last session in the customer journey

* **is\_​last\_​non\_​direct\_​cross\_​device**

  **BOOLEAN**

  Indicates if this is the last non-direct session in the customer journey across devices

* **linear\_​model\_​attribution\_​weight\_​cross\_​device**

  **DECIMAL**

  The share of order credit assigned to the campaign-driven session by the linear cross-device model.

* **marketing\_​activity\_​url\_​parameter\_​key**

  **STRING**

  The URL parameter name tied to the marketing activity for the session. Values are free-text parameter keys from your campaign links.

* **marketing\_​activity\_​url\_​parameter\_​value**

  **STRING**

  The URL parameter value tied to the marketing activity for the session. Values are free text from your campaign links.

* **marketing\_​event\_​api\_​client\_​id**

  **IDENTITY**

  Identifier for the API client of the Marketing Event associated with the session

* **marketing\_​event\_​id**

  **IDENTITY**

  The marketing event identifier associated with the session that led to the order.

* **month**

  **MONTH\_TIMESTAMP**

  The month an order from a campaign-driven session was processed.

* **month\_​of\_​year**

  **MONTH\_OF\_YEAR**

  The month of year an order from a campaign-driven session was processed, with values 1 through 12.

* **new\_​or\_​returning\_​customer**

  **STRING**

  Whether an order came from the customer's first purchase (New) or a later purchase (Returning).

* **normalized\_​page\_​url**

  **STRING**

  The page URL for the session, with query parameters and fragments removed so the same page groups together. Use [`normalized_page_url`](#campaignsalesdimension-propertydetail-normalizedpageurl) to see which pages led to campaign-driven sales.

* **order\_​id**

  **IDENTITY**

  The unique Shopify identifier for the order. Use [`order_id`](#campaignsalesdimension-propertydetail-orderid) with [`order_name`](#campaignsalesdimension-propertydetail-ordername) to show readable order labels.

* **order\_​name**

  **STRING**

  Name of the order

* **order\_​processed\_​at**

  **TIMESTAMP**

  The exact date and time the order was processed, reported in your store's time zone.

* **quarter**

  **QUARTER\_TIMESTAMP**

  The quarter an order from a campaign-driven session was processed.

* **referrer\_​url**

  **STRING**

  The referring page that brought the visitor to your store. The same page groups together regardless of tracking parameters.

* **referring\_​channel**

  **STRING**

  Channel that led to an online store session

* **referring\_​medium**

  **STRING**

  Category of referring channel that led to an online store session

* **referring\_​platform**

  **STRING**

  Platform that led to an online store session

* **sa\_​token**

  **STRING**

  The session token tied to campaign attribution for the order.

* **shop\_​id**

  **IDENTITY**

  The unique Shopify identifier for your store. Use [`shop_id`](#campaignsalesdimension-propertydetail-shopid) with [`shop_name`](#campaignsalesdimension-propertydetail-shopname) to show readable store labels.

* **traffic\_​type**

  **STRING**

  The type of traffic that led to the online store session, such as Direct, Paid, Organic, or Unattributed.

* **utm\_​campaign**

  **STRING**

  The campaign name from the UTM tracking on the session. Values are free text from your campaign links.

* **utm\_​content**

  **STRING**

  UTM content associated with the session

* **utm\_​medium**

  **STRING**

  The medium value from the UTM tracking on the session. Values are free text from your campaign links.

* **utm\_​source**

  **STRING**

  The source value from the UTM tracking on the session. Values are free text from your campaign links.

* **utm\_​term**

  **STRING**

  The term value from the UTM tracking on the session. Values are free text from your campaign links, often used for keywords or search terms.

* **week**

  **WEEK\_TIMESTAMP**

  The week an order from a campaign-driven session was processed.

* **week\_​of\_​year**

  **WEEK\_OF\_YEAR**

  The week of year an order from a campaign-driven session was processed, with values 1 through 53.

* **year**

  **YEAR\_TIMESTAMP**

  The year an order from a campaign-driven session was processed.

* **customer\_​amount\_​spent**

  **MONEY**

  The customer's all-time spend is shown in your store's currency.

* **customer\_​last\_​order\_​date**

  **DAY\_TIMESTAMP**

  The day the customer most recently placed an order, reported in your store's time zone.

* **customer\_​number\_​of\_​orders**

  **INTEGER**

  Number of orders the customer has placed across all time

* **shop\_​name**

  **STRING**

  Name of your store

* **customer\_​first\_​order**

  **BOOLEAN**

  **deprecated**

  Indicates if this is the customer's first order

  **Deprecated:**

  Deprecated since `2026-04`. Field removed from data source

* **marketing\_​event\_​type**

  **STRING**

  **deprecated**

  Type of the marketing event

  **Deprecated:**

  Deprecated since `2026-04`. Field removed from data source

### IDENTITY

A unique identifier for a Shopify resource such as a customer, product, or order.

```ts
```

### STRING

A sequence of characters representing text data.

```ts
```

### BOOLEAN

A true or false value representing binary states.

```ts
```

### DAY\_TIMESTAMP

A date value truncated to day precision.

```ts
```

### DAY\_OF\_WEEK

A day within a week, used for weekday-based grouping and filtering.

```ts
```

### HOUR\_TIMESTAMP

A timestamp truncated to hour precision.

```ts
```

### HOUR\_OF\_DAY

An hour within a day, typically represented as an integer from 0 to 23.

```ts
```

### MONTH\_TIMESTAMP

A date value representing the start of a month.

```ts
```

### MONTH\_OF\_YEAR

A month number within a year.

```ts
```

### TIMESTAMP

A full-precision timestamp including date and time.

```ts
```

### QUARTER\_TIMESTAMP

A date value representing the start of a fiscal quarter.

```ts
```

### WEEK\_TIMESTAMP

A date value representing the start of a week.

```ts
```

### WEEK\_OF\_YEAR

A week number within a year.

```ts
```

### YEAR\_TIMESTAMP

A date value representing the start of a year.

```ts
```

***

## Related schemas

* [`campaign_products`](https://shopify.dev/docs/api/shopifyql/latest/schemas/marketing/campaign_products): Product-level attribution for the same campaigns when you want unit volume per product.
* [`campaign_sessions`](https://shopify.dev/docs/api/shopifyql/latest/schemas/marketing/campaign_sessions): Session-level funnel signals from the same campaigns.
* [`marketing_engagements`](https://shopify.dev/docs/api/shopifyql/latest/schemas/marketing/marketing_engagements): App-level engagement and ad spend metrics paired with attributed sales.

***
