Skip to main content
Use the same query standards from the SQL Query Library overview: is_order_sm_valid = TRUE for order analyses, sm_store_id scoping for multi-store setups, and your_project placeholders.
When reporting-currency conversion is enabled, ad_spend and platform-reported revenue fields use your workspace reporting currency for Google Ads, Meta, TikTok, AppLovin, and Snapchat. Accounts with different source currencies are converted separately before totals are combined. Other advertising sources stay in their native currency unless SourceMedium has enabled conversion for that surface. See Reporting Currency.
Click/impression-based ratios such as CPC, CTR, and CPM are only meaningful when the underlying click or impression metric is available. For TikTok, exclude ad_campaign_type = 'gmv_max' when you need ordinary TikTok Ads metrics because GMV Max rows can carry spend without clicks or impressions.
What you’ll learn: Ad spend per new customer, split by where the sale happened (sm_channel is the commerce sales channel: online DTC, Amazon, retail, wholesale, TikTok Shop). This is blended CAC: it divides all ad spend by all new customers, including customers who arrived with no ad spend behind them. For per-platform efficiency, use the ROAS template below.
What you’ll learn: Which ad platform and campaign type combinations are generating the best return on ad spend. Helps you decide where to allocate more budget and which underperforming campaigns to optimize or cut.
What you’ll learn: Which TikTok campaign types have spend, clicks, and impressions available. Use this before calculating CPC, CTR, or CPM across TikTok so GMV Max spend does not distort ordinary TikTok Ads metrics.
For TikTok Ads-only CPC, CTR, and CPM, add AND ad_campaign_type != 'gmv_max' to the WHERE clause.

Back to the SQL Query Library.

Messaging

Compare paid performance with owned-channel outcomes.

Orders & Revenue

Connect media efficiency to order and revenue quality.

Attribution & Data Health

Validate tracking quality before channel-level decisions.