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

ParameterTypeRequiredDescription
productsArray<Product>YesList of products.
grandTotalnumber | stringYesThe total value of items in a cart. Float number or string containing a float number representation.
currencyCodestringNoThe 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

AttributeTypeRequiredDescription
skustringYesProduct stock-keeping unit.
namestringNoProduct name. Default: "".
categorystring | Array<string>NoProduct category or an array of up to 5 categories. Default: "".
pricenumber | stringNoProduct price; float number or string containing a float number representation. Default: 0.
quantitynumber | stringNoProduct quantity; integer number or string containing an integer number representation. Default: 1.
brandstringNoProduct brand. Default: "".
variantstringNoProduct variant. Default: "".
customDimensionsobjectNoProduct 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