addEcommerceItem

❗️

Deprecated

This method is no longer recommended. Use the ecommerceAddToCart() method instead.

The addEcommerceItem() method adds a product to the cart.

Syntax

addEcommerceItem(productSKU[, productName[, productCategory[, productPrice[, productQuantity]]]])
addEcommerceItem(productSKU, productName, productCategory, productPrice, productQuantity): void
addEcommerceItem(productSKU, productName, productCategory, productPrice, productQuantity): void
addEcommerceItem(productSKU, productName, productCategory, productPrice, productQuantity): void
addEcommerceItem(productSKU, productName, productCategory, productPrice, productQuantity): void
addEcommerceItem(productSKU, productName, productCategory, productPrice, productQuantity): void
addEcommerceItem(productSKU, productName, productCategory, productPrice, productQuantity): void

Parameters

productSKU (string, required)

The stock-keeping unit of the added product.

productName (string, optional)

The name of the added product.

productCategory (string | array, optional)

The category of the added product. It can be an array of up to 5 categories.

productPrice (number, optional)

The price of the added product.

productQuantity (number, optional)

The number of added items.

Examples

To add one product to the cart:

_paq.push([ "addEcommerceItem", "584340", "Specialized Stumpjumper", "Mountain bike", 5000, 1, ]);

To add two products to the cart:

_paq.push([ "addEcommerceItem", "584340", "Specialized Stumpjumper", "Mountain bike", 5000, 1, ]); _paq.push([ "addEcommerceItem", "460923", "Specialized Chamonix", "Helmets", 200, 1, ]);

To add a product and send a cart update to Piwik PRO:

_paq.push([ "addEcommerceItem", "584340", "Specialized Stumpjumper", "Mountain bike", 5000, 1, ]); _paq.push(["trackEcommerceCartUpdate", 5000]);

To add two products to the cart and send a cart update:

_paq.push([ "addEcommerceItem", "584340", "Specialized Stumpjumper", "Mountain bike", 5000, 1, ]); _paq.push([ "addEcommerceItem", "460923", "Specialized Chamonix", "Helmets", 200, 1, ]); _paq.push(["trackEcommerceCartUpdate", 5200]);

To track a confirmed order:

// register all purchased items _paq.push([ "addEcommerceItem", "584340", // SKU "Specialized Stumpjumper", // name "Mountain bike", // category 5000, // price 1, // quantity ]); _paq.push([ "addEcommerceItem", "460923", // SKU "Specialized Chamonix", // name "Helmets", // category 200, // price 1, // quantity ]); // track order _paq.push([ "trackEcommerceOrder", "43967392", // order ID 5250, // grand total (value + tax + discount + shipping) 5200, // sub total (value + tax + discount) 970, // tax 150, // shipping 100, // discount ]);

Notes

  • The cart with added items is not stored in the browser storage. Make sure that you add all items again after the page reloads.
  • If a product with the same SKU is already in the cart, it’ll be removed and replaced with the one added with the addEcommerceItem() method.
  • This method doesn’t send any data to Piwik PRO. It just creates a cart. You can use the trackEcommerceCartUpdate() or trackEcommerceOrder() method to send cart data to Piwik PRO.

Related methods


Did this page help you?