Product events (Sales Insights)

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

 

Product events

With the tracker, an ecommerce instance is available, exposing different objects and methods useful for measuring:

  • Product displays
  • Product page displays

    Additionally, it’s possible to enable automatic tagging of SalesTracker viewed products 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];
    

  • Add-to-cart or remove-from-cart actions

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 bottom of this page.

 

Product display

Measuring product display is done by creating a DisplayProduct object, to which the following is associated:

  • A list of products, products, which can contain one or several ECommerceProduct-type products.

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 (0 for no; 1 for yes).
  • “pricetaxincluded” – Float: Price, including tax.
  • “pricetaxfree” – Float: Price, excluding tax.
  • “currency” – String: Currency.
  • “stock” – Boolean: Product in stock (0 for no; 1 for yes).
  • “category1” – String: The product’s level 1 category (up to 6 tree structure levels are possible; from “category1” to “category6”).

Example

let tracker: Tracker = ATInternet.sharedInstance.defaultTracker
let dp: DisplayProduct = tracker.ecommerce.displayProducts.add()
dp.products.append(ECommerceProduct(obj: 
    [
        "id": "7",
        "variant": "1",
        "$": "laptop_A56",
        "brand": "ACER",
        "discount": 1,
        "pricetaxincluded": 549,
        "pricetaxfree": 456.2,
        "currency": "EUR",
        "stock": 1,
        "category1": "Computers_and_Networking",
        "category2": "Computers",
        "category3": "Laptops"
    ]))
tracker.dispatch()

You may use the independent method “tracker.events.send()” in order to send only your Ecommerce data.

Tracker* tracker = [ATInternet sharedInstance].defaultTracker;
DisplayProduct *dp = [[tracker.ecommerce displayProducts] add];
NSMutableArray *dpproducts = [dp.products mutableCopy];
[dpproducts addObject:[[ECommerceProduct alloc] initWithObj:@{
    @"id": @"7",
    @"variant": @"1",
    @"$": @"laptop_A56",
    @"brand": @"ACER",
    @"discount": @1,
    @"pricetaxincluded": @549,
    @"pricetaxfree": @456.2,
    @"currency": @"EUR",
    @"stock": @1,
    @"category1": @"Computers_and_Networking",
    @"category2": @"Computers",
    @"category3": @"Laptops"
}]];
[dp setProducts: dpproducts];
[tracker dispatch];

You may use the independent method “[tracker.events send];” in order to send only your Ecommerce data.

 

Product page display

Measuring the display of a product page is done by creating a DisplayPageProduct object, to which the following is associated:

  • an ECommerceProduct-type product.

A product’s properties should be declared as a em>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 (0 for no; 1 for yes).
  • “pricetaxincluded” – Float: Price, including tax.
  • “pricetaxfree” – Float: Price, excluding tax.
  • “currency” – String: Currency.
  • “stock” – Boolean: Product in stock (0 for no; 1 for yes).
  • “category1” – String: The product’s level 1 category (up to 6 tree structure levels are possible; from “category1” to “category6”).

Example

Tracker tracker = let tracker: Tracker = ATInternet.sharedInstance.defaultTracker
let dpp: DisplayPageProduct = tracker.ecommerce.displayPageProducts.add()
_ = dpp.product.setAll(obj: 
    [
        "id": "7",
        "variant": "1",
        "$": "laptop_A56",
        "brand": "ACER",
        "discount": 1,
        "pricetaxincluded": 549,
        "pricetaxfree": 456.2,
        "currency": "EUR",
        "stock": 1,
        "category1": "Computers_and_Networking",
        "category2": "Computers",
        "category3": "Laptops"
    ])
tracker.dispatch()

You may use the independent method “tracker.events.send()” in order to send only your Ecommerce data.

Tracker* tracker = [ATInternet sharedInstance].defaultTracker;
DisplayPageProduct *dpp = [[tracker.ecommerce displayPageProducts] add];
(void)[dpp.product setAllWithObj:@{
    @"id": @"7",
    @"variant": @"1",
    @"$": @"laptop_A56",
    @"brand": @"ACER",
    @"discount": @1,
    @"pricetaxincluded": @549,
    @"pricetaxfree": @456.2,
    @"currency": @"EUR",
    @"stock": @1,
    @"category1": @"Computers_and_Networking",
    @"category2": @"Computers",
    @"category3": @"Laptops"
}];
[tracker dispatch];

You may use the independent method “[tracker.events send];” in order to send only your Ecommerce data.

 

Product addition

Measuring the addition of a product to the cart is done by creating an AddProduct object, to which the following are associated:

  • an ECommerceCart-type cart
  • an ECommerceProduct-type product

