Next Commerce
Data AttributesProspect Cart

Prospect Cart

The prospect cart captures a shopper's contact information before they complete checkout, so abandoned carts can be recovered via email or SMS. It is created automatically when the shopper enters a valid email or phone in the checkout form, and is upgraded into a real order on submit.

ProspectCartEnhancer is initialized automatically by CheckoutFormEnhancer — you do not register it manually. Configure it by placing data attributes on the checkout form itself (<form data-next-checkout>).

<form data-next-checkout
      data-trigger-on="phoneEntry"
      data-min-phone-digits="10">
  <!-- checkout fields -->
</form>

Trigger Modes

Pick when the prospect cart is created by setting data-trigger-on on the form element.

data-trigger-onFires when…Email requiredPhone required
formStartThe shopper first interacts with the formyesno
emailEntry (default)A valid email is entered (blur or change)yesno
phoneEntryA valid phone is entered (blur or change)noyes
emailAndPhoneBoth email and phone are valid — fires once both are filledyesyes
manualNever automatically — only via window.next.createProspectCart()yesno

firstName and lastName are always required, regardless of the trigger mode.

A field that is not required for the chosen trigger is still validated when the shopper does type into it — half-typed input is never sent to the API.

Choosing a Mode

Funnel patternUse
Standard email-first checkoutemailEntry (default)
SMS-led funnel — phone collected before emailphoneEntry
Want both an email and an SMS-able phone before tracking the prospectemailAndPhone
Fire as early as possible — even on a single keystroke into the formformStart
Fully manual control from your own scriptsmanual

Phone Field Configuration

AttributeDefaultWhat it does
data-phone-fieldphoneThe input name to locate when no data-next-checkout-field="phone" element is present. Mirrors the existing data-email-field.
data-email-fieldemailThe input name to locate when no data-next-checkout-field="email" element is present.
data-min-phone-digits7Minimum digit count for the fallback validator used when intlTelInput is not initialized on the page. Set higher or lower for markets with different valid-number lengths.

When intl-tel-input is initialized on the phone field, its built-in validator is used and data-min-phone-digits is ignored.


All Attributes

Place these on the checkout form element (<form data-next-checkout>).

AttributeTypeDefaultDescription
data-trigger-onenumemailEntryOne of formStart, emailEntry, phoneEntry, emailAndPhone, manual
data-email-fieldstringemailInput name for the email field
data-phone-fieldstringphoneInput name for the phone field
data-min-phone-digitsnumber7Minimum phone digits for the fallback validator
data-auto-createbooleantrueSet to false to disable automatic creation entirely
data-prospect-configJSONFull config object: { "triggerOn": "phoneEntry", "minPhoneDigits": 10, "sessionTimeout": 60 }. Individual attributes override matching keys in this JSON.

JavaScript API

MethodDescription
window.next.createProspectCart()Force-create the prospect cart now. Required when data-trigger-on="manual".

DOM Events

The enhancer dispatches CustomEvents on the form element:

EventWhen
next:prospect-cart-createdThe API responded successfully and a prospect cart now exists
next:prospect-cart-abandonedThe session expired before checkout completed
next:prospect-cart-convertedThe order completed — the prospect was converted to a real customer

Listen on the form:

document.querySelector('form[data-next-checkout]')
  .addEventListener('next:prospect-cart-created', (e) => {
    console.log('Prospect cart created', e.detail);
  });

See Custom Analytics Triggers for an example that uses next:prospect-cart-created to fire a begin_checkout event on email or phone entry instead of on form initialization.


Common Pitfalls

  • data-trigger-on="phoneEntry" requires a valid phone, not just any input. With intl-tel-input initialized, the country-aware validator runs. Without it, the value must contain at least data-min-phone-digits digits.
  • Optional fields are validated only when typed into. If the shopper types 12 into the phone field under formStart, the cart is not created — 12 is non-empty but invalid.
  • data-min-phone-digits is a fallback. It is only used when intl-tel-input has not initialized on the phone input. Most production pages use intl-tel-input, in which case this attribute has no effect.

On this page