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

# Metric recipes

> Pre-configured metric recipes for common LayersQL and ShopifyQL use cases — sales, views, carts, returns, and velocity — that you can copy into your store.

The platform provides pre-configured metric recipes that implement common use cases for both LayersQL and Imported metrics.

## Dashboard metric recipes

When you create a new store, Layers automatically provisions a set of default dashboard metrics on the **Overview** dashboard. These metrics give you an at-a-glance summary of key performance indicators without any manual setup.

Dashboard recipes include aggregate metrics for search, collections, orders, revenue, image search, similar products, and block recommendations. They are displayed as cards or tables depending on the metric type.

### Block analytics dashboard recipes

The following recipes track how your [recommendation blocks](/platform/blocks) perform. They are added to the Overview dashboard automatically for all stores.

**Block Impressions (30d)** — Card

```sql theme={null}
FROM blocks
SHOW COUNT(requests)
SINCE -30d
```

Total number of block recommendation requests over the last 30 days.

**Block Revenue (30d)** — Card

```sql theme={null}
FROM blocks
SHOW SUM(total_sales)
SINCE -30d
```

Total revenue attributed to block recommendations over the last 30 days.

**Block Conversion Rate (30d)** — Card

```sql theme={null}
FROM blocks
SHOW (COUNT_DISTINCT(cart_sessions) / NULLIF(COUNT_DISTINCT(requests),0)) * 100
SINCE -30d
```

Percentage of block recommendation requests that resulted in an add to cart over the last 30 days.

**Block Click Sessions (30d)** — Card

```sql theme={null}
FROM blocks
SHOW COUNT_DISTINCT(click_sessions)
SINCE -30d
```

Unique sessions where a product from block recommendations was clicked over the last 30 days.

**Top Blocks (30d)** — Table

```sql theme={null}
FROM blocks
SHOW COUNT(requests)
GROUP BY block_title
SINCE -30d
```

Your most-requested recommendation blocks over the last 30 days, ranked by request volume.

**Top Blocks by Revenue (30d)** — Table

```sql theme={null}
FROM blocks
SHOW SUM(total_sales)
GROUP BY block_title
SINCE -30d
```

Recommendation blocks generating the most revenue over the last 30 days.

<Note>
  Block analytics recipes query the [blocks dataset](/platform/layersql/datasets/blocks). You need the [Storefront Pixel](/shopify-integration/storefront-pixel) installed to track block interactions and attribute revenue.
</Note>

### Geographic dashboard recipes

These recipes show where search demand is concentrated geographically. They use the `geo_bar` chart type, which renders a ranked horizontal bar chart and resolves two-letter country codes (for example, `US`) into full country names (`United States`). Bars are sorted in descending order by search volume, and `LIMIT 12` keeps the chart readable on dashboard tiles.

**Searches by Country (30d)** — Geo bar

```sql theme={null}
FROM search_text
SHOW COUNT(requests) AS searches
WHERE geo_country IS NOT NULL
GROUP BY geo_country
SINCE -30d
VISUALIZE searches TYPE geo_bar BY geo_country LIMIT 12
```

Search request volume grouped by shopper country over the last 30 days. Use this to identify the markets driving the most search demand.

**Searches by State/Region (30d)** — Geo bar

```sql theme={null}
FROM search_text
SHOW COUNT(requests) AS searches
WHERE geo_state IS NOT NULL
GROUP BY geo_state
SINCE -30d
VISUALIZE searches TYPE geo_bar BY geo_state LIMIT 12
```

Search request volume grouped by shopper state or region over the last 30 days. Use this to spot regional demand within the countries you serve.

<Note>
  Geographic recipes query the [search (text) dataset](/platform/layersql/datasets/search-text) and rely on the `geo_country` and `geo_state` fields captured with each search request. Rows without geo data are excluded.
</Note>

### Product engagement dashboard recipes