A cart must contain a property:

  • “id” – String: Cart ID (mandatory).

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 (0 for no; 1 for yes).
  • “pricetaxincluded” – Float: Price, including tax.
  • “pricetaxfree” – Float: Price, excluding tax.
  • “currency” – String: Currency.
  • “stock” – Boolean: Product in stock (0 for no; 1 for yes).
  • “quantity” – Number: Number of products to add.
  • “category1” – String: CThe product’s level 1 category (up to 6 tree structure levels are possible; from “category1” to “category6”).
  • “cart.creation” – Boolean: Cart creation (1 if the action of adding a product has resulted in cart creation, 0 otherwise).

Example

let tracker: Tracker = ATInternet.sharedInstance.defaultTracker
let ap: AddProduct = tracker.ecommerce.addProducts.add()
_ = ap.cart.set(key: "id", value: "34")
_ = ap.product.setAll(obj:
    [
        "id": "3",
        "variant": "1",
        "$": "laptop_A56",
        "brand": "ACER",
        "discount": 1,
        "pricetaxincluded": 549,
        "pricetaxfree": 456.2,
        "currency": "EUR",
        "stock": 1,
        "quantity": 1,
        "cartcreation": 1,
        "category1": "Computers_and_Networking",
        "category2": "Computers",
        "category3": "Laptops"
    ]
)
tracker.dispatch()

You may use the independent method “tracker.events.send()” in order to send only your Ecommerce data.

Tracker* tracker = [ATInternet sharedInstance].defaultTracker;
AddProduct *ap = [[tracker.ecommerce addProducts] add];
(void)[ap.cart setWithKey:@"id" value:@"34"];
(void)[ap.product setAllWithObj:@{
    @"id": @"3",
    @"variant": @"1",
    @"$": @"laptop_A56",
    @"brand": @"ACER",
    @"discount": @1,
    @"pricetaxincluded": @549,
    @"pricetaxfree": @456.2,
    @"currency": @"EUR",
    @"stock": @1,
    @"quantity": @1,
    @"cartcreation": @1,
    @"category1": @"Computers_and_Networking",
    @"category2": @"Computers",
    @"category3": @"Laptops"
}];
[tracker dispatch];

You may use the independent method “[tracker.events send];” in order to send only your Ecommerce data.

 

Product deletion

Measuring the deletion of a product from the cart is done by creating a RemoveProduct object, to which the following are associated:

  • an ECommerceCart-type cart
  • an ECommerceProduct-type product

A cart must contain a property:

  • “id” – String: Cart ID (mandatory).

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 (0 for no; 1 for yes).
  • “pricetaxincluded” – Float: Price, including tax.
  • “pricetaxfree” – Float: Price, excluding tax.
  • “currency” – String: Currency.
  • “stock” – Boolean: Product in stock (0 for no; 1 for yes).
  • “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”).

Example

let tracker: Tracker = ATInternet.sharedInstance.defaultTracker
let rp: RemoveProduct = tracker.ecommerce.removeProducts.add()
_ = rp.cart.set(key: "id", value: "34")
_ = rp.product.setAll(obj:
    [
        "id": "3",
        "variant": "1",
        "$": "laptop_A56",
        "brand": "ACER",
        "discount": 1,
        "pricetaxincluded": 549,
        "pricetaxfree": 456.2,
        "currency": "EUR",
        "stock": 1,
        "quantity": 1,
        "category1": "Computers_and_Networking",
        "category2": "Computers",
        "category3": "Laptops"
    ]
)
tracker.dispatch()

You may use the independent method “tracker.events.send()” in order to send only your Ecommerce data.

Tracker* tracker = [ATInternet sharedInstance].defaultTracker;
RemoveProduct *rp = [[tracker.ecommerce removeProducts] add];
(void)[rp.cart setWithKey:@"id" value:@"34"];
(void)[rp.product setAllWithObj:@{
    @"id": @"3",
    @"variant": @"1",
    @"$": @"laptop_A56",
    @"brand": @"ACER",
    @"discount": @1,
    @"pricetaxincluded": @549,
    @"pricetaxfree": @456.2,
    @"currency": @"EUR",
    @"stock": @1,
    @"quantity": @1,
    @"category1": @"Computers_and_Networking",
    @"category2": @"Computers",
    @"category3": @"Laptops"
}];
[tracker dispatch];

You may use the independent method “[tracker.events send];” in order to send only your Ecommerce data.

 

Appendix

 

Configuration variables

Name Default value Description Version
collectDomain “” Sales Insights collection domain  >= 2.12.0
autoSalesTracker false Enable automatic measurement of SalesTracker order contents upon transaction confirmation events  >= 2.12.0
 

Was this post helpful?

Last update: 10/09/2019