← Back to all products
$29
Cart Abandonment Recovery
Abandoned cart detection, email sequence automation, retargeting pixel setup, and recovery rate analytics dashboard.
MarkdownYAMLPython
📄 Product Preview
Try the interactive reader and demo tools below, or get the full product with all content unlocked.
📖 Interactive Reader (Free Preview) ⚙ Try Demo Tools 📦 Download Free Sample📁 File Structure 20 files
shopping-cart-abandonment/
├── LICENSE
├── README.md
├── configs/
│ └── abandonment_config.yaml
├── data/
│ └── sample_carts.csv
├── free-sample.zip
├── guide/
│ ├── 01-overview.md
│ ├── 02-cart-abandonment-detection-and-triggers.md
│ └── 03-recovery-analytics-and-optimization.md
├── guides/
│ └── setup_guide.md
├── index.html
├── src/
│ ├── __init__.py
│ ├── cart_detector.py
│ ├── email_engine.py
│ ├── recovery_analytics.py
│ └── retargeting_pixels.py
├── templates/
│ ├── final_offer.html
│ ├── reminder_1h.html
│ └── reminder_24h.html
└── tests/
└── test_abandonment.py
📖 Documentation Preview README excerpt
Shopping Cart Abandonment Recovery System
A complete cart abandonment detection and recovery toolkit for e-commerce stores. Identifies abandoned carts from event data, triggers multi-step email sequences, generates retargeting pixel events for ad platforms, and measures recovery performance.
Average e-commerce stores lose 70% of carts to abandonment. This system helps you recover 5-15% of that lost revenue through timed email sequences and retargeting.
Features
- Cart Detection Engine — Identifies abandoned carts based on configurable time thresholds, categorizes by value tier and checkout stage reached, and prioritizes recovery targets
- 3-Step Email Sequence — Pre-built HTML email templates (1-hour nudge, 24-hour social proof, 72-hour discount offer) with
$variablesubstitution and send history tracking - Retargeting Pixel Events — Generates ready-to-use event payloads for Meta (Facebook) Pixel and Google Ads remarketing, plus JavaScript snippets for Dynamic Product Ads
- Recovery Analytics — Measures recovery rates, revenue recaptured, email performance (open/click/conversion), and breakdown by cart value tier and checkout stage
- Suppression Rules — Prevents duplicate sends, respects purchases and unsubscribes, enforces daily email caps and quiet hours
Quick Start
from src.cart_detector import CartDetector
from src.email_engine import EmailSequenceEngine
# 1. Detect abandoned carts from your event data
detector = CartDetector.from_csv("data/sample_carts.csv",
abandonment_threshold_minutes=60)
abandoned = detector.detect_abandoned()
detector.print_summary()
# 2. Generate recovery emails
engine = EmailSequenceEngine(template_dir=".")
cart_dicts = [
{"cart_id": a.cart_id, "customer_id": a.customer_id,
"email": a.email, "cart_value": a.cart_value,
"item_count": a.item_count, "last_event_time": a.last_event_time}
for a in abandoned
]
emails = engine.generate_emails(cart_dicts)
for email in emails:
print(f" → {email.to_email}: {email.subject} [{email.step_id}]")
What's Included
shopping-cart-abandonment/
├── README.md ← You are here
├── LICENSE ← MIT License
├── .gitignore
├── src/
│ ├── __init__.py ← Package init with public API imports
│ ├── cart_detector.py ← Abandonment detection engine
│ ├── email_engine.py ← Email sequence scheduler + renderer
│ ├── retargeting_pixels.py ← Ad platform event generator
│ └── recovery_analytics.py ← Recovery performance analytics
├── templates/
│ ├── reminder_1h.html ← 1-hour gentle nudge email
│ ├── reminder_24h.html ← 24-hour social proof email
│ └── final_offer.html ← 72-hour discount offer email
├── data/
│ └── sample_carts.csv ← 20 sample carts (44 events)
├── tests/
*... continues with setup instructions, usage examples, and more.*
📄 Code Sample .py preview
src/cart_detector.py
"""
Cart Abandonment Detector
=========================
Identifies shopping carts that were created but never converted to a
purchase. A cart is considered "abandoned" when:
1. Items were added to the cart (cart_created event)
2. No corresponding purchase event occurred
3. More than ``abandonment_threshold`` minutes have elapsed
The detector also categorises abandoned carts by:
- Cart value (high / medium / low)
- Stage reached (added items / started checkout / entered payment)
- Time of abandonment (to find patterns)
Usage::
detector = CartDetector(cart_events, abandonment_threshold_minutes=60)
abandoned = detector.detect_abandoned()
summary = detector.abandonment_summary()
"""
from __future__ import annotations
import csv
import logging
from collections import defaultdict
from dataclasses import dataclass, field
from datetime import datetime, timedelta
from pathlib import Path
from typing import Any, Dict, List, Optional, Sequence, Tuple
logger = logging.getLogger(__name__)
# ---------------------------------------------------------------------------
# Data structures
# ---------------------------------------------------------------------------
@dataclass
class CartEvent:
"""A single cart-related event."""
cart_id: str
customer_id: str
event_type: str # cart_created | item_added | checkout_started | payment_entered | purchased
timestamp: datetime
cart_value: float = 0.0
item_count: int = 0
# ... 301 more lines ...