HomeQuery LibraryShopify

What percentage of your Shopify revenue comes from repeat customers?

Repeat purchase rate is a proxy for customer satisfaction, product-market fit, and brand loyalty. This query breaks it down by month so you can see whether your retention is improving.

📊 Shopify👥 Shopify merchants🔤 Plain-English → SQL
Part of the Explore all Shopify analytics queries

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.

Show me what percentage of revenue and orders come from repeat vs new customers each month
Shopify Repeat Purchase Rate — generated by Taptic Data AI
WITH customer_order_history AS (
  SELECT
    customer_id,
    id            AS order_id,
    total_price,
    created_at,
    ROW_NUMBER() OVER (
      PARTITION BY customer_id
      ORDER BY created_at ASC
    )             AS order_sequence
  FROM shopify_orders
  WHERE financial_status IN ('paid', 'partially_refunded')
    AND customer_id IS NOT NULL
)
SELECT
  TO_CHAR(DATE_TRUNC('month', created_at), 'YYYY-MM')   AS order_month,
  COUNT(*) FILTER (WHERE order_sequence = 1)            AS new_customer_orders,
  COUNT(*) FILTER (WHERE order_sequence > 1)            AS repeat_customer_orders,
  COUNT(*)                                              AS total_orders,
  ROUND(SUM(total_price) FILTER (WHERE order_sequence = 1)::numeric, 2)  AS new_revenue,
  ROUND(SUM(total_price) FILTER (WHERE order_sequence > 1)::numeric, 2) AS repeat_revenue,
  ROUND(
    COUNT(*) FILTER (WHERE order_sequence > 1)::numeric * 100
    / NULLIF(COUNT(*), 0), 2
  )                                                     AS repeat_order_pct,
  ROUND(
    SUM(total_price) FILTER (WHERE order_sequence > 1)::numeric * 100
    / NULLIF(SUM(total_price)::numeric, 0), 2
  )                                                     AS repeat_revenue_pct
FROM customer_order_history
WHERE created_at >= NOW() - INTERVAL '12 months'
GROUP BY DATE_TRUNC('month', created_at)
ORDER BY 1 ASC
Schema-aware SQL generated from plain English33 lines

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. This type of analysis is commonly used in shopify revenue dashboard and ecommerce reporting.

Breaking it down line by line

  1. CTE uses ROW_NUMBER() partitioned by customer_id to assign each order a sequence number per customer
  2. Order sequence = 1 means first-ever order (new customer); > 1 means repeat
  3. PostgreSQL FILTER clause enables aggregating new vs repeat in the same SELECT without a pivot
  4. Calculates both order count percentage and revenue percentage for repeat customers separately
  5. Trends over 12 months so you can see whether retention is improving month over month

Result description

Monthly breakdown of new vs repeat customer orders and revenue, with percentage of each — covering the last 12 months to reveal retention trends.

The business impact

A healthy eCommerce business typically sees 25–40% of revenue from repeat customers. If your repeat rate is declining, it's a leading indicator of churn before it shows up in revenue numbers. If it's growing, your retention and product strategies are working.

New to this metric? How to calculate Shopify repeat purchase rate — definition, formula, and business context.

All queries and use cases on this page relate to analyzing your Shopify data in Taptic. To see the full analytics workflow, explore shopify revenue dashboard, ecommerce reporting.

Common questions

How do I generate a "Shopify Repeat Purchase Rate" query automatically?
In Taptic Data, type "Show me what percentage of revenue and orders come from repeat vs new customers each month" and the AI generates schema-aware SQL against your real Shopify data — no manual writing required.
What database does this query work with?
This query is designed for Shopify. Taptic reads your live schema so the generated SQL always matches your actual table and column names.
Can I edit the generated SQL?
Yes. Taptic shows you the exact SQL it generated. You can edit it directly, ask the AI to explain any line, or request a revision in plain English.
Can I save this as a scheduled report?
Yes. Once you run this query in Taptic, you can save it as a report, add charts and KPIs, and schedule it to email your team on any cadence — daily, weekly, or monthly.

Skip the SQL. Ask the question.

In Taptic Data, you type "Show me what percentage of revenue and orders come from repe..." and this SQL runs automatically against your real Shopify data.

Try Taptic Free — $29.99/mo

No credit card required. Connect your data source in under 5 minutes.

Next step
Run this query on your own Shopify data
Connect 🟢 Shopify to Taptic Data and this SQL generates automatically from plain English — against your real schema, your real tables.
Analytics hub
More Shopify queries, use cases, and analytics resources in one place.
Explore all Shopify analytics queries