HomeQuery LibraryShopify

Which products turn first-time buyers into loyal customers?

Not all first purchases are equal. Some products attract one-time buyers; others reliably convert customers into repeat purchasers. This query identifies which Shopify products have the highest repeat purchase rate.

📊 Shopify👥 Shopify merchants and growth teams🔤 Plain-English → SQL
Show me which products customers bought first and what percentage of those customers made a second purchase
Shopify Repeat Customers by First Product — generated by Taptic Data AI
WITH first_orders AS (
  SELECT
    o.customer_id,
    MIN(o.created_at)                              AS first_order_date,
    MIN(o.shopify_order_id)                        AS first_order_id
  FROM shopify_orders o
  WHERE o.is_test_order = false
    AND o.cancelled_at IS NULL
    AND o.customer_id IS NOT NULL
  GROUP BY o.customer_id
),
first_products AS (
  SELECT
    fo.customer_id,
    li.product_title                               AS first_product
  FROM first_orders fo
  JOIN shopify_order_line_items li ON li.shopify_order_id = fo.first_order_id
),
repeat_buyers AS (
  SELECT DISTINCT customer_id
  FROM shopify_orders
  WHERE is_test_order = false
    AND cancelled_at IS NULL
  GROUP BY customer_id
  HAVING COUNT(shopify_order_id) > 1
)
SELECT
  fp.first_product,
  COUNT(DISTINCT fp.customer_id)                   AS total_first_buyers,
  COUNT(DISTINCT rb.customer_id)                   AS repeat_buyers,
  ROUND(COUNT(DISTINCT rb.customer_id) * 100.0
    / NULLIF(COUNT(DISTINCT fp.customer_id), 0), 1) AS repeat_rate_pct
FROM first_products fp
LEFT JOIN repeat_buyers rb ON rb.customer_id = fp.customer_id
GROUP BY fp.first_product
HAVING COUNT(DISTINCT fp.customer_id) >= 10
ORDER BY repeat_rate_pct DESC
LIMIT 25
Schema-aware SQL generated from plain English38 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 shopify inventory management.

Breaking it down line by line

  1. First CTE identifies each customer's earliest order using MIN(created_at)
  2. Second CTE joins to line items to find what product the customer bought first
  3. Third CTE identifies all customers who have placed more than one order
  4. Final query joins first products to repeat buyers, calculating repeat rate per first product
  5. HAVING >= 10 filters out products with too few buyers for the percentage to be meaningful

Result description

Top 25 products ranked by repeat purchase rate, showing total first buyers, number who returned for a second purchase, and the repeat rate percentage.

The business impact

Products with high repeat rates are your best customer acquisition tools — they bring in buyers who stay. Products with low repeat rates may still be worth selling, but they're not building your loyal customer base. This query tells you which products to feature in acquisition campaigns.

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, shopify inventory management.

Common questions

How do I generate a "Shopify Repeat Customers by First Product" query automatically?
In Taptic Data, type "Show me which products customers bought first and what percentage of those customers made a second purchase" 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 which products customers bought first and what perce..." 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.