Skip to content

Cart Abandonment

The Lindris WordPress plugin automatically tracks cart abandonment for WooCommerce and Easy Digital Downloads stores when the WooCommerce or Easy Digital Downloads integration is enabled, enabling automated cart recovery campaigns.

How It Works

Cart abandonment tracking follows this lifecycle:

  1. Cart Created - Fires when the first item is added to an empty cart
  2. Cart Updated - Fires when cart contents change (items added/removed, quantity changed)
  3. Cart Activity Monitored - JavaScript tracker detects customer activity and updates cart timestamp
  4. Cart Abandoned - Fires when cart is inactive for 10 minutes (default threshold)
  5. Recovery Campaign - Use the abandoned cart event in Lindris workflows to trigger recovery emails

Cart Events

Cart Created

Triggered when the first item is added to an empty cart.

Triggers:

  • WooCommerce: woocommerce_add_to_cart
  • EDD: edd_post_add_to_cart

Cart Updated

Triggered when cart contents change.

Actions that trigger updates:

  • Adding items
  • Removing items
  • Changing quantities
  • Emptying cart

Cart Abandoned

Triggered when a cart remains inactive for the abandonment threshold (default: 10 minutes).

Event Properties:

  • id - Unique cart identifier
  • source - Integration name (WooCommerce or Easy Digital Downloads)
  • products - Array of cart items with product details
  • total - Cart total
  • currency - Currency code
  • url - Cart recovery URL (pre-fills cart when visited)
  • email - Customer email (if provided during checkout)
  • customer - Customer details collected from checkout form
  • modified_at - Last activity timestamp

Platform-Specific Properties:

  • WooCommerce: shipping, taxes
  • Easy Digital Downloads: discounts

Activity Tracking

The plugin includes its own JavaScript tracking script that monitors customer activity and keeps the cart "active" while they browse. This script automatically loads when customers view products or have items in their cart.

NOTE

The cart abandonment tracking script is separate from the JavaScript Tracker. Both work together: the main tracker identifies visitors, while the cart tracking script monitors cart activity.

Tracked Activities:

  • Mouse movements
  • Touch interactions
  • Keyboard input
  • Form field changes
  • Page scrolling
  • Browser/tab closing

Activity signals are debounced (1 second delay) to optimize performance. The tracking script also captures customer information from checkout fields (email, name, phone) to enable recovery even if checkout is incomplete.

REST API Endpoints

The cart tracking script communicates with the WordPress REST API to signal cart activity. These endpoints must be accessible for logged-out users (no authentication required):

WooCommerce:

EndpointPurpose
/wp-json/lindris/v1/events/woocommerce/cart/activitySignals cart activity to prevent premature abandonment
/wp-json/lindris/v1/events/woocommerce/product/viewed/{product_id}Tracks product views

Easy Digital Downloads:

EndpointPurpose
/wp-json/lindris/v1/events/easy-digital-downloads/cart/activitySignals cart activity to prevent premature abandonment
/wp-json/lindris/v1/events/easy-digital-downloads/product/viewed/{product_id}Tracks product views

NOTE

The cart_abandoned event is dispatched by a background Action Scheduler job, not directly by the JS tracker. The tracker only signals activity to keep the cart session "active" - if no activity is detected within the abandonment threshold, the background job marks the cart as abandoned.

If you're using a security plugin that restricts REST API access for logged-out users, ensure these routes remain accessible. The /app/* endpoints (used for plugin settings) can safely require authentication.

Cart Recovery URLs

The plugin generates recovery URLs that automatically restore cart contents when clicked:

WooCommerce Example:

https://example.com/checkout/?add-to-cart=123&quantity=2&add-to-cart=456&quantity=1

Easy Digital Downloads Example:

https://example.com/checkout/?edd_action=add_to_cart&download_id=123&edd_options[price_id]=1

These URLs are included in the cart_abandoned event and can be used in recovery email campaigns.

Configuration

Abandonment Threshold

Change how long a cart must be inactive before being considered abandoned:

php
// Mark carts as abandoned after 15 minutes
add_filter( 'lindris_cart_abandonment_threshold', function( $minutes ) {
    return 15;
} );

Default: 10 minutes

Check Interval

Change how often the plugin checks for abandoned carts:

php
// Check for abandoned carts every 10 minutes
add_filter( 'lindris_cart_abandonment_check_interval', function( $interval ) {
    return 600; // seconds
} );

Default: 300 seconds (5 minutes)

Available Hooks

lindris_pre_save_pending_cart

Modify cart event properties before they're saved. Ideal for adding custom data to cart abandonment events.

Parameters:

  • $event_properties (array) - Event properties
  • $integration (string) - Integration slug
  • $cart_id (string) - Cart identifier
  • $uuid (string) - Visitor UUID

Example - Add cart value tier:

php
add_filter( 'lindris_pre_save_pending_cart', function( $event_properties, $integration, $cart_id, $uuid ) {
    if ( isset( $event_properties['total'] ) ) {
        if ( $event_properties['total'] >= 100 ) {
            $event_properties['value_tier'] = 'high';
        } elseif ( $event_properties['total'] >= 50 ) {
            $event_properties['value_tier'] = 'medium';
        } else {
            $event_properties['value_tier'] = 'low';
        }
    }
    return $event_properties;
}, 10, 4 );

lindris_check_abandoned_carts

Fires when the plugin checks for abandoned carts.

