> ## 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.

# Blocks dataset

> LayersQL Blocks dataset reference for analyzing recommendation block requests, impressions, clicks, and conversions across strategies and fallback chains.

* **Label:** Blocks
* **Description:** Analytics for recommendation block requests and conversions.
* **Default group key:** `block_id`

Use the blocks dataset to measure how your recommendation blocks perform, including how often they are requested, how many clicks and views they generate, and the sales they drive.

## Metrics

* **requests (requests)**
  * Number of block recommendation requests.
  * Example: COUNT\_DISTINCT(requests)
* **total\_sales (USD)**
  * Sales after discounts and before taxes/returns attributed to block recommendations.
  * Example: SUM(total\_sales)
* **quantity\_purchased (items)**
  * Number of items purchased from block recommendation traffic.
  * Example: SUM(quantity\_purchased)
* **click\_sessions (sessions)**
  * Sessions where a product from block recommendations was clicked.
  * Example: COUNT\_DISTINCT(click\_sessions)
* **view\_sessions (sessions)**
  * Sessions where a product was viewed from block recommendations.
  * Example: COUNT\_DISTINCT(view\_sessions)
* **cart\_sessions (sessions)**
  * Sessions where a product from block recommendations was added to cart.
  * Example: COUNT\_DISTINCT(cart\_sessions)
* **quantity\_added\_to\_cart (items)**
  * Items added to cart from block recommendations.
  * Example: SUM(quantity\_added\_to\_cart)

## Dimensions

* **block\_id:** The block identifier.
* **block\_title:** Title of the block at request time.
* **anchor\_type:** Anchor type of the block (product, collection, cart, none).
* **strategy\_type:** Strategy type used (interaction, similar\_products, manual).
* **strategy\_key:** Strategy key (e.g., recipe name for interaction strategy).
* **num\_results:** Number of results returned.
* **shopping\_channel:** The shopping channel (e.g., online\_store).
* **attribution\_token:** Token used to attribute downstream events/purchases back to this block request.
* **device\_type:** Device category.
* **geo\_country:** Two-letter country code.
* **geo\_state:** Up to three-letter province code.
* **geo\_city:** City name as captured.
* **marketing\_source:** UTM source.
* **marketing\_medium:** UTM medium.
* **marketing\_campaign:** UTM campaign.

## Examples

Block requests by block (last 7 days)

```sql theme={null}
FROM blocks
SHOW COUNT_DISTINCT(requests)
GROUP BY block_id
SINCE -7d
```

Revenue attributed to blocks by strategy (this month)

```sql theme={null}
FROM blocks
SHOW SUM(total_sales)
GROUP BY strategy_type
SINCE this_month
```

Click-through and sales for a specific anchor type

```sql theme={null}
FROM blocks
SHOW COUNT_DISTINCT(click_sessions), SUM(total_sales)
GROUP BY block_id
WHERE anchor_type = 'product'
SINCE -30d
```

Block performance by country (past 30 days)

```sql theme={null}
FROM blocks
SHOW COUNT_DISTINCT(requests), SUM(total_sales)
GROUP BY geo_country
SINCE past_30_days
```

## Next steps

* [LayersQL syntax](/platform/layersql/syntax)
* [LayersQL functions](/platform/layersql/functions)
* [Datasets overview](/platform/layersql/datasets)
