Not all traffic is equal. Customers from Google Ads might have a different average order value than those from Instagram or email. This query breaks down AOV by referring source so you can allocate marketing budget smarter.
This is part of the Taptic Data Shopify query library. Explore related queries: SQL query for Shopify revenue by month, SQL query for Shopify customer lifetime value, SQL query for Shopify refund rate by product, and more.
The question
The SQL Taptic generates
SELECT COALESCE(NULLIF(o.referring_site, ''), 'Direct / Unknown') AS traffic_source, COUNT(DISTINCT o.id) AS orders, COUNT(DISTINCT o.customer_id) AS unique_customers, ROUND(SUM(o.total_price)::numeric, 2) AS total_revenue, ROUND(AVG(o.total_price)::numeric, 2) AS avg_order_value, ROUND(SUM(o.total_price)::numeric / NULLIF(COUNT(DISTINCT o.customer_id), 0), 2) AS revenue_per_customer FROM shopify_orders o WHERE o.financial_status IN ('paid', 'partially_refunded') AND o.cancelled_at IS NULL AND o.created_at >= NOW() - INTERVAL '90 days' GROUP BY COALESCE(NULLIF(o.referring_site, ''), 'Direct / Unknown') HAVING COUNT(DISTINCT o.id) >= 5 ORDER BY avg_order_value DESC
This query was generated by Taptic Data from plain English against a real Shopify schema. In Taptic, you type the question โ the AI writes the SQL, runs it, and returns the result. You can edit the SQL, ask for explanations, and save it as a refreshable report.
How this query works
What it returns
Traffic sources ranked by average order value, with order count, unique customers, total revenue, and revenue per customer.
Why it matters
FAQ
Generate this automatically
In Taptic Data, you type "Show me average order value by traffic source for the last 9..." and this SQL runs automatically against your real Shopify data.
Try Taptic Free โ $29.99/moNo credit card required. Connect your data source in under 5 minutes.
Compare tools