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-on | Fires when… | Email required | Phone required |
|---|---|---|---|
formStart | The shopper first interacts with the form | yes | no |
emailEntry (default) | A valid email is entered (blur or change) | yes | no |
phoneEntry | A valid phone is entered (blur or change) | no | yes |
emailAndPhone | Both email and phone are valid — fires once both are filled | yes | yes |
manual | Never automatically — only via window.next.createProspectCart() | yes | no |
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 pattern | Use |
|---|---|
| Standard email-first checkout | emailEntry (default) |
| SMS-led funnel — phone collected before email | phoneEntry |
| Want both an email and an SMS-able phone before tracking the prospect | emailAndPhone |
| Fire as early as possible — even on a single keystroke into the form | formStart |
| Fully manual control from your own scripts | manual |
Phone Field Configuration
| Attribute | Default | What it does |
|---|---|---|
data-phone-field | phone | The input name to locate when no data-next-checkout-field="phone" element is present. Mirrors the existing data-email-field. |
data-email-field | email | The input name to locate when no data-next-checkout-field="email" element is present. |
data-min-phone-digits | 7 | Minimum 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>).
| Attribute | Type | Default | Description |
|---|---|---|---|
data-trigger-on | enum | emailEntry | One of formStart, emailEntry, phoneEntry, emailAndPhone, manual |
data-email-field | string | email | Input name for the email field |
data-phone-field | string | phone | Input name for the phone field |
data-min-phone-digits | number | 7 | Minimum phone digits for the fallback validator |
data-auto-create | boolean | true | Set to false to disable automatic creation entirely |
data-prospect-config | JSON | — | Full config object: { "triggerOn": "phoneEntry", "minPhoneDigits": 10, "sessionTimeout": 60 }. Individual attributes override matching keys in this JSON. |
JavaScript API
| Method | Description |
|---|---|
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:
| Event | When |
|---|---|
next:prospect-cart-created | The API responded successfully and a prospect cart now exists |
next:prospect-cart-abandoned | The session expired before checkout completed |
next:prospect-cart-converted | The 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. Withintl-tel-inputinitialized, the country-aware validator runs. Without it, the value must contain at leastdata-min-phone-digitsdigits.- Optional fields are validated only when typed into. If the shopper types
12into the phone field underformStart, the cart is not created —12is non-empty but invalid. data-min-phone-digitsis a fallback. It is only used whenintl-tel-inputhas not initialized on the phone input. Most production pages useintl-tel-input, in which case this attribute has no effect.