LayersQL is as a derivative of ShopifyQL but is deliberately
narrower in scope. It removes complexity in favor of a small, consistent
set of clauses and functions that make metrics easy to define, reuse,
and apply directly in merchandising workflows.
What you can do with LayersQL
Use LayersQL to create metrics and logic that can be reused in:- Merchandising rules — e.g., sort products by recent sales, views, or conversions.
- Custom scoring — combine metrics into weighted scores to power advanced sort orders.
- Performance tracking — define the same metrics you use in sort orders so they are visible in dashboards.
- Segmentation — break down performance by geography, marketing channel, or other dimensions to support localized merchandising.
Basic query structure
LayersQL uses a strict clause order to keep queries simple and predictable:FROM → SHOW → GROUP BY → [WHERE] → SINCE → [SEGMENT BY]
- FROM: Selects the dataset to build metrics from (e.g., products).
- SHOW: Defines which metrics or expressions to calculate (e.g.,
SUM(total_sales)
). - GROUP BY: Groups results by dimensions or identifiers (e.g.,
product_id
). - WHERE (optional): Filters rows before aggregation (e.g.,
geo_country = 'US'
). - SINCE: Sets the time window for the metric.
- SEGMENT BY (optional): Adds an additional dimension to further break down each group.
Example
This query creates a metric for 7-day product sales segmented by country:- displayed directly in the merchandising dashboard, and
- referenced in sort orders to rank products by recent sales.