php
// Log when abandoned cart checks run
add_action( 'lindris_check_abandoned_carts', function() {
    error_log( 'Checking for abandoned carts at ' . current_time( 'mysql' ) );
} );

Modifying Cart Recovery URLs

Modify the cart recovery URL before events are sent to Lindris. These filters fire when cart events are tracked.

Available Filters:

  • lindris_easy-digital-downloads_track_cart_created
  • lindris_easy-digital-downloads_track_cart_updated
  • lindris_woocommerce_track_cart_created
  • lindris_woocommerce_track_cart_updated

Parameters:

  • $event_properties (array) - Event properties including the url field
  • $email (string) - Customer email
  • $api (object) - API client instance

Example - Add UTM parameters to recovery URL:

php
add_filter( 'lindris_woocommerce_track_cart_created', 'modify_recovery_url', 10, 3 );
add_filter( 'lindris_woocommerce_track_cart_updated', 'modify_recovery_url', 10, 3 );

function modify_recovery_url( $event_properties, $email, $api ) {
    if ( isset( $event_properties['url'] ) ) {
        $event_properties['url'] = add_query_arg( [
            'utm_source' => 'lindris',
            'utm_medium' => 'email',
            'utm_campaign' => 'cart-recovery',
        ], $event_properties['url'] );
    }
    return $event_properties;
}

Example - Redirect to custom landing page:

php
add_filter( 'lindris_easy-digital-downloads_track_cart_created', 'custom_recovery_landing', 10, 3 );
add_filter( 'lindris_easy-digital-downloads_track_cart_updated', 'custom_recovery_landing', 10, 3 );

function custom_recovery_landing( $event_properties, $email, $api ) {
    if ( isset( $event_properties['url'] ) ) {
        // Keep original URL as parameter
        $original_url = $event_properties['url'];
        $event_properties['url'] = add_query_arg(
            'cart_url',
            urlencode( $original_url ),
            home_url( '/cart-recovery/' )
        );
    }
    return $event_properties;
}

Integration with Lindris

All cart events are sent to the Lindris Events API:

POST https://api.lindris.com/api/events/cart/{action}

Actions: created, updated, abandoned

In Lindris, you can use these events to:

  • Create automated cart recovery workflows
  • Segment customers by cart value or products
  • Apply lifecycle tags based on cart behavior
  • Send personalized recovery emails with cart recovery URLs

See the Lifecycle Tags documentation for automatic tagging based on order completion.

Best Practices

Recovery Email Timing

Consider your abandonment threshold when creating recovery workflows:

  • 10 minutes (default): Quick recovery for distracted customers
  • 1 hour: Better for considered purchases
  • 24 hours: Suitable for high-value or complex products

Multi-Step Recovery

Create a sequence of recovery emails:

  1. 1 hour after abandonment: Gentle reminder with cart contents
  2. 24 hours: Include discount code or incentive
  3. 48 hours: Last chance email with urgency messaging

Lifecycle Tagging

Configure lifecycle tags to organize abandoned cart contacts:

  • When Order Completed, remove abandoned and cart tags
  • When Cart Abandoned, add abandoned-cart tag

This ensures contacts move out of abandoned cart segments after purchase completion.

Testing

Quick Testing Steps

  1. Enable WooCommerce or EDD integration in Lindris settings
  2. Add items to cart as a customer
  3. Enter email address on checkout page (required for tracking)
  4. Leave the site for 10+ minutes
  5. Check Lindris dashboard for cart_abandoned event
  6. Verify cart recovery URL works correctly

Fast Testing (Development)

Reduce thresholds for faster testing:

php
// Check every 1 minute with 2-minute abandonment threshold
add_filter( 'lindris_cart_abandonment_threshold', fn() => 2 );
add_filter( 'lindris_cart_abandonment_check_interval', fn() => 60 );

Manually trigger the checker:

php
do_action( 'lindris_check_abandoned_carts' );

Troubleshooting

Events Not Being Sent

Check these items:

  1. Integration enabled - Verify WooCommerce or EDD integration is enabled in Lindris settings
  2. JavaScript tracker loaded - Check browser console for the lindris_uuid cookie
  3. Email collected - Customer must provide email on checkout page
  4. Time threshold met - Wait at least 10 minutes after last cart activity
  5. Background jobs running - Check Action Scheduler status in WooCommerce/EDD admin

Pending Cart Records

Check if pending carts exist in the database:

php
$carts = get_posts([
    'post_type' => 'lindris_pending_cart',
    'post_status' => 'publish',
    'posts_per_page' => -1
]);

Action Scheduler Not Running

Cart abandonment uses WordPress Action Scheduler (bundled with WooCommerce and EDD):

  • View scheduled actions at WooCommerce > Status > Action Scheduler or Downloads > Tools > Action Scheduler
  • Look for lindris_check_abandoned_carts actions
  • Manually trigger with WP-CLI: wp action-scheduler run

Recovery URL Not Working

Possible causes:

  1. Products deleted - Recovery fails if products no longer exist
  2. Out of stock - Products may be unavailable
  3. Permalink structure - Ensure permalinks are not set to "Plain"
  4. Plugin conflicts - Temporarily disable other cart-related plugins

Activity Tracking Issues

  1. Check JavaScript console - Look for errors in browser developer tools
  2. Verify cookie - Confirm lindris_uuid cookie exists
  3. Test REST API - Ensure /wp-json/lindris/v1/events/{integration}/cart/activity is accessible
  4. Check nonce - WordPress REST API nonces must be valid