Cart events (Sales Insights)

  • iOS
  • watchOS
  • tvOS
 

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 instance 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:

    let tracker: Tracker = ATInternet.sharedInstance.defaultTracker
    tracker.ecommerce.setAutoSalesTrackerEnabled(true, sync: true, completionHandler: nil)
    Tracker* tracker = [ATInternet sharedInstance].defaultTracker;
    [tracker.ecommerce setAutoSalesTrackerEnabled:YES sync:YES completionHandler:nil];
    

  • Cart updates
  • Delivery and payment steps

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

tracker.ecommerce.setCollectDomain("collect-euw1", sync: true, completionHandler: nil)
[tracker.ecommerce setCollectDomain:@"collect-euw1" sync:YES completionHandler:nil];

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

 

Cart display

Measuring 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 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.

A product’s properties should be declared as a Dictionary-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 Sales Insights 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

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"
    ]
)
_ = dc.products.append(ECommerceProduct(obj: 
    [
        "id": "7",
        "name": "laptop_A56",
        "priceTaxIncluded": 549,
        "priceTaxFree": 456.2, 
        "quantity": 1,
        "category1": "Computers_and_Networking",
        "category2": "Computers",
        "category3": "Laptops"
    ]))
tracker.dispatch()
Tracker* tracker = [ATInternet sharedInstance].defaultTracker;
DisplayCart *dc = [[tracker.ecommerce displayCarts] add];
NSMutableArray *dcproducts = [dc.products mutableCopy];
(void)[dc.cart setAllWithObj:@{
    @"id": @"53",
    @"turnoverTaxFree": @456.2,
    @"turnoverTaxIncluded":@549,
    @"nbDistinctProduct": @1,
    @"quantity": @1,
    @"currency": @"EUR"
}];
[dcproducts addObject:[[ECommerceProduct alloc] initWithObj:@{
    @"id": @"7",
    @"name": @"laptop_A56",
    @"priceTaxIncluded": @549,
    @"priceTaxFree": @456.2,
    @"category1": @"Computers_and_Networking",
    @"category2": @"Computers", 
    @"quantity": @1,
    @"category3": @"Laptops"
}]];
[dc setProducts: dcproducts];
[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 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()
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];

 

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

 

Annexes

 

Configuration variables

Nom Valeur par défaut Description Version
collectDomain “” Sales Insights collection domain  >= 2.12.0
autoSalesTracker false Enable automatic measurement of SalesTracker cart content on a cart display event  >= 2.12.0
 

Was this post helpful?

Last update: 21/06/2019