These recipes summarize shopper interaction with product tiles. They query the [products dataset](/platform/layersql/datasets/products) and depend on `product_impression`, `product_hover`, and `product_touch` events emitted by the [Storefront Pixel](/shopify-integration/storefront-pixel) or sent through the [Tracking API](/tracking-api/send-events).

**Product Impressions (30d)** — Card

```sql theme={null}
FROM products
SHOW product_impressions
SINCE -30d
COMPARE TO previous_period
```

Total tracked product impression events over the last 30 days, with the previous-period delta.

**Top Products by Impressions (30d)** — Table

```sql theme={null}
FROM products
SHOW product_impressions
GROUP BY product
SINCE -30d
```

Products ranked by tracked impression events over the last 30 days.

**Product Hover Rate (30d)** — Card

```sql theme={null}
FROM products
SHOW hover_rate
SINCE -30d
COMPARE TO previous_period
```

Tracked product hovers divided by impressions over the last 30 days. Indicates how often shoppers explore tiles on desktop.

**Product Touch Rate (30d)** — Card

```sql theme={null}
FROM products
SHOW touch_rate
SINCE -30d
COMPARE TO previous_period
```

Tracked product touches divided by impressions over the last 30 days. Indicates tile engagement on mobile.

## Product-level metric recipes

## LayersQL metric recipes

**Total Sales (7 days)**

```sql theme={null}
FROM products
SHOW SUM(total_sales)
GROUP BY product_id
SINCE -7d
```

Revenue tracked by Layers over the last 7 days. Use for merchandising based on search-driven conversions.

**Total Sales - Variant Level (7 days)**

```sql theme={null}
FROM products
SHOW SUM(total_sales)
GROUP BY product_id, variant_id
SINCE -7d
```

Revenue tracked by Layers at the variant level. When used with variant breakouts, variant tiles sort by their individual sales while product tiles sort by total product sales.

**Total Quantity (7 days)**

```sql theme={null}
FROM products
SHOW SUM(quantity_purchased)
GROUP BY product_id
SINCE -7d
```

Number of items purchased in the last 7 days. Ideal for identifying high-volume products.

**View Sessions (7 days)**

```sql theme={null}
FROM products
SHOW COUNT_DISTINCT(view_sessions)
GROUP BY product_id
SINCE -7d
```

Unique product view sessions in the last 7 days. Track product visibility and interest.

**Cart Sessions (7 days)**

```sql theme={null}
FROM products
SHOW COUNT_DISTINCT(cart_sessions)
GROUP BY product_id
SINCE -7d
```

Unique add-to-cart sessions in the last 7 days. Measure purchase intent.

## Imported (ShopifyQL) metric recipes

**Return Rate (7 days)** - Refresh: Daily

```sql theme={null}
FROM sales
SHOW product_id, returned_quantity_rate
WHERE product_id IS NOT NULL
GROUP BY product_id
SINCE -7d UNTIL today
```

Percentage of returned items from Shopify. Identify products with quality or sizing issues.

**Average Sales Price (7 days)** - Refresh: Daily

```sql theme={null}
FROM sales
SHOW product_id, average_order_value
WHERE product_id IS NOT NULL
GROUP BY product_id
SINCE -7d UNTIL today
```

Average order value after discounts. Understand actual selling prices vs. list prices.

**Revenue (7 days)** - Refresh: Daily

```sql theme={null}
FROM sales
SHOW product_id, net_sales
WHERE product_id IS NOT NULL
GROUP BY product_id
SINCE -7d UNTIL today
```

Net sales (sales minus returns) from Shopify. Authoritative revenue for financial merchandising.

**Sales Velocity** - Refresh: Daily

```sql theme={null}
FROM sales
SHOW product_id, (net_items_sold / 168) as sales_velocity_per_hour
WHERE product_id IS NOT NULL
GROUP BY product_id
SINCE -7d UNTIL today
```

Units sold per hour from 7-day Shopify data. Track product momentum and trending items.

<Note>
  These recipes are available in your Layers dashboard. Go to the **Metrics** section and select from the recipe library to install and customize them for your specific requirements.
</Note>
