SmashGL Reference

~10 min read

SmashGL (Smash Goal Language) is dashboardSMASHBOARD's goal-first query language for configuring each card. It extends ShopifyQL with additional clauses that control time windows, comparison modes, goal tracking, sparkline smoothing, and visualization rendering.

The Simple tab in the card editor writes SmashGL automatically. This reference is for users who want to write or customise queries directly in the Code tab.

Query Structure

A SmashGL query has two blocks separated by the DEFINE keyword:

-- Intent block: what to measure and how to display it
SMASH <vizType> [<flags>]
[GOAL <variable> <operator>]
WINDOW <period>
[COMPARE <mode>]
[SMOOTH <algorithm>]
[NAME "<label>"]
-- Data body: where the data comes from
DEFINE <variable>
  FROM <source>
  SHOW <metrics>
  [GROUP BY <dimension>]
  [ORDER BY <field> ASC|DESC]
  [LIMIT <n>]

SMASH must be the first non-empty line. DEFINE marks the boundary between the intent block and the data body. FROM and SHOW are required inside DEFINE.

SMASH — Visualization and Flags

The opening clause. Declares the visualization type and optional display flags.

SMASH <vizType> [<flag> ...]

vizType

ValueDescription
metricLarge hero number with OKR goal block and vs-prior comparison pill
sparklineHero number + delta pill + trend line chart
chartFull-width chart variant (alias for sparkline)
barHorizontal bar chart with optional goal line
tableRanked rows (used by Top Products)
gaugeArc/dial showing progress toward a goal
badgeSimple large-number display

Flags

Optional display features listed on the same line as SMASH. Two modes:

FlagDescriptionRequires
TRENDHistorical sparkline alongside the hero numberGROUP BY day in DEFINE block
FORECASTForward projection pill + dashed sparklineGOAL + fixed or named window
ALERTRAG pulse on card border keyed to goal statusGOAL
RISKPace-to-goal indicator: At risk / On pace / AheadGOAL + fixed or named window
GAPGap to goal — value remnant + time remnantGOAL

Custom ALERT colours — provide exactly 3 hex values (red, amber, green) to override defaults:

