Custom SmashGL Cards
~6 min readEvery card in dashboardSMASHBOARD is powered by a SmashGL query. For most use cases, the Simple tab generates that query for you. But if you want to go beyond the built-in templates — custom metrics, non-standard aggregations, or fully bespoke goals — you can write SmashGL directly in the Code tab.
Templated Cards vs. Custom SmashGL Cards
| Simple tab | Code tab |
|---|---|
| Point-and-click configuration | Write SmashGL directly |
| Works for all built-in card types | Unlocks any metric, aggregation, or grouping |
| Query is generated for you | You write (and own) the query |
| Limited to supported fields per card type | Full ShopifyQL field access inside DEFINE |
You can switch between Simple and Code at any time — the Code tab always shows the current query, even when generated from Simple settings.
Using the Code Tab
- Open a dashboard and click Add Card.
- Select any card type and click through to the card editor.
- Click the Code tab.
- Write or paste your SmashGL query.
- Click Preview to see a live render with real data.
- Click Save to add the card to your dashboard.
You can also open any existing card and switch to the Code tab to see or edit its underlying query.
SmashGL Query Structure
A SmashGL query has two parts: an intent block that declares what you want to show and how, and a DEFINE block that describes the data using ShopifyQL.
SMASH <vizType> [flags]
GOAL <variable> <operator> <value>
WINDOW <period>
COMPARE <mode>
NAME "<label>"
DEFINE <variable>
FROM <table>
SHOW <fields>
The intent block (everything before DEFINE) is SmashGL. The body inside DEFINE is ShopifyQL, passed directly to the Shopify API.
A Minimal Custom Card
This card tracks net revenue over the last 30 days with a 10% growth goal:
SMASH metric TREND ALERT
GOAL revenue >= 12000
WINDOW 30d
COMPARE previousPeriod
NAME "Revenue — Last 30 Days"
DEFINE revenue
FROM sales
SHOW net_sales
Common Patterns
Sparkline with a rolling window
SMASH sparkline
GOAL orders +10%
WINDOW 7d
COMPARE previousPeriod
NAME "Orders — Last 7 Days"
DEFINE orders
FROM sales
SHOW orders
Top products table
SMASH table
WINDOW 30d
NAME "Top Products by Revenue"
DEFINE revenue
FROM sales
SHOW product_title, net_sales
GROUP BY product_title
ORDER BY net_sales DESC
LIMIT 10
Gauge with an absolute goal
SMASH gauge
GOAL revenue >= 50000
WINDOW startOfMonth
COMPARE previousYear
NAME "Monthly Revenue vs Goal"
DEFINE revenue
FROM sales
SHOW net_sales
AOV card (automatically calculated)
When both net_sales and orders are in SHOW, SmashGL automatically calculates AOV as net_sales / orders:
SMASH metric
GOAL aov +5%
WINDOW 30d
COMPARE previousPeriod
NAME "AOV — Last 30 Days"
DEFINE aov
FROM sales
SHOW net_sales, orders
Available Fields
Sales (FROM sales)
| Field | What it returns |
|---|---|
net_sales |
Revenue after discounts and returns |
gross_sales |
Revenue before discounts |
orders |
Order count |
net_items_sold |
Net quantity of items sold |
product_title |
Product name (use with GROUP BY) |
Sessions (FROM sessions)
| Field | What it returns |
|---|---|
online_store_visitors |
Unique visitor session count |
For the complete field reference, WINDOW syntax, COMPARE modes, and all SmashGL clauses, see the SmashGL reference.
Tips
- Use Preview often. The preview renders with live store data so you can see exactly what the card will look like before saving.
- The Simple tab generates valid SmashGL. If you want to learn the syntax, configure a card in Simple mode, then switch to Code to see what it produced.
- GOAL is optional. Omit it for data-only cards like Top Products tables where goal tracking doesn't apply.
- COMPARE is optional. Omit it if you don't need a period-over-period delta.
Next Steps
Still need help?