trackEcommerceTransaction

❗️

Deprecated

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

The trackEcommerceTransaction() method tracks a confirmed order.

Syntax

const options: TrackEcommerceOptions = {
  discount: orderDiscount,
  shipping: orderShipping,
  subTotal: orderSubTotal,
  tax: orderTax,
  items: [
    {
      sku: 'sku',
      category: "category",
      name: 'name',
      price: price,
      quantity: quantity,
    },
  ],
  visitCustomVariables: { index: { name: 'name', value: 'value' },
  customDimensions: { dimensionID: 'value', dimensionID: 'value', },
};
await PiwikProSdk.trackEcommerce('order_1', 124144, options);

Parameters

orderID (string, required)

The unique order ID.

orderGrandTotal (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.

orderSubTotal (number, optional)

Payment for the order without shipping. Format: 1/100 of the base currency unit. Example: 100 is 1 USD.

orderTax (number, optional)

Tax included in the order. Format: 1/100 of the base currency unit. Example: 100 is 1 USD.

orderShipping (number, optional)

Shipping costs for the order. Format: 1/100 of the base currency unit. Example: 100 is 1 USD.

orderDiscount (number, optional)

Discounts included in the order. Format: 1/100 of the base currency unit. Example: 100 is 1 USD.

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: { index: { name: 'name', value: 'value' },
  customDimensions: { dimensionID: 'value', dimensionID: 'value', },
};
await PiwikProSdk.trackEcommerce('order_1', 124144, options);