---
title: addPurchaseRows
slug: js-api/addpurchaserows
description: Overview of the Monetate JavaScript API addPurchaseRows method and how to use it
image:  https://archbee-image-uploads.s3.amazonaws.com/ceIfEvQHzQk1IVxoRWUh7/K9eTL4jKm7UQINb6zNziJ-20250912-181225.png
docTags: 
createdAt: 2024-04-30T17:27:44.755Z
---

:::CodeblockTabs
addPurchaseRows Method

```javascript
// addPurchaseRows Method
window.monetateQ.push([
  "addPurchaseRows", [{
    "purchaseId": "idString",
    "productId": "pidString",
    "quantity": "quantityString",
    "unitPrice": "priceString",
    "sku": "skuString",
    "currency": "currencyString"
  }]
]);
```
:::

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

:::hint{type="info"}
You don't need to send an additional API call with the [addCartRows](docId\:Y-wcMRn_146QuOtE7NjFt) method 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.

## Required and Optional Properties

The required properties are as follows:

- `purchaseId`
- `productId`
- `quantity`
- `unitPrice`

:::hint{type="warning"}
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.

These object properties are optional:

- `sku`
- `currency`

:::hint{type="warning"}
If you are using Personalized Search, the SKU is a required parameter.
:::

:::hint{type="warning"}
If your site doesn't use US dollars (USD) for purchases, then 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 View

This screenshot shows the **Components** tab of the [Monetate Inspector browser plug-in](https://docs.monetate.com/docs/install-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](https://dyzz9obi78pm5.cloudfront.net/app/image/id/64f76540b43da86178047136/n/monetate-inspector-components-tab-event-viewpage-viewpurchase-page-type-purchase-cart-products-product-id-product-sku.png)

This code example contains the method in use that results in the Monetate Inspector results shown in the previous screenshot.

:::CodeblockTabs
addPurchaseRows Example

```javascript
// addPurchaseRows Example
window.monetateQ = window.monetateQ || [];
window.monetateQ.push([
  "addPurchaseRows", [{
    "purchaseId": "1456768298719",
    "productId": "359920273",
    "sku": "913801477",
    "quantity": "1",
    "unitPrice": "299.99",
    "currency": "EUR"
  }, {
    "purchaseId": "73893797",
    "productId": "b345",
    "sku": "sku345",
    "quantity": "3",
    "unitPrice": "29.99",
    "currency": "EUR"
  }]
]);
window.monetateQ.push([
  "trackData"
]);
```
:::

