One-script install · Works on any commerce site

Universal Cart Recovery Install Guide

Add cart abandonment tracking and recovery emails to any commerce website with one script.

Step 1

Drop the script into your store

Paste this snippet just before </body> on every page of your store.

<script async
  src="https://YOUR_APP_DOMAIN/cart-recovery.js"
  data-store-key="cr_PUBLIC_STORE_KEY"
  data-endpoint="https://YOUR_PROJECT_REF.functions.supabase.co/functions/v1/track-event">
</script>
YOUR_APP_DOMAIN

Where the recovery app / script is hosted.

cr_PUBLIC_STORE_KEY

Public store key from your merchant dashboard. Safe to expose.

YOUR_PROJECT_REF

Your Supabase project ref (the subdomain in your project URL).

Step 2

What it tracks automatically

Product views
Add-to-cart clicks
Cart views
Checkout starts
Email capture
Purchase completion
Optional

Manual tracking API

Use the global window.cartRecovery for stores where DOM events don't capture everything.

Identify customer
cartRecovery.identify({
  email: "shopper@example.com",
  name: "Alex Shopper",
});
Set cart contents
cartRecovery.setCart({
  currency: "USD",
  items: [
    { id: "SKU-123", title: "Linen Shirt", price: 4900, quantity: 1 },
    { id: "SKU-456", title: "Canvas Tote",  price: 2500, quantity: 2 },
  ],
  total: 9900,
});
Record purchase
cartRecovery.purchase({
  order_id: "1042",
  total: 9900,
  currency: "USD",
});
Step 3

Testing checklist

  1. 1Open store in a private browser window
  2. 2View any product
  3. 3Add it to cart
  4. 4Enter a test email at checkout
  5. 5Leave without buying
  6. 6Confirm dashboard shows the session, contact, and cart
  7. 7Wait 60 minutes or run the abandoned-cart processor manually
Architecture

Backend setup

The backend runs entirely on Supabase Edge Functions — no servers to maintain. Each function has a single, focused responsibility.

track-event

Receives browser events from the script.

process-abandoned-carts

Scheduled job that finds carts to recover.

send-recovery-email

Sends recovery emails via your provider.

resend-webhook

Records deliveries, opens, and clicks.

unsubscribe

Public unsubscribe endpoint linked in every email.

dashboard-api

Authenticated API powering the merchant dashboard.

Never expose Supabase service role keys in the frontend. The install snippet only uses your public store key. Dashboard requests must send the signed-in Supabase user's JWT in the Authorization header.
Dashboard

What merchants see

Total sessions
12,480
+8.2% vs last 30 days
Abandoned carts
1,932
−3.1% vs last 30 days
Captured emails
874
+12.4% vs last 30 days
Sent recovery emails
612
+5.0% vs last 30 days
Recovered purchases
143
+18.7% vs last 30 days
Recovered revenue
$24,910
+22.3% vs last 30 days