Developers » AS2 tagging » Android » Ecommerce » Sales Insights » Cart events
Cart events
Foreword
This tagging documentation only applies to Tracker from version 2.13.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 object is available, exposing different objects and methods useful for measuring:
- Cart displays
- Cart updates
- Delivery and payment steps
- Cart awaiting payment
Cart display
Measuring a cart display is done by creating a DisplayCart object, to which the following are associated:
- An ECommerceCart-type cart
- A list of products, products, which can contain one or several ECommerceProduct– type products.
A cart’s properties should be declared as a HashMap-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
Tracker tracker = ATInternet.getInstance().getDefaultTracker(); DisplayCart dc = tracker.ECommerce().DisplayCarts().add(); dc.Cart().setAll(new HashMap<String, Object>() {{ put("id", "53"); put("turnovertaxfree", 456.2); put("turnovertaxincluded", 549); put("nbdistinctproduct", 1); put("quantity", 1); put("currency", "EUR"); }}); tracker.dispatch();
You may use the independent method “tracker.Events.send()” in order to send only your Ecommerce data.
Cart updates
Measuring a cart update is done by creating an UpdateCart object, to which the following is associated:
- an ECommerceCart-type cart
A cart’s properties should be declared as a HashMap-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
Tracker tracker = ATInternet.getInstance().getDefaultTracker(); UpdateCart uc = tracker.ECommerce().UpdateCarts().add(); uc.Cart().setAll(new HashMap<String, Object>() {{ put("id", "34"); put("turnoverTaxFree", 52); put("turnovertaxincluded", 62.4); put("nbdistinctproduct", 1); put("quantity", 2); put("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 HashMap-type collection, with different keys:
- « id » – String : Identifiant du panier (obligatoire).
- « currency » – String : Devise.
- « turnovertaxincluded » – Float : Montant total TTC du panier.
- « turnovertaxfree » – Float : Montant total HT du panier.
- « quantity » – Number : Nombre total de produits dans le panier.
- « nbdistinctproduct » – Number : Nombre de produits distincts dans le panier.
Delivery data should be delcared as a HashMap-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
Tracker tracker = ATInternet.getInstance().getDefaultTracker(); DeliveryCheckout dch = tracker.ECommerce().DeliveryCheckouts().add(); dch.Cart().setAll(new HashMap<String, Object>() {{ put("id", "34"); put("turnovertaxfree", 34); put("turnovertaxincluded", 40.8); put("nbdistinctproduct", 1); put("quantity", 1); put("currency", "EUR"); }}); dch.Shipping().setAll(new HashMap<String, Object>() {{ put("costtaxfree", 7); put("costtaxincluded", 8.4); put("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 ECommerceShipping-type object
A cart’s properties should be declared as a HashMap-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 HashMap-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
Tracker tracker = ATInternet.getInstance().getDefaultTracker(); PaymentCheckout pc = tracker.ECommerce().PaymentCheckouts().add(); pc.Cart().setAll(new HashMap<String, Object>() {{ put("id", "34"); put("turnovertaxfree", 34); put("turnovertaxincluded", 40.8); put("nbdistinctproduct", 1); put("quantity", 1); put("currency", "EUR"); }}); pc.Shipping().setAll(new HashMap<String, Object>() {{ put("costTaxFree", 7); put("costTaxIncluded", 8.4); put("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 HashMap-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 in a HashMap-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 in the cart.
- “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 HashMap-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 HashMap-type collection, with different keys:
- “promocode” – ArrayList : Promotional code table including one or several codes. A promotional code is declared as a label.
- “firstpurchase” – Boolean: First customer purchase.
Example
Tracker tracker = ATInternet.getInstance().getDefaultTracker(); CartAwaitingPayment cap = tracker.ECommerce().CartAwaitingPayments().add(); cap.Cart().setAll(new HashMap<String, Object>() {{ put("id", "34"); put("currency", "EUR"); put("turnovertaxfree", 463.2); put("turnovertaxincluded", 557.4); put("creation_utc", 1514973161); put("quantity", 1); put("nbdistinctproduct", 1); }}); cap.Products().add(new ECommerceProduct(new HashMap<String, Object>() {{ put("id", "7"); put("variant", "1"); put("$", "laptop_A56"); put("brand", "ACER"); put("discount", true); put("pricetaxincluded", 549); put("pricetaxfree", 456.2); put("currency", "EUR"); put("stock", true); put("quantity", 1); put("category1", "Computers_and_Networking"); put("category2", "Computers"); put("category3", "Laptops"); }})); cap.Shipping().setAll(new HashMap<String, Object>() {{ put("costtaxfree", 7); put("costtaxincluded", 8.4); put("delivery", "My carrier"); }}); cap.Payment().set("mode", "Credit card"); cap.Transaction().setAll(new HashMap<String, Object>(){{ put("promocode", new ArrayList<String>() {{ add("DQQYRZSJ"); add("UN1ENE27"); }}); put("firstpurchase", false); }}); tracker.dispatch();
You may use the independent method “tracker.Events.send()” in order to send only your Ecommerce data.Last update: 20/05/2020