---
title: "Abandoned Cart Recovery"
description: "Recover lost sales with an intelligent multi-step email sequence that brings customers back to complete their purchase."
url: https://tajo.io/docs/skills/email-marketing/abandoned-cart/
markdown: https://tajo.io/docs/skills/email-marketing/abandoned-cart.md
lang: en-US
---

# Abandoned Cart Recovery

Recover lost sales with an intelligent multi-step email sequence. This skill monitors cart abandonment and automatically sends personalized recovery emails to bring customers back.

## Overview

| Property | Value |
| --- | --- |
| **Category** | Email Marketing |
| **Status** | Stable |
| **Version** | 3.0 |
| **Triggers** | `cart_abandoned`, `cart_recovered` |
| **Average Recovery Rate** | 10-15% |

## How It Works

```mermaid
graph TD
    A[Customer adds to cart] -->|Leaves site| B{Cart abandoned?}
    B -->|No checkout in 30min| C[Trigger: cart_abandoned]
    C --> D[Wait 1 hour]
    D --> E{Purchased?}
    E -->|No| F[Send Email #1]
    F --> G[Wait 24 hours]
    G --> H{Purchased?}
    H -->|No| I[Send Email #2 + Discount]
    I --> J[Wait 48 hours]
    J --> K{Purchased?}
    K -->|No| L[Send Email #3 - Final]
    E -->|Yes| M[Stop sequence]
    H -->|Yes| M
    K -->|Yes| M
    L --> N[Mark as lost]
```

## Configuration

### Basic Setup

```yaml
skills:
  abandoned-cart:
    enabled: true

    # Cart abandonment detection
    detection:
      inactivity_threshold: 30m  # Minutes before cart is abandoned
      min_cart_value: 25         # Minimum cart value to trigger
      exclude_logged_out: false  # Include guest carts

    # Email sequence
    sequence:
      - delay: 1h
        template_id: 101
        subject: "Forgot something?"

      - delay: 24h
        template_id: 102
        subject: "Your cart is waiting"
        include_discount: true
        discount_percent: 10

      - delay: 48h
        template_id: 103
        subject: "Last chance - items selling fast"
        include_discount: true
        discount_percent: 15
        discount_expiry: 24h

    # Stop conditions
    stop_on:
      - cart_recovered
      - order_placed
      - unsubscribe
```

### Advanced Configuration

```yaml
skills:
  abandoned-cart:
    # Segment-specific timing
    timing:
      vip_customers:
        first_email: 30m
        discount_threshold: 0  # Always include discount
      new_customers:
        first_email: 2h
        discount_threshold: 50  # Discount only if cart > $50
      repeat_customers:
        first_email: 1h
        discount_threshold: 100

    # A/B testing
    ab_testing:
      enabled: true
      variants:
        - name: "urgency"
          subject: "Items in your cart are selling fast!"
          weight: 50
        - name: "friendly"
          subject: "Did you forget something?"
          weight: 50

    # Exclusions
    exclude:
      - email_domain: ["temp-mail.com", "disposable.com"]
      - customer_tag: ["wholesale", "staff"]
      - product_category: ["gift-cards"]
```

## Triggers

### cart\_abandoned

Fires when a cart has been inactive for the configured threshold.

#### Event Data

| Parameter | Type | Description |
| --- | --- | --- |
| `cart_id` required | string | Unique cart identifier |
| `customer_email` required | string | Customer's email address |
| `items` required | array | Array of cart items with name, price, quantity, image\_url |
| `total` required | number | Cart total value |
| `currency` optional | string | Currency code (e.g., USD, EUR) Default: `USD` |
| `recovery_url` required | string | URL to recover the cart |
| `abandoned_at` required | datetime | When the cart was abandoned |

Example payload:

```json
{
  "event": "cart_abandoned",
  "timestamp": "2024-01-15T14:30:00Z",
  "data": {
    "cart_id": "cart_abc123",
    "customer_email": "jane@example.com",
    "items": [
      {
        "id": "prod_123",
        "name": "Premium Headphones",
        "price": 199.99,
        "quantity": 1,
        "image_url": "https://cdn.example.com/headphones.jpg",
        "variant": "Black"
      },
      {
        "id": "prod_456",
        "name": "Phone Case",
        "price": 29.99,
        "quantity": 2,
        "image_url": "https://cdn.example.com/case.jpg"
      }
    ],
    "subtotal": 259.97,
    "shipping": 0,
    "tax": 20.80,
    "total": 280.77,
    "currency": "USD",
    "recovery_url": "https://store.example.com/cart/recover/abc123",
    "abandoned_at": "2024-01-15T14:00:00Z"
  }
}
```

### cart\_recovered

Fires when a customer returns and completes checkout.

