Developers » AS2 tagging » Apple » Ecommerce » Sales Insights » Cart events
Cart events
- iOS
- watchOS
- tvOS
Foreword
This tagging documentation only applies to Tracker from version 2.15.0.
If you can’t see the “Sales Insights” menu entry in Explorer, please get in touch with us so we can activate this for you.
Cart events
With the tracker, an ecommerce instance is available, exposing different objects and methods useful for measuring:
- Cart displays
- Cart updates
- Delivery and payment steps
- Cart awaiting payment
Cart display
Measuring cart display is done by creating a DisplayCart object, to which the following are associated:
- An ECommerceCart-type cart
A cart’s properties should be declared as a Dictionary-type collection, with different keys:
- “id” – String: Cart ID (mandatory).
- “currency” – String: Currency.
- “turnovertaxincluded” – Float: Total amount of cart, including tax.
- “turnovertaxfree” – Float: Total amount of cart, excluding tax.
- “quantity” – Number: Total number of products in the cart.
- “nbdistinctproduct” – Number: Number of distinct products in the cart.
Example
let tracker: Tracker = ATInternet.sharedInstance.defaultTracker let dc: DisplayCart = tracker.ecommerce.displayCarts.add() _ = dc.cart.setAll(obj: [ "id": "53", "turnovertaxfree": 456.2, "turnovertaxincluded": 549, "nbdistinctproduct": 1, "quantity": 1, "currency": "EUR" ] ) tracker.dispatch()
You may use the independent method “tracker.events.send()” in order to send only your Ecommerce data.
Tracker* tracker = [ATInternet sharedInstance].defaultTracker; DisplayCart *dc = [[tracker.ecommerce displayCarts] add]; (void)[dc.cart setAllWithObj:@{ @"id": @"53", @"turnovertaxfree": @456.2, @"turnovertaxincluded":@549, @"nbdistinctproduct": @1, @"quantity": @1, @"currency": @"EUR" }]; [tracker dispatch];
You may use the independent method “[tracker.events send];” in order to send only your Ecommerce data.
Display the delivery step
Measuring the delivery step is done by creating a DeliveryCheckout object, to which the following are associated:
- an ECommerceCart-type cart
- delivery data in the form of an ECommerceDelivery-type object
A cart’s properties should be declared as a Dictionary-type collection, with different keys:
- “id” – String: Cart ID (mandatory).
- “currency” – String: Currency.
- “turnovertaxincluded” – Float: Total amount of cart, including tax.
- “turnovertaxfree” – Float: Total amount of cart, excluding tax.
- “quantity” – Number: Total number of products in the cart.
- “nbdistinctproduct” – Number: Number of distinct products in the cart.
Delivery data should be declared as a Dictionary-type collection, with different keys (to be indicated if they are already known at this step):
- “delivery” – String: Name of shipping company.
- “costtaxincluded” – Float: Amount of shipping costs, including tax.
- “costtaxfree” – Float: Amount of shipping costs, excluding tax.
Shipping data should only be indicated once, either during the delivery step, or during the payment step.
Example
let tracker: Tracker = ATInternet.sharedInstance.defaultTracker let dch: DeliveryCheckout = tracker.ecommerce.deliveryCheckouts.add() _ = dch.cart.setAll(obj: [ "id": "34", "turnovertaxfree": 34, "turnovertaxincluded": 40.8, "nbdistinctproduct": 1, "quantity": 1, "currency": "EUR" ] ) _ = dch.shipping.setAll(obj: [ "costtaxfree": 7, "costtaxincluded": 8.4, "delivery": "My carrier" ] ) tracker.dispatch()
You may use the independent method “tracker.events.send()” in order to send only your Ecommerce data.
Tracker* tracker = [ATInternet sharedInstance].defaultTracker; DeliveryCheckout *dch = [[tracker.ecommerce deliveryCheckouts] add]; (void)[dch.cart setAllWithObj:@{ @"id": @"34", @"turnovertaxfree": @34, @"turnovertaxincluded": @40.8, @"nbdistinctproduct": @1, @"quantity": @1, @"currency": @"EUR" }]; (void)[dch.shipping setAllWithObj:@{ @"costtaxfree": @7, @"costtaxincluded": @8.4, @"delivery": @"My carrier" }]; [tracker dispatch];
You may use the independent method “[tracker.events send];” in order to send only your Ecommerce data.
Display the payment step
Measuring the payment step is done by creating a PaymentCheckout object, to which the following are associated:
- An ECommerceCart-type cart
- Delivery data in the form of an ECommerceDelivery-type object
A cart’s properties should be declared as a Dictionary-type collection, with different keys:
- “id” – String: Cart ID (mandatory).
- “currency” – String: Currency.
- “turnovertaxincluded” – Float: Total amount of cart, including tax (shipping costs included).
- “turnovertaxfree” – Float: Total amount of cart, excluding tax (shipping costs included).
- “quantity” – Number: Total number of products in the cart.
- “nbdistinctproduct” – Number: Number of distinct products in the cart.
Delivery data should be declared as a Dictionary-type collection, with different keys (to be indicated if they are already known at this step):
- “delivery” – String: Name of shipping company.
- “costtaxincluded” – Float: Amount of shipping costs, including tax.
- “costtaxfree” – Float: Amount of shipping costs, excluding tax.
Shipping data should only be indicated once, either during the delivery step, or during the payment step.
Example
let tracker: Tracker = ATInternet.sharedInstance.defaultTracker let pch: PaymentCheckout = tracker.ecommerce.paymentCheckouts.add() _ = pch.cart.setAll(obj: [ "id": "34", "turnovertaxfree": 34, "turnovertaxincluded": 40.8, "nbdistinctproduct": 1, "quantity": 1, "currency": "EUR" ] ) _ = pch.shipping.setAll(obj: [ "costtaxfree": 7, "costtaxincluded": 8.4, "delivery": "My carrier" ] ) tracker.dispatch()
You may use the independent method “tracker.events.send()” in order to send only your Ecommerce data.
Tracker* tracker = [ATInternet sharedInstance].defaultTracker; PaymentCheckout *pch = [[tracker.ecommerce paymentCheckouts] add]; (void)[pch.cart setAllWithObj:@{ @"id": @"34", @"turnovertaxfree": @34, @"turnovertaxincluded": @40.8, @"nbdistinctproduct": @1, @"quantity": @1, @"currency": @"EUR" }]; (void)[pch.shipping setAllWithObj:@{ @"costtaxfree": @7, @"costtaxincluded": @8.4, @"delivery": @"My carrier" }]; [tracker dispatch];
You may use the independent method “[tracker.events send];” in order to send only your Ecommerce data.
Cart awaiting payment
A cart awaiting payment has to be validated with a transaction confirmation on server-side.
Measuring a cart awaiting payment is done by creating a CartAwaitingPayment object, to which the following can be associated:
- An ECommerceCart-type cart
- A list of products, products, which can contain one or several ECommerceProduct-type products
- Shipping data in an ECommerceShipping-type object
- Payment data in an ECommercePayment-type object
- Transaction data in an ECommerceTransaction-type object
A cart’s properties should be declared as a Dictionary-type collection, with different keys:
- “id” – String: Cart ID.
- “currency” – String: Currency.
- “turnovertaxincluded” – Float: Total amount of cart, including tax (shipping costs included).
- “turnovertaxfree” – Float: Total amount of cart, excluding tax (shipping costs included).
- “creation_utc” – Date: Date of creation of the cart (timestamp UTC in seconds).
- “quantity” – Number: Total number of products in the cart.
- “nbdistinctproduct” – Number: Number of distinct products in the cart.
A product’s properties should be declared as a Dictionary-type collection, with different keys:
- “id” – String: Product ID (mandatory).
- “variant” – String: Product variant (size, colour, etc.).
- “$” – String: Product name.
- “brand” – String: Product brand.
- “discount” – Boolean: Discounted product.
- “pricetaxincluded” – Float: Price, including tax.
- “pricetaxfree” – Float: Price, excluding tax.
- “currency” – String: Currency.
- “stock” – Boolean: Product in stock.
- “quantity” – Number: Number of products to add.
- “category1” – String: The product’s level 1 category (up to 6 tree structure levels are possible; from “category1” to “category6”).
Delivery data should be declared as a Dictionary-type collection, with different keys:
- “delivery” – String: Name of shipping company.
- “costtaxincluded” – Float: Amount of shipping costs, including tax.
- “costtaxfree” – Float: Amount of shipping costs, excluding tax.
Payment method should be declared in a property:
- “mode” – String: Payment method.
A transaction’s properties should be declared as a Dictionary-type collection, with different keys:
- “promocode” – Array: Promotional code table including one or several codes. A promotional code is declared as a label.
- “firstpurchase” – Boolean: First customer purchase.
Example
let tracker: Tracker = ATInternet.sharedInstance.defaultTracker let cap: CartAwaitingPayment = tracker.ecommerce.cartAwaitingPayments.add() _ = cap.cart.setAll(obj: [ "id": "34", "turnovertaxfree": 463.2, "turnovertaxincluded": 557.4, "nbdistinctproduct": 1, "quantity": 1, "currency": "EUR", "creation_utc": 1514973161 //UTC timestamp in seconds ] ) cap.products.append(ECommerceProduct(obj: [ "id": "7", "variant": "1", "$": "laptop_A56", "brand": "ACER", "discount": true, "pricetaxincluded": 549, "pricetaxfree": 456.2, "currency": "EUR", "stock": true, "quantity": 1, "category1": "Computers_and_Networking", "category2": "Computers", "category3": "Laptops" ])) _ = cap.shipping.setAll(obj: [ "costtaxfree": 7, "costtaxincluded": 8.4, "delivery": "My carrier" ] ) _ = cap.payment.set(key: "mode", value: "Credit card") _ = cap.transaction.setAll(obj: [ "promocode": ["DQQYRZSJ", "UN1ENE27"], "firstpurchase": false ] ) tracker.dispatch()
You may use the independent method “tracker.events.send()” in order to send only your Ecommerce data.
Tracker* tracker = [ATInternet sharedInstance].defaultTracker; CartAwaitingPayment *cap = [[tracker.ecommerce cartAwaitingPayments] add]; NSMutableArray *capproducts = [cap.products mutableCopy]; (void)[cap.cart setAllWithObj:@{ @"id": @"34", @"turnovertaxfree": @463.2, @"turnovertaxincluded": @557.4, @"nbdistinctproduct": @1, @"quantity": @1, @"currency": @"EUR", @"creation_utc": @1514973161 //UTC timestamp in seconds }]; [capproducts addObject:[[ECommerceProduct alloc] initWithObj:@{ @"id": @"7", @"variant": @"1", @"$": @"laptop_A56", @"brand": @"ACER", @"discount": @true, @"pricetaxincluded": @549, @"pricetaxfree": @456.2, @"currency": @"EUR", @"stock": @true, @"quantity": @1, @"category1": @"Computers_and_Networking", @"category2": @"Computers", @"category3": @"Laptops" }]]; (void)[cap.shipping setAllWithObj:@{ @"costtaxfree": @7, @"costtaxincluded": @8.4, @"delivery": @"My carrier" }]; (void)[cap.payment setWithKey:@"mode" value: @"Credit card"]; (void)[cap.transaction setAllWithObj:@{ @"promocode": @[@"DQQYRZSJ", @"UN1ENE27"], @"firstpurchase": @false }]; [cap setProducts: capproducts]; [tracker dispatch];
You may use the independent method “[tracker.events send];” in order to send only your Ecommerce data.