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

# Sales by Layers Surface dataset

> LayersQL Sales by Layers Surface dataset reference for splitting total store sales between Search, Collections, Blocks & recommendations, and orders with no retained Layers attribution.

* **Label:** Sales by Layers Surface
* **Description:** Imported sales, with every line of each order assigned to the earliest retained Layers request credited for that order.
* **Default group key:** `order_surface`

Use this dataset when you need revenue figures that add up. Each order belongs to exactly one surface, so grouping by `order_surface` splits your total store sales without counting an order twice. The **Revenue by surface** card on the [Overview dashboard](https://docs.uselayers.com/help/analytics/dashboards.md#the-overview-dashboard) is built on this dataset.

## Metrics

* **revenue (USD)**
  * Line-item sales after line-item discounts, in the store's own currency: before taxes and shipping, and not reduced by refunds or cancellations.
  * Example: SHOW revenue
* **orders (orders)**
  * Distinct orders, each assigned to one surface.
  * Example: SHOW orders

## Dimensions

* **order\_surface:** The surface credited with the order. One of:
  * `Search`: the earliest credited request was a search.
  * `Collections`: the earliest credited request was a collection page.
  * `Blocks & recommendations`: the earliest credited request was a recommendation block.
  * `No retained Layers attribution`: the order has no Layers credit, or its credit is no longer retained.
* **transaction\_id:** Shopify order ID.

This dataset doesn't expose the shared [personalization dimensions](https://docs.uselayers.com/platform/layersql/datasets.md#personalization-dimensions-all-datasets). To segment sales by shopper context, use the [Sales dataset](https://docs.uselayers.com/platform/layersql/datasets/sales.md).

## How orders are assigned

When more than one Layers request is credited for an order, the order goes to the request that happened first. The whole order, including lines the shopper found another way, counts toward that surface. Because of this, the `Search` revenue here can differ from attributed revenue in the [Search (text)](https://docs.uselayers.com/platform/layersql/datasets/search-text.md) dataset, which credits individual line items.

Attribution for this dataset becomes available on the same schedule as other attributed metrics. See [Data freshness](https://docs.uselayers.com/platform/metrics.md#data-freshness).

## Examples

Total sales by surface (last 30 days)

```sql theme={null}
FROM order_surface_sales
SHOW revenue, orders
GROUP BY order_surface
SINCE -30d
```

Daily revenue credited to search

```sql theme={null}
FROM order_surface_sales
SHOW revenue
WHERE order_surface = 'Search'
SINCE -30d
TIMESERIES day
```

Revenue with retained Layers attribution, across all surfaces

```sql theme={null}
FROM order_surface_sales
SHOW revenue
WHERE order_surface != 'No retained Layers attribution'
SINCE -30d
```
