Skip to main content

Overview

Metrics in Layers are quantifiable measurements of product performance that enable data-driven merchandising and sorting decisions. The platform supports two types of metrics, each designed for different use cases and data sources.

Metric Types

LayersQL Metrics

LayersQL metrics are computed from Layers’ internal analytics data, including user behavior tracked through the Storefront Pixel and search interactions. These metrics provide real-time insights into how customers engage with your products through the Layers platform. Key characteristics:
  • Built using the LayersQL query language
  • Powered by Layers’ behavioral analytics data
  • Support segmentation by dimensions (country, marketing channel, etc.)
  • Real-time computation from search, browse, and interaction events
  • Ideal for metrics like views, add-to-carts, and search-driven conversions
Example LayersQL metric:
FROM products
SHOW SUM(total_sales)
GROUP BY product_id
SINCE -7d
This metric calculates total sales tracked by Layers over the last 7 days, grouped by product.

Imported (ShopifyQL) Metrics

Imported metrics leverage Shopify’s native analytics data through ShopifyQL queries. These metrics provide access to Shopify’s comprehensive sales data, including information not available through Layers’ analytics like returns, refunds, and detailed financial metrics. Key characteristics:
  • Built using full ShopifyQL syntax
  • Powered by Shopify’s native sales and analytics data
  • Automatically refreshed on a configurable schedule (hourly, daily, weekly)
  • Access to Shopify-specific metrics like return rates, net sales, and order values
  • Must include product_id in the query results for proper product association
Example Imported metric:
FROM sales
SHOW product_id, returned_quantity_rate
WHERE product_id IS NOT NULL
GROUP BY product_id
SINCE -7d UNTIL today
This metric imports Shopify’s return rate data for products over the last 7 days, refreshed daily. Important requirements for Imported metrics:
  • The ShopifyQL query must return a product_id column
  • Only one metric value column (besides product_id) should be returned
  • Queries must specify a refresh frequency: hourly, daily, or weekly

What you can do with metrics

In Sort Orders

Use metrics as sorting criteria to automatically rank products based on performance. Create weighted combinations of multiple metrics to develop sophisticated ranking algorithms that balance different business objectives. Examples:
  • Sort by recent conversion rate to surface high-performing products
  • Combine sales velocity with inventory levels for intelligent restocking
  • Weight revenue metrics alongside engagement metrics for balanced merchandising

In Merchandising Rules

View real-time metrics while creating or editing merchandising rules to make informed decisions about product placement, pins, and boosts. Metrics provide the quantitative foundation for manual merchandising decisions. Examples:
  • Pin products with high return rates to the bottom of collections
  • Boost products with strong revenue per view in key collections
  • Demote products with declining sales velocity

Common Metric Use Cases

Behavioral Metrics (LayersQL)

  • View Sessions: Unique sessions where products were viewed
  • Cart Sessions: Unique sessions where products were added to cart
  • Purchases: Total purchases tracked through Layers
  • Conversion Rate: Percentage of viewers who purchased
  • Click-Through Rate: Percentage of impressions that resulted in clicks

Financial Metrics (Imported/ShopifyQL)

  • Net Sales/Revenue: Sales minus returns from Shopify data
  • Return Rate: Percentage of items returned
  • Average Order Value: Average price per transaction
  • Sales Velocity: Units sold per time period
  • Gross Margin: Profit margins from Shopify financial data

Common Metric Recipes

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

LayersQL Metric Recipes

Total Sales (7 days)
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 Quantity (7 days)
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)
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)
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
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
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
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
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.
These recipes are available in your Layers dashboard. Navigate to the Metrics section and select from the recipe library to install and customize them for your specific requirements.

Creating Custom Metrics

Creating a LayersQL Metric

  1. Navigate to Metrics in your Layers dashboard
  2. Click “Create Metric”
  3. Select “LayersQL” as the metric type
  4. Write your LayersQL query following the syntax: FROM → SHOW → GROUP BY → SINCE
  5. Optionally add WHERE clauses for filtering or SEGMENT BY for dimensional breakdowns
  6. Name your metric and save

Creating an Imported Metric

  1. Navigate to Metrics in your Layers dashboard
  2. Click “Create Metric”
  3. Select “Imported (ShopifyQL)” as the metric type
  4. Write your ShopifyQL query ensuring it includes product_id
  5. Set the refresh frequency (hourly, daily, or weekly)
  6. Name your metric and save
The system will automatically execute the ShopifyQL query against your Shopify store and refresh the data according to your specified frequency.

Metric Refresh and Updates

LayersQL metrics update in real-time as behavioral data flows through the Layers analytics pipeline. There is no manual refresh required. Imported metrics refresh automatically based on their configured schedule:
  • Hourly: Updated every hour for time-sensitive metrics
  • Daily: Updated once per day, ideal for most sales metrics
  • Weekly: Updated weekly for slower-moving or historical metrics
You can manually trigger a refresh for any Imported metric from the metric details page in your dashboard.

Best Practices

Choosing Between Metric Types

Use LayersQL metrics when:
  • You need real-time behavioral data from search and browse interactions
  • Segmentation by marketing channel or geography is important
  • The metric is based on user engagement (views, clicks, searches)
Use Imported metrics when:
  • You need Shopify’s authoritative sales and financial data
  • Return rates, refunds, or detailed order information is required
  • Daily or periodic updates are sufficient

Query Optimization

  • Keep time windows reasonable (7-30 days) to balance freshness with data volume
  • Use WHERE clauses to pre-filter data before aggregation
  • For Imported metrics, avoid queries that return excessive rows
  • Test queries on a subset of data before deploying to production

Naming Conventions

  • Include the time window in the metric name (e.g., “Sales 7d”, “Returns 30d”)
  • Use clear, descriptive names that indicate the metric’s purpose
  • Distinguish between LayersQL and Imported metrics in naming when helpful

Where metrics show up

  • Sort Orders: Add metric-based conditions and weights to control product ranking
  • Merchandising Rules: Preview live metrics as you pin, boost, or group products
  • Analytics Dashboard: Track metric trends over time for performance monitoring
  • Product Details: View individual product metric values for manual merchandising

Learn more

I