trackEcommerceAddToCart

The trackEcommerceAddToCart() method tracks when a product is added to the cart.

Syntax

await FlutterPiwikPro.sharedInstance.trackEcommerceAddToCart(
    products: ecommerceProducts,
    currencyCode: 'currencyCode',
);

Parameters

products (Array<EcommerceProduct>, required)

The product list. Each product should have these attributes:

sku (string, required)

The product stock keeping unit (SKU).

name (string, optional)

The product name. Default: "".

category (string|Array<string>, optional)

The product category or an array of up to 5 categories. Default: "".

price (number|string, optional)

The product price. Use a float number or a string that contains a float number. Default: 0.

quantity (number|string, optional)

The product quantity. Use an integer or a string that contains an integer. Default: 1.

brand (string, optional)

The product brand. Default: "".

variant (string, optional)

The product variant. Default: "".

customDimensions (object, optional)

The product custom dimensions. Default: {}.

currencyCode (string, optional)

The ISO 4217 currency code for the product prices. Example: USD, EUR, PLN.

Examples

final ecommerceproducts = [
EcommerceProduct(sku: 'craft-311', 
                name: 'Unicorn Iron on Patch', 
                category: ['Crafts & Sewing', 'Toys'], 
                price: '49.9089', 
                quantity: 3, 
                brand: 'DMZ', 
                variant: 'blue',  
                customDimensions: {1: 'coupon-2020', 2: '20%'}),
EcommerceProduct(sku: 'dert-456')
];
await FlutterPiwikPro.sharedInstance.trackEcommerceAddToCart(
    products: ecommerceProducts,
);

Related methods