Step 5: Capture Cart Information

The addCartRows method sends information about the products that visitors have added to their cart to Monetate. You should make a call to this method on every page or at least on any page on which the basket has the potential to change. Implementing the addCartRows method on these pages is important because it allows you to use experiences such as abandoned cart messaging, delivery threshold messaging, and targeted upsell opportunities based on products in a visitor's cart.

For example, if you've implemented addCartRows and want to run an experience to target visitors with products in their carts above or below a certain value, you can configure the relevant data target, such as product in cart under $50, in the WHO settings of the experience.

Code ExampleTips
// addCartRows Method
window.monetateQ.push([
  "addCartRows", [{
    "productId": "pidString",
    "quantity": "quantityString",
    "unitPrice": "priceString",
    "sku": "skuString",
    "currency": "currencyString"
  }]
]);
addCartRows requires the following properties: productId, quantity, and unitPrice. Optional properties include currency and SKU. Non-US sites must include currency.

If your cart updates with AJAX or changes state asynchronously to display new data, you must add a retrack to ensure Monetate is aware of the change. Refer to AJAX Site Updates for more information.
// addCartRows Example
window.monetateQ = window.monetateQ || [];
window.monetateQ.push([
 "addCartRows", [{
 "productId": "200001",
 "quantity": "1",
 "unitPrice": "99.99",
 "currency": "EUR"
 }, {
 "productId": "b345",
 "quantity": "3",
 "unitPrice": "29.99",
 "currency": "EUR"
 }]
]);
window.monetateQ.push([
 "trackData"
]);
The addCartRows method only captures the product price and no separate delivery, tax or promotion costs.
// Empty Cart Example 
window.monetateQ = window.monetateQ || [];
window.monetateQ.push(["addCartRows", []]);
window.monetateQ.push(["trackData"]);