ecommerceCartUpdate
The ecommerceCartUpdate() method tracks the current state of the cart.
Syntax
PiwikTracker.sharedInstance()?.ecommerceCartUpdate(products: products, grandTotal: "grandTotal")
PiwikTracker.sharedInstance()?.ecommerceCartUpdate(products: products, grandTotal: "grandTotal", currencyCode: "currencyCode")[[PiwikTracker sharedInstance] ecommerceCartUpdate:products grandTotal:@"grandTotal"];
[[PiwikTracker sharedInstance] ecommerceCartUpdate:products grandTotal:@"grandTotal" currencyCode:@"currencyCode"];Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| products | Array<Product> | Yes | List of products. |
| grandTotal | number | string | Yes | The total value of items in a cart. 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()?.ecommerceCartUpdate(products: products, grandTotal: "180.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] ecommerceCartUpdate:products grandTotal:@"180.00"];To track the same event with an explicit currency code:
PiwikTracker.sharedInstance()?.ecommerceCartUpdate(products: products, grandTotal: "180.00", currencyCode: "USD")[[PiwikTracker sharedInstance] ecommerceCartUpdate:products grandTotal:@"180.00" currencyCode:@"USD"];Related methods
Updated 22 days ago