The addCartRows method is used to add products a customer has added to their cart.

To unlock full targeting functionality for your cart, include the addCartRows method to all pages and not just your cart page.

Each row is an object with properties specific to the product added to the cart. Some object properties are required, and others are optional.

A product ID can have a maximum of 50 characters. Any product ID that exceeds this length is truncated after 50 characters.

If items are in the cart and a visitor adds a new one, the addCartRows method overwrites any existing cart details that your site passed to the Monetate platform. As a result, you should pass all products currently in the cart in each addCartRows method call.

The cart state is persistent throughout the Monetate session. Therefore, the best practice is to call this method any time items are added or removed from the cart.

Required and Optional Properties

These object properties are required:

  • Product ID
  • Quantity
  • Unit price

These object properties are options:

  • SKU
  • Currency

If your site doesn't use US dollars (USD) for purchases, you must include currency information in this method.

Don't send empty strings for optional property values. Only send properties that have a value.

Monetate Inspector Example

This screenshot shows the required properties—product ID, quantity, and unit price—as they appear in the Monetate Inspector browser plug-in.

The Components tab of Monetate Inspector, with cart in the Page Type row and with product IDs, quantity, and unit price in two Cart Products rows

Code Samples

// addCartRows Method
  "addCartRows", [{
    "productId": "pidString",
    "quantity": "quantityString",
    "unitPrice": "priceString",
    "sku": "pidString",
    "currency": "currencyString"
// addCartRows Example
window.monetateQ = window.monetateQ || [];
  "addCartRows", [
    "productId": "200001",
    "quantity": "1",
    "unitPrice": "99.99",
    "currency": "EUR"
    "productId": "b345",
    "quantity": "3",
    "unitPrice": "29.99",
    "currency": "EUR"

Reporting Empty Carts

You can indicate an empty cart by calling addCartRows once with an empty array, as shown in this code example.

// addCartRows Empty Cart Example
window.monetateQ = window.monetateQ || [];
window.monetateQ.push(["addCartRows", []]);