ALERT(#ef4444,#f59e0b,#22c55e)

GOAL — Target Tracking

Sets a goal for the card. Optional — without it, the card shows the metric and vs-prior comparison only.

GOAL <variable> <operator>

The <variable> must match the identifier on the DEFINE line.

Relative Goal

The goal is calculated as N% above or below the comparison period's value. Adjusts automatically every period.

GOAL revenue +10%
GOAL returns -5%

Absolute Goal

A fixed target value, regardless of historical performance.

GOAL orders >= 15500
GOAL revenue >= 50000

Supported operators: >=, <=, >, <, =

WINDOW — Time Range

Defines the time period for the current data window. Required.

WINDOW <period>
SyntaxPeriod
WINDOW 7dLast 7 days (rolling)
WINDOW 30dLast 30 days (rolling)
WINDOW NdLast N days (rolling)
WINDOW NwLast N weeks (rolling)
WINDOW startOfWeekFrom the start of the current calendar week to today
WINDOW startOfMonthFrom the 1st of the current month to today
WINDOW startOfQuarterFrom the start of the current quarter to today
WINDOW startOfYearFrom January 1st to today
WINDOW 2026-03-01From that date to today (rolling from a fixed start)
WINDOW 2026-03-01 2026-03-15Fixed range between two dates

COMPARE — Comparison Mode

Controls which period to compare against for % change calculations. Optional — defaults to previousPeriod.

ValueComparison period
previousPeriodEqual-length window immediately before the current window (default)
previousYearSame date range, exactly 12 months earlier
sameDayLastWeekSame date range, shifted back 7 days

SMOOTH — Sparkline Smoothing

Applies a smoothing algorithm to the sparkline trend data. Does not affect the headline KPI value. Optional.

ValueDescription
rolling77-day rolling average
rolling1414-day rolling average
rolling3030-day rolling average
ema7Exponential moving average, 7-period span — recent days weighted more
ema14Exponential moving average, 14-period span

NAME — Card Label

Sets the display label shown as the card title on the dashboard. Optional — defaults to the card type name.

NAME "March Revenue"

DEFINE — Data Source

Declares the named variable and the data body that populates it. Required.

DEFINE <variable>
  FROM <source>
  SHOW <metrics>
  [GROUP BY <dimension>]
  [ORDER BY <field> ASC|DESC]
  [LIMIT <n>]

The variable name on the DEFINE line must match the variable in the GOAL clause.

FROM — Data source

SourceData available
salesNet sales, gross sales, orders, items sold
sessionsOnline store visitors

SHOW — Metrics

FROM sales:

FieldTypeDescription
net_salesCurrencyRevenue after discounts, returns, and taxes
gross_salesCurrencyRevenue before discounts and returns
ordersIntegerNumber of orders
net_items_soldIntegerNet quantity of items sold (after returns)

FROM sessions:

FieldTypeDescription
online_store_visitorsIntegerUnique visitors to the online store

The first metric in SHOW is the primary KPI (hero number). Additional metrics appear as supplementary stats.

AOV: Including both net_sales and orders in SHOW automatically calculates Average Order Value as net_sales ÷ orders.

Complete Examples

Revenue — monthly target, vs. last year

SMASH metric ALERT
GOAL revenue >= 50000
WINDOW startOfMonth
COMPARE previousYear
NAME "March Revenue"
DEFINE revenue
  FROM sales
  SHOW net_sales, gross_sales

Orders — rolling 30 days, grow 15%

SMASH metric TREND ALERT
GOAL orders +15%
WINDOW 30d
NAME "Orders"
DEFINE orders
  FROM sales
  SHOW orders

Revenue Trend — sparkline with 7-day smoothing

SMASH sparkline TREND
WINDOW 30d
SMOOTH rolling7
NAME "Revenue Trend"
DEFINE revenue
  FROM sales
  SHOW net_sales
  GROUP BY day
  ORDER BY day ASC

AOV — rolling 30 days, gauge with absolute goal

SMASH gauge
GOAL aov >= 85
WINDOW 30d
NAME "Avg Order Value"
DEFINE aov
  FROM sales
  SHOW net_sales, orders

AOV is calculated automatically when both net_sales and orders are in SHOW.

Store Sessions — this quarter, all goal indicators

SMASH metric TREND FORECAST ALERT RISK GAP
GOAL sessions >= 10000
WINDOW startOfQuarter
COMPARE previousYear
NAME "Q1 Sessions"
DEFINE sessions
  FROM sessions
  SHOW online_store_visitors
  GROUP BY day

Top Products — last 90 days

SMASH table
WINDOW 90d
NAME "Top Products (90d)"
DEFINE products
  FROM sales
  SHOW gross_sales
  GROUP BY product_title
  ORDER BY gross_sales DESC
  LIMIT 10

BFCM — fixed date range with forecast

SMASH metric ALERT FORECAST GAP
GOAL revenue >= 25000
WINDOW 2026-11-27 2026-11-30
NAME "BFCM Revenue"
DEFINE revenue
  FROM sales
  SHOW net_sales, orders

SmashGL vs. ShopifyQL

FeatureSmashGLShopifyQL
Shopify data tables
GOAL clause
WINDOW / COMPARE
SMASH visualization control
Sparkline smoothing (SMOOTH)
Embedded in dashboardSMASHBOARD

Validation Rules

A SmashGL query is valid when:

  1. SMASH <vizType> is the first non-empty line
  2. WINDOW is present in the intent block
  3. DEFINE <variable> is present
  4. If GOAL is present, the variable name must match the identifier on the DEFINE line
  5. <vizType> is one of: gauge, badge, chart, bar, metric, sparkline, table

Warnings (query still runs):

Next Steps

Still need help?