To compare Shopify sales with what you spend on ads, load the Shopify pipeline and your ad pipelines into PostgreSQL, sum cost across the ad rows per day, and divide one revenue column from the Shopify rows by it. When the Shopify connector is available, each Shopify row is one store and one local day, and carries gross_sales, discounts, refunds, net_sales, shipping, taxes, total_sales, orders and units as platform columns. Shopify rows have no cost, clicks or conversions, so the spend side always comes from the ad platforms. Choose your revenue column before you start, and keep in mind that Shopify gives the app only the last 60 days of orders.
What a Shopify row holds
Every figure counts on the day the order was placed, in the store's own time zone. Test orders and cancelled orders are left out. A day with no counted order gets no row at all.
| Column in PostgreSQL | What it is |
|---|---|
extra.orders |
Orders placed that day |
extra.gross_sales |
Product sales before discounts and returns, without tax and shipping |
extra.discounts |
Order and line discounts, before returns, without tax |
extra.refunds |
Money refunded on that day's orders: goods, shipping and tax |
extra.net_sales |
Product sales after discounts, returns and order edits, without tax and shipping |
extra.shipping |
Shipping charged after refunds and discounts, without tax |
extra.taxes |
Tax after returns and refunds |
extra.total_sales |
The orders' total price after returns, with tax and shipping |
extra.units |
Items ordered, before returns |
extra.revenue |
The same number as extra.net_sales |
Because refunds includes refunded shipping and tax, gross sales minus discounts minus refunds does not equal net sales. Use net_sales or total_sales as they are. The money fields guide explains how each one is worked out from Shopify's order amounts.
The common columns are there too: date, network (the value shopify), account_id (the store's .myshopify.com address), account_name and currency. On the ad platforms' rows, cost is in the ad account's own currency.
Pick one revenue definition first
Shopify's Finance reports define net sales as gross sales minus discounts and returns, without shipping and tax. Total sales adds taxes, shipping and fees back. etlmcp's net_sales and total_sales follow the same split. Use one in your ratio and keep it: net sales against spend is lower than total sales against spend, so switching breaks the trend.
Shopify Analytics and etlmcp put returns on different days. Shopify's Finance reports put a return on the day the refund is processed, as a negative amount. etlmcp puts it on the day the original order was placed, by lowering that day's net_sales and total_sales. A routine sync pulls the last 58 days of the store again, so the figures for recent days fall as refunds and edits come in. A month in etlmcp therefore matches Shopify's report only once refunds have settled, and only if you compare the same definition. Comparing etlmcp Shopify sales with Shopify Analytics goes through a reconciliation.
The query
PostgreSQL keeps a platform column's dotted name, extra.net_sales, so you must write it in double quotes. Without them, PostgreSQL reads extra as a table name. The example below assumes the Shopify pipeline loads marketing.shopify_daily and your ad pipelines load marketing.ad_daily. Several pipelines can write to one table, because each run replaces only its own pipeline's rows for its dates.
WITH sales AS (
SELECT date, currency,
SUM("extra.net_sales") AS net_sales,
SUM("extra.orders") AS orders
FROM marketing.shopify_daily
WHERE network = 'shopify'
GROUP BY date, currency
),
spend AS (
SELECT date, currency, SUM(cost) AS ad_spend
FROM marketing.ad_daily
WHERE network <> 'shopify'
GROUP BY date, currency
)
SELECT COALESCE(s.date, a.date) AS date,
COALESCE(s.currency, a.currency) AS currency,
COALESCE(s.net_sales, 0) AS net_sales,
COALESCE(s.orders, 0) AS orders,
COALESCE(a.ad_spend, 0) AS ad_spend,
s.net_sales / NULLIF(a.ad_spend, 0) AS sales_per_ad_dollar,
a.ad_spend / NULLIF(s.orders, 0) AS ad_spend_per_order
FROM sales s
FULL OUTER JOIN spend a ON a.date = s.date AND a.currency = s.currency
ORDER BY 1, 2;
The full outer join keeps days with spend and no orders, since Shopify sends no row for them. Joining on currency keeps amounts in different currencies apart: if one output day has two rows, an ad account bills in another currency than the store. Convert that cost first with the fx rule in the ad pipeline, so every amount is in the store's currency. To read the ratio over weeks instead of days, group by date_trunc('week', date) in both parts, because single days swing with how orders and spend fall around midnight.
Shopify dates its rows in the store's time zone. Check that your ad accounts report in the same zone, or a late-evening order and the click that led to it can land on different days.
History: 60 days of orders
Shopify's Order reference says that by default an app can read only the last 60 days of a store's orders. Older ones need Shopify to approve the app for all orders. etlmcp asks only for the standard orders permission, so a Shopify run reaches back about 60 days. A backfill that starts earlier is shortened to the oldest day Shopify serves, and one that lies wholly before it fails. Rows already in your table stay, so start the Shopify pipeline early: it builds up a longer history day by day while your ad pipelines may reach much further back. Compare only the dates both sides cover.
MER vs platform ROAS covers what the ratio tells you.