Cart Interaction

Use a cart interaction event to monitor customer activity when they add items to, remove items from, or replace the entire contents of their online shopping cart.

Cart interactions come in two forms:

  • Single line item interactions: For modifying individual line items in the customer’s cart.
  • Multiple line item interactions: For bulk operations against the customer’s cart.

These interaction names are used for cart interactions that affect individual line items.

Interaction NameValue
SalesforceInteractions.CartInteractionName.AddToCartAdd To Cart
SalesforceInteractions.CartInteractionName.RemoveFromCartRemove From Cart

Here are fields for a single line cart interaction.

Field NameField TypeDescription
lineItemLine Item DataRequired. A single Line Item Data value.
namestringRequired. The event names.

To track adding or removing a single product, use the AddToCart or RemoveFromCart interaction names. The payload must contain a lineItem key with a single Line Item object as its value.

These interaction names are used for cart interactions that affect all the line items in a cart.

Interaction NameValue
SalesforceInteractions.CartInteractionName.ReplaceCartReplace Cart

Here are the fields for multiple line item cart interactions.

Field NamesField TypeDescription
lineItemsarrayRequired. An array of zero to many Line Item Data values
namestringRequired. The event names.

To track a bulk update that replaces all items in the cart, use the ReplaceCart interaction name. This is common after a login when merging a guest cart with a saved cart. The payload must contain a lineItems key with an array of Line Item objects as its value. An empty array indicates the cart is now empty.

You can send a cart interaction event directly from your own JavaScript code, such as within a custom event handler for an "Add to Cart" button using the Web SDK.

For a more declarative approach, you can use the Sitemap to listen for user actions (like a button click) and automatically send the corresponding event.

See Also