Most Shopify dashboards tell you revenue. Few tell you whether the customers you won in March ever came back. If your Shopify orders already land in BigQuery, one query answers it.
It builds a monthly cohort table: for each first-purchase month, what share of those customers ordered again 1, 2, 3, 6 and 12 months later.
WITH orders AS ( SELECT customer_id, DATE(created_at) AS order_date FROM `project.dataset.orders` WHERE financial_status IN ('paid', 'partially_refunded') AND cancelled_at IS NULL AND NOT COALESCE(test, FALSE) AND customer_id IS NOT NULL ), cohorts AS ( SELECT customer_id, DATE_TRUNC(MIN(order_date), MONTH) AS cohort_month FROM orders GROUP BY customer_id ), activity AS ( SELECT c.cohort_month, DATE_DIFF(DATE_TRUNC(o.order_date, MONTH), c.cohort_month, MONTH) AS months_since_first, o.customer_id FROM orders o JOIN cohorts c USING (customer_id) ) SELECT cohort_month, COUNT(DISTINCT IF(months_since_first = 0, customer_id, NULL)) AS cohort_size, ROUND(SAFE_DIVIDE(COUNT(DISTINCT IF(months_since_first = 1, customer_id, NULL)), COUNT(DISTINCT IF(months_since_first = 0, customer_id, NULL))) * 100, 1) AS pct_active_month_1, ROUND(SAFE_DIVIDE(COUNT(DISTINCT IF(months_since_first = 3, customer_id, NULL)), COUNT(DISTINCT IF(months_since_first = 0, customer_id, NULL))) * 100, 1) AS pct_active_month_3 FROM activity GROUP BY cohort_month ORDER BY cohort_month DESC; Swap project.dataset.orders for your own orders table. Add more pct_active_month_N columns the same way for months 2, 6 and 12.
What the filters are doing
-
financial_status IN ('paid', 'partially_refunded')drops unpaid and fully refunded orders, which would inflate retention. -
cancelled_at IS NULLand thetestcheck remove cancelled and test orders. -
customer_id IS NOT NULLdrops guest checkouts. If most of your orders are guest orders, key on a hashed email instead.
How to read it
Compare the month 1 column across cohorts. If a cohort from a big promo has a much lower month 1 number than a normal month, the promo bought one-time buyers. That is the number to look at before you raise ad spend.
I bundled this with the other queries I use on Shopify data (daily revenue, customer LTV, sell-through, a BFCM recap and a setup guide) in one pack: https://kushalkshah.gumroad.com/l/ecom-sql-pack
Questions on adapting the query to your schema are welcome in the comments.

