trackEcommerce
DeprecatedThis method is no longer recommended. Use the trackEcommerceOrder() method instead.
The trackEcommerce() method tracks a confirmed order.
Syntax
const options: TrackEcommerceOptions = {
discount: discount,
shipping: shipping,
subTotal: subTotal,
tax: tax,
items: [
{
sku: 'sku',
category: 'category',
name: 'name',
price: price,
quantity: quantity,
},
],
visitCustomVariables: { 1: { name: 'name', value: 'value' } },
customDimensions: { 1: 'value', 2: 'value' },
};
await PiwikProSdk.trackEcommerce('orderId', grandTotal, options);Parameters
orderId (string, required)
The unique order ID.
grandTotal (number, required)
Total payment for the order. Includes tax, shipping and discounts. Format: 1/100 of the base currency unit. Example: 100 is 1 USD.
options
Order tracking options: an object containing seven properties.
subTotal (number, optional)
Payment for the order without shipping. Format: 1/100 of the base currency unit. Example: 100 is 1 USD.
tax (number, optional)
Tax included in the order. Format: 1/100 of the base currency unit. Example: 100 is 1 USD.
shipping (number, optional)
Shipping costs for the order. Format: 1/100 of the base currency unit. Example: 100 is 1 USD.
discount (number, optional)
Discounts included in the order. Format: 1/100 of the base currency unit. Example: 100 is 1 USD.
items (array, optional)
Items included in the order. Each item requires sku, name, category, price and quantity.
customDimensions
An object that contains custom dimensions.
visitCustomVariables
An object that contains visit custom variables.
Examples
To track a confirmed order:
const options: TrackEcommerceOptions = {
discount: 0,
shipping: 1000,
subTotal: 33110,
tax: 9890,
items: [
{
sku: '0123456789012',
category: "Men's T-shirts",
name: 'Polo T-shirt',
price: 3000,
quantity: 2,
},
],
visitCustomVariables: { 1: { name: 'name', value: 'value' } },
customDimensions: { 1: 'value', 2: 'value' },
};
await PiwikProSdk.trackEcommerce('order_1', 124144, options);Updated about 5 hours ago