Product events

  • iOS
  • watchOS
  • tvOS
 

Foreword

This tagging documentation only applies to Tracker from version 2.17.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
  • Add-to-cart or remove-from-cart actions
 

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.).
  • “article” – String: Additional level of detail for product variant.
  • “placement” – String: Product placement.
  • “promocode” – Array: Promotional code table including one or several codes. A promotional code is declared as a label.
  • “$” – String: Product name.
  • “brand” – String: Product brand.
  • “discount” – Boolean: Discounted product.
  • “pricetaxincluded” – Float: Price, including tax.
  • “pricetaxfree” – Float: Price, excluding tax.
  • “stock” – Boolean: Product in stock.
  • “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",
        "article": "21",
        "placement": "homepage",
        "promocode": ["AQQYRTGJ"],
        "$": "laptop_A56",
        "brand": "ACER",
        "discount": true,
        "pricetaxincluded": 549,
        "pricetaxfree": 456.2,
        "stock": true,
        "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",
    @"article": @"21",
    @"placement": @"homepage",
    @"promocode": @[@"AQQYRTGJ"],
    @"$": @"laptop_A56",
    @"brand": @"ACER",
    @"discount": @true,
    @"pricetaxincluded": @549,
    @"pricetaxfree": @456.2,
    @"stock": @true,
    @"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.).
  • “article” – String: Additional level of detail for product variant.
  • “placement” – String: Product placement.
  • “promocode” – Array: Promotional code table including one or several codes. A promotional code is declared as a label.
  • “$” – String: Product name.
  • “brand” – String: Product brand.
  • “discount” – Boolean: Discounted product.
  • “pricetaxincluded” – Float: Price, including tax.
  • “pricetaxfree” – Float: Price, excluding tax.
  • “stock” – Boolean: Product in stock.
  • “category1” – String: The product’s level 1 category (up to 6 tree structure levels are possible; from “category1” to “category6”).

In case of SalesTracker tagging activation, you can add screen data by passing an instance of Screen as a parameter.

Example

Tracker tracker = let tracker: Tracker = ATInternet.sharedInstance.defaultTracker
let myScreen: Screen = tracker.screens.add("product")
let dpp: DisplayPageProduct = tracker.ecommerce.displayPageProducts.add(screen: myScreen)
_ = dpp.product.setAll(obj: 
    [
        "id": "7",
        "variant": "1",
        "article": "21",
        "placement": "homepage",
        "promocode": ["AQQYRTGJ"],
        "$": "laptop_A56",
        "brand": "ACER",
        "discount": true,
        "pricetaxincluded": 549,
        "pricetaxfree": 456.2,
        "stock": true,
        "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;
// With SalesTracker
[tracker.ecommerce setAutoSalesTrackerEnabled:YES sync:YES completionHandler:nil];
Screen *myScreen = [tracker.screens add:@"product"];
DisplayPageProduct *dpp = [[tracker.ecommerce displayPageProducts] addWithScreen:myScreen];
(void)[dpp.product setAllWithObj:@{
    @"id": @"7",
    @"variant": @"1",
    @"article": @"21",
    @"placement": @"homepage",
    @"promocode": @[@"AQQYRTGJ"],
    @"$": @"laptop_A56",
    @"brand": @"ACER",
    @"discount": @true,
    @"pricetaxincluded": @549,
    @"pricetaxfree": @456.2,
    @"stock": @true,
    @"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.).
  • “article” – String: Additional level of detail for product variant.
  • “placement” – String: Product placement.
  • “promocode” – Array: Promotional code table including one or several codes. A promotional code is declared as a label.
  • “$” – String: Product name.
  • “brand” – String: Product brand.
  • “discount” – Boolean: Discounted product.
  • “pricetaxincluded” – Float: Price, including tax.
  • “pricetaxfree” – Float: Price, excluding tax.
  • “stock” – Boolean: Product in stock.
  • “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”).
  • “cartcreation” – Boolean: Cart creation (true if the action of adding a product has resulted in cart creation, false 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",
        "article": "21",
        "placement": "homepage",
        "promocode": ["AQQYRTGJ"],
        "$": "laptop_A56",
        "brand": "ACER",
        "discount": true,
        "pricetaxincluded": 549,
        "pricetaxfree": 456.2,
        "stock": true,
        "quantity": 1,
        "cartcreation": true,
        "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",
    @"article": @"21",
    @"placement": @"homepage",
    @"promocode": @[@"AQQYRTGJ"],
    @"$": @"laptop_A56",
    @"brand": @"ACER",
    @"discount": @true,
    @"pricetaxincluded": @549,
    @"pricetaxfree": @456.2,
    @"stock": @true,
    @"quantity": @1,
    @"cartcreation": @true,
    @"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.).
  • “article” – String: Additional level of detail for product variant.
  • “placement” – String: Product placement.
  • “promocode” – Array: Promotional code table including one or several codes. A promotional code is declared as a label.
  • “$” – String: Product name.
  • “brand” – String: Product brand.
  • “discount” – Boolean: Discounted product.
  • “pricetaxincluded” – Float: Price, including tax.
  • “pricetaxfree” – Float: Price, excluding tax.
  • “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”).

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",
        "article": "21",
        "placement": "homepage",
        "promocode": ["AQQYRTGJ"],
        "$": "laptop_A56",
        "brand": "ACER",
        "discount": true,
        "pricetaxincluded": 549,
        "pricetaxfree": 456.2,
        "stock": true,
        "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",
    @"article": @"21",
    @"placement": @"homepage",
    @"promocode": @[@"AQQYRTGJ"],
    @"$": @"laptop_A56",
    @"brand": @"ACER",
    @"discount": @true,
    @"pricetaxincluded": @549,
    @"pricetaxfree": @456.2,
    @"stock": @true,
    @"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.

Cet article a-t-il été utile ?

Last update: 12/08/2020