ecommerceOrder
The ecommerceOrder() method tracks conversions, including products and payment details.
Syntax
PiwikTracker.sharedInstance()?.ecommerceOrder(
products: products,
orderId: "orderId",
grandTotal: "grandTotal",
subTotal: "subTotal",
tax: "tax",
shipping: "shipping",
discount: "discount"
)
PiwikTracker.sharedInstance()?.ecommerceOrder(
products: products,
orderId: "orderId",
grandTotal: "grandTotal",
subTotal: "subTotal",
tax: "tax",
shipping: "shipping",
discount: "discount",
currencyCode: "currencyCode"
)[[PiwikTracker sharedInstance] ecommerceOrder:products
orderId:@"orderId"
grandTotal:@"grandTotal"
subTotal:@"subTotal"
tax:@"tax"
shipping:@"shipping"
discount:@"discount"];
[[PiwikTracker sharedInstance] ecommerceOrder:products
orderId:@"orderId"
grandTotal:@"grandTotal"
subTotal:@"subTotal"
tax:@"tax"
shipping:@"shipping"
discount:@"discount"
currencyCode:@"currencyCode"];Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| products | Array<Product> | Yes | List of products. |
| orderId | string | Yes | Unique order identifier. |
| grandTotal | number | string | Yes | The total value of items in a cart. Float number or string containing a float number representation. |
| subTotal | number | string | No | The total value of items in a cart without shipping. Float number or string containing a float number representation. |
| tax | number | string | No | The total tax amount. Float number or string containing a float number representation. |
| shipping | number | string | No | The total shipping cost. Float number or string containing a float number representation. |
| discount | number | string | No | The total discount. Float number or string containing a float number representation. |
| currencyCode | string | No | The ISO 4217 currency code for the event. Example: USD, EUR, PLN. If not provided, the currency configured for the site/app in Piwik PRO is used. |
Product Object
| Attribute | Type | Required | Description |
|---|---|---|---|
| sku | string | Yes | Product stock-keeping unit. |
| name | string | No | Product name. Default: "". |
| category | string | Array<string> | No | Product category or an array of up to 5 categories. Default: "". |
| price | number | string | No | Product price; float number or string containing a float number representation. Default: 0. |
| quantity | number | string | No | Product quantity; integer number or string containing an integer number representation. Default: 1. |
| brand | string | No | Product brand. Default: "". |
| variant | string | No | Product variant. Default: "". |
| customDimensions | object | No | Product custom dimensions. Default: {}. |
Examples
let product = Product.productWithSku(
sku: "craft-311",
name: "Unicorn Iron on Patch",
category: ["Crafts & Sewing", "Toys"],
price: "49.90",
quantity: 3,
brand: "DMZ",
variant: "blue",
customDimensions: [1: "coupon-2020", 2: "20%"]
)
let products = EcommerceProducts()
products.add(product: product)
PiwikTracker.sharedInstance()?.ecommerceOrder(
products: products,
orderId: "order-3415",
grandTotal: "180.00",
subTotal: "120.00",
tax: "39.60",
shipping: "60.00",
discount: "18.00"
)Product *product = [Product productWithSku:@"craft-311"
name:@"Unicorn Iron on Patch"
category:@[@"Crafts & Sewing", @"Toys"]
price:@"49.90"
quantity:@3
brand:@"DMZ"
variant:@"blue"
customDimensions:@{@1: @"coupon-2020", @2: @"20%"}];
EcommerceProducts *products = [[EcommerceProducts alloc] init];
[products addProduct:product];
[[PiwikTracker sharedInstance] ecommerceOrder:products
orderId:@"order-3415"
grandTotal:@"180.00"
subTotal:@"120.00"
tax:@"39.60"
shipping:@"60.00"
discount:@"18.00"];To track the same event with an explicit currency code:
PiwikTracker.sharedInstance()?.ecommerceOrder(
products: products,
orderId: "order-3415",
grandTotal: "180.00",
subTotal: "120.00",
tax: "39.60",
shipping: "60.00",
discount: "18.00",
currencyCode: "USD"
)[[PiwikTracker sharedInstance] ecommerceOrder:products
orderId:@"order-3415"
grandTotal:@"180.00"
subTotal:@"120.00"
tax:@"39.60"
shipping:@"60.00"
discount:@"18.00"
currencyCode:@"USD"];