addPurchaseRows

The addPurchaseRows method is used to add products a customer has purchased.

You don't need to send an additional API call with addCartRows to empty the cart after a conversion.

The method data is an array of objects. Each row is an object with properties specific to the purchased product. Some object properties are required while others are optional.

The required properties are as follows:

  • purchaseId
  • productId
  • quantity
  • unitPrice

A product ID (PID) as well as the purchase ID each can have no more than 50 characters. The API call fails if any PID exceeds this limit.

The purchaseId property must be the same across all rows within addPurchaseRows. The value it contains must be unique across all purchases to track purchases on your site. If your site passes a purchase ID to Monetate more than once, it discards the newer duplicate purchase ID and doesn't include it in analytics.

Optional cart row objects include SKU and currency. If your site doesn't use US dollars for purchases, you must include currency information in this method.

Do not send empty strings for optional property values. Only set properties that have a value.

Monetate Inspector Example

This screenshot shows the Components tab of the Monetate Inspector browser plug-in. The Purchase ID row indicates that the addPurchaseRows method has passed the transaction number to Monetate along with the required PID, quantity, and unit price values as shown in the Cart Products rows.

The Components tab of Monetate Inspector, with a value in the 'Purchase ID' row as well as product ID, quantity, and unit price values in  the Cart Products rows

Code Samples

// addPurchaseRows Method
window.monetateQ.push([
  "addPurchaseRows", [{
    "purchaseId": "idString",
    "productId": "pidString",
    "quantity": "quantityString",
    "unitPrice": "priceString",
    "sku": "pidString",
    "currency": "currencyString"
  }]
]);
// addPurchaseRows Example
window.monetateQ = window.monetateQ || [];
window.monetateQ.push([
  "addPurchaseRows", [{
    "purchaseId": "73893797",
    "productId": "a123",
    "quantity": "1",
    "unitPrice": "99.99",
    "currency": "EUR"
  }, {
    "purchaseId": "73893797",
    "productId": "b345",
    "quantity": "3",
    "unitPrice": "29.99",
    "currency": "EUR"
  }]
]);
window.monetateQ.push([
  "trackData"
]);