```json
{
  "event": "cart_recovered",
  "timestamp": "2024-01-15T16:45:00Z",
  "data": {
    "cart_id": "cart_abc123",
    "customer_email": "jane@example.com",
    "order_id": "order_789",
    "recovered_via": "email_1",  // Which email triggered recovery
    "time_to_recover": "2h15m"
  }
}
```

## Email Templates

### Template Variables

Use these variables in your Brevo email templates:

| Variable | Description | Example |
| --- | --- | --- |
| `params.FIRSTNAME` | Customer’s first name | Jane |
| `params.CART_URL` | Cart recovery URL | https://… |
| `params.CART_TOTAL` | Formatted cart total | $280.77 |
| `params.ITEM_COUNT` | Number of items | 3 |
| `params.ITEMS` | JSON array of items | \[…\] |
| `params.DISCOUNT_CODE` | Generated discount code | SAVE10-ABC |
| `params.DISCOUNT_PERCENT` | Discount percentage | 10 |
| `params.EXPIRY_DATE` | Discount expiry date | Jan 17, 2024 |

### Recommended Email Sequence

**Email 1 (1 hour)**: Gentle reminder

- Subject: “Forgot something, {{ params.FIRSTNAME }}?”
- Focus: Remind about cart contents
- No discount yet

**Email 2 (24 hours)**: Add urgency + incentive

- Subject: “Your cart is waiting + 10% off”
- Focus: Limited-time discount
- Include discount code

**Email 3 (48 hours)**: Final push

- Subject: “Last chance - 15% off expires soon”
- Focus: Scarcity + stronger discount
- 24-hour expiry on discount

## Code Examples

### Enable Abandoned Cart Skill

```javascript
import { TajoClient } from '@tajo/sdk';

const tajo = new TajoClient({
  apiKey: process.env.TAJO_API_KEY,
  brevoApiKey: process.env.BREVO_API_KEY
});

await tajo.skills.enable('abandoned-cart', {
  detection: {
    inactivityThreshold: '30m',
    minCartValue: 25
  },
  sequence: [
    { delay: '1h', templateId: 101 },
    { delay: '24h', templateId: 102, discountPercent: 10 },
    { delay: '48h', templateId: 103, discountPercent: 15 }
  ]
});
```

### Track Cart Abandonment

```javascript
// Call this when cart activity is detected
await tajo.events.track('cart_updated', {
  cartId: 'cart_abc123',
  customerEmail: 'jane@example.com',
  items: cartItems,
  total: 280.77
});

// Call this when customer leaves without checkout
// (typically from a beforeunload event or session timeout)
await tajo.events.track('cart_abandoned', {
  cartId: 'cart_abc123',
  customerEmail: 'jane@example.com',
  items: cartItems,
  total: 280.77,
  recoveryUrl: 'https://store.example.com/cart/recover/abc123'
});
```

### Generate Discount Codes

```javascript
// Generate a unique discount code
const discount = await tajo.discounts.create({
  type: 'percentage',
  value: 10,
  expiresIn: '7d',
  usageLimit: 1,
  prefix: 'SAVE10'
});

// discount.code => "SAVE10-ABC123"
```

## Analytics

Track abandoned cart recovery performance:

| Metric | Description |
| --- | --- |
| **Abandonment Rate** | % of carts that are abandoned |
| **Recovery Rate** | % of abandoned carts recovered |
| **Revenue Recovered** | Total revenue from recovered carts |
| **Email Open Rate** | % of recovery emails opened |
| **Email CTR** | Click-through rate on recovery emails |
| **Time to Recovery** | Average time from abandonment to purchase |

```javascript
const stats = await tajo.skills.getStats('abandoned-cart', {
  period: '30d'
});

console.log(stats);
// {
//   abandonmentRate: 68.5,
//   recoveryRate: 12.3,
//   revenueRecovered: 15420.50,
//   emailsSent: 2340,
//   emailOpenRate: 45.2,
//   emailCtr: 8.7,
//   avgTimeToRecovery: '4h32m'
// }
```

## Best Practices

Timing Matters

Send the first email within 1-2 hours of abandonment. Recovery rates drop significantly after 24 hours.

1. **Personalize subject lines** - Use the customer’s name and cart contents
2. **Show cart contents** - Include product images in the email
3. **Create urgency** - Mention low stock or limited-time discounts
4. **Make recovery easy** - One-click cart recovery links
5. **Test your sequence** - A/B test timing, subject lines, and discounts
6. **Respect unsubscribes** - Stop the sequence immediately on unsubscribe

## Related Skills

- Cart Events - Track cart activity
- Browse Abandonment - Recover browse sessions
- Win-Back - Re-engage inactive customers

## Next Steps

1. Set up cart tracking on your platform
2. Create email templates in Brevo
3. Configure discount codes integration
4. Monitor performance in the dashboard
