Cart events (Sales Insights)

 

Foreword

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

    Additionally, it’s possible to enable automatic tagging of SalesTracker cart content by overriding the “autoSalesTracker” configuration variable:

    Tracker tracker = ATInternet.getInstance().getDefaultTracker();
    tracker.ECommerce().setAutoSalesTrackerEnabled(true, null, true);
    

  • Cart updates
  • Delivery and payment steps

The Ecommerce collection domain must be indicated via the “collectDomain” configuration variable:

tracker.ECommerce().setCollectDomain("collect-euw1", null, true);

See the full list of Ecommerce configuration variables that can be overridden at the end of this page.

 

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.

A product’s properties should be declared as a HashMap-type collection, with different keys:

  • “id” – String: Product ID (mandatory).
  • “name” – String: Product name.
  • “priceTaxIncluded” – Float: Total price, including tax.
  • “priceTaxFree” – Float: Total price, excluding tax.
  • “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”).

Declaring products is optional for the Ecommerce analysis. Products, if declared, only enable you to enrich the analysis with SalesTracker sales/order information. The only parameters to declare are therefore the parameters necessary for SalesTracker tagging.

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");
}});
dc.Products().add(new ECommerceProduct(new HashMap<String, Object>() {{
    put("id", "7");
    put("variant", "1");
    put("name", "laptop_A56");
    put("brand", "ACER");
    put("discount", 1);
    put("priceTaxIncluded", 549);
    put("priceTaxFree", 456.2);
    put("currency", "EUR");
    put("stock", 1);
    put("category1", "Computers_and_Networking");
    put("category2", "Computers");
    put("category3", "Laptops");
}}));
tracker.dispatch();
 

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();
 

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();
 

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
  • payment data in the form of an ECommercePayment-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.
Payment method should be declared in a property:
  • “mode” – String: Payment method.

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");
}});
pc.Payment().set("mode", "Credit card");
tracker.dispatch();
 

Appendix

 

Configuration variables

Nom Valeur par défaut Description Version
collectDomain “” Sales Insights collection domain  >= 2.11.0
autoSalesTracker false Enable automatic measurement of SalesTracker cart content on a cart display event  >= 2.11.0
Was this post helpful?
Yes
No
Last update: 07/05/2019