trackEcommerceOrder
The trackEcommerceOrder() method tracks conversions, including products and payment details.
Syntax
const options: TrackEcommerceOrderOptions = {
visitCustomVariables: { 1: { name: 'name', value: 'value' } },
customDimensions: { 1: 'value', 2: 'value' },
discount: 'discount',
shipping: 'shipping',
subTotal: 'subTotal',
tax: 'tax',
currencyCode: 'currencyCode',
};
const ecommerceProduct: EcommerceProduct[] = [
{
sku: 'sku',
name: 'name',
category: ['category'],
price: 'price',
quantity: quantity,
brand: 'brand',
variant: 'variant',
customDimensions: {
1: 'value',
2: 'value',
},
},
];
let grandTotal: String = 'grandTotal';
let orderId: String = 'orderId';
await PiwikProSdk.trackEcommerceOrder(orderId, grandTotal, ecommerceProduct, options);Parameters
orderId (string, required)
Unique order identifier.
grandTotal (string, required)
The total value of items in a cart. Must be a string that represents a floating-point number.
products (Array<object>, required)
Product list. Each product should have the following attributes:
sku (string, required)
Product stock-keeping unit.
name (string, optional)
Product name (default: “”).
category (string|Array<string>, optional)
Product category or an array of up to 5 categories. Default: “”.
price (number|string, optional)
Product price has to be a float number or a string containing float number representation. Default: 0.
quantity (number|string, optional)
Product quantity has to be an integer number or a string containing integer representation. Default: 1.
brand (string, optional)
Product brand. Default: “”.
variant (string, optional)
Product variant. Default: “”.
customDimensions (object, optional)
Product custom dimensions. Default: {}.
options
Order tracking options: an object containing seven properties.
subTotal (string, optional)
The total value of items in a cart without shipping.
tax (string, optional)
The total tax amount.
shipping (string, optional)
The total shipping cost.
discount (string, optional)
The total discount.
currencyCode (string, optional)
ISO 4217 currency code, such asUSD, EUR, PLN. If no currency is provided, the default currency set in the Piwik PRO panel is used.
customDimensions
An object that specifies custom dimensions.
visitCustomVariables
An object that contains visit custom variables.
Examples
const options: TrackEcommerceOrderOptions = {
visitCustomVariables: { 1: { name: 'name', value: 'value' } },
customDimensions: { 1: 'value', 2: 'value' },
discount: '18',
shipping: '60',
subTotal: '120',
tax: '39.6',
currencyCode: 'EUR',
};
const ecommerceProduct: EcommerceProduct[] = [
{
sku: 'craft-311',
name: 'Unicorn Iron on Patch',
category: ['Crafts & Sewing', 'Toys', 'Cosmetics'],
price: '49,9089',
quantity: 3,
brand: 'DMZ',
variant: 'blue',
customDimensions: {
1: 'coupon-2020',
2: '20%',
},
},
];
let grandTotal: String = '10000';
let orderId: String = 'order-3415';
await PiwikProSdk.trackEcommerceOrder(orderId, grandTotal, ecommerceProduct, options);Related methods
Updated 3 days ago