Reports that the user added a product to the cart.

👍

Required for e-commerce sections.

Parameters

  • name: Human-readable name, not used to identify an event type
  • properties: A container for the event properties as specified in the following table:
PropertyDescriptionType
dyTypeMust be "add-to-cart-v1".String
valueThe total monetary value of the event (item or items added that triggered the event only).
Note that this is not all the items in the cart. See the code example that follows after this table (productId "item-34454", quantity 2, itemPrice 59.13: Value is 118.26. The other item in the cart is not included.)
Float (dollars.cents).

Numbers are rounded to the nearest 0.01. Numbers smaller than 0.005 are rounded down to 0.
currency

Optional, but required for multi-currency sites
The currency used for the valueString
List of supported currencies
productIdThe SKU exactly as it appears in the product feedString
quantityThe total number of items that were added to cartNumber
cart
Optional, but recommended
The cart's current state, including the last item added. Products are ordered from the first added to the cart to the most recent.

Note: Pass the updated cart with the newly added product to ensure that the cart state is fully in sync with your system. This is important mainly for triggered email and push notifications.
Object

See the cart property table that follows for details.

Cart object properties:

PropertyDescriptionType
productIdSKU exactly as it appears in the product feedString
quantityNumber of itemsNumber
itemPriceThe price of the item addedFloat in the format: dollars.cents

Example: Implementation via script

DY.API("event", {
  name: "Add to Cart",
  properties: {
    dyType: "add-to-cart-v1",
    value: 118.26,
    currency: "any supported currency code",
    productId: "item-34454",
    quantity: 2,
    size: "XL",
    cart: [{
        productId: "sku-4324-bg",
        quantity: 2,
        itemPrice: 12.34,
      },
      {
        productId: "item-34454",
        quantity: 2,
        itemPrice: 59.13
      }
    ]
  }
});

Example: Implementation via Experience API (server-side)

"events":[
  {
  name: "Add to Cart",
  properties: {
    dyType: "add-to-cart-v1",
    value: 198.00,
    productId: "p-tv78615a",
    quantity: 2,
    cart: [
      {
        productId: "p-cr91275g",
        quantity: 1,
        itemPrice: 49.95
      },
      {
        productId: "p-tv78615a",
        quantity: 2,
        itemPrice: 99.00,
      }
     ]
   }
 }  
]