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

 

Transaction events

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

 

Transaction confirmation

Measuring transaction confirmations is done by creating a TransactionConfirmation object, to which the following can be associated:

  • An ECommerceCart-type cart
  • Shipping data in an ECommerceShipping-type object
  • Payment data in an ECommercePayment-type object
  • Transaction data in an ECommerceTransaction-type object
  • 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.
  • “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 transaction 's properties should be declared as a Dictionary-type collection, with different keys:

  • “id” – String: Transaction ID (mandatory).
  • “status” – String: Transaction status.
  • “promocode” – Array: Promotional code table including one or several codes. A promotional code is declared as a label.
  • “firstpurchase” – Boolean: First customer purchase.

Delivery data should be declared as a Dictionary-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 product 's properties should be declared in 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.
  • “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”).

Example

let tracker: Tracker = ATInternet.sharedInstance.defaultTracker
let tc: TransactionConfirmation = tracker.ecommerce.transactionConfirmations.add()
_ = tc.cart.setAll(obj:
    [
        "id": "34",
        "creation_utc": 1514973161, //UTC timestamp in seconds
        "turnovertaxfree": 447.76, //Shipping fees included + discount 8€44
        "turnovertaxincluded": 547.4, //Shipping fees included + discount 10€
        "nbdistinctproduct": 1,
        "quantity": 1,
        "currency": "EUR"
    ]
)
_ = tc.transaction.setAll(obj:
    [
        "id": "27",
        "status": "charged",
        "promocode": ["DQQYRZSJ", "UN1ENE27"],
        "firstpurchase": false
    ]
)
_ = tc.shipping.setAll(obj:
    [
        "costtaxfree": 7,
        "costtaxincluded": 8.4,
        "delivery": "My carrier"
    ]
)
_ = tc.payment.set(key: "mode", value: "Credit card")
_ = tc.products.append(ECommerceProduct(obj:
    [
        "id": "1",
        "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;
TransactionConfirmation *tc = [[tracker.ecommerce transactionConfirmations] add];
NSMutableArray *tcproducts = [tc.products mutableCopy];
(void)[tc.cart setAllWithObj:@{
    @"id": @"34",
    @"creation_utc": @1514973161, //UTC timestamp in seconds
    @"turnovertaxfree": @447.76, //Shipping fees included + discount 8€44
    @"turnovertaxincluded": @547.4, //Shipping fees included + discount 10€
    @"nbdistinctproduct": @1,
    @"quantity": @1,
    @"currency": @"EUR"
}];
(void)[tc.transaction setAllWithObj:@{
    @"id": @"27",
    @"status": @"charged",
    @"promocode": @[@"DQQYRZSJ", @"UN1ENE27"],
    @"firstpurchase": @false
}];
(void)[tc.shipping setAllWithObj:@{
    @"costtaxfree": @7,
    @"costtaxincluded": @8.4,
    @"delivery": @"My carrier"
}];
(void)[tc.payment setWithKey:@"mode" value: @"Credit card"];
[tcproducts addObject:[[ECommerceProduct alloc] initWithObj:@{
    @"id": @"1",
    @"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"
}]];
[tc setProducts: tcproducts];
[tracker dispatch];

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

 

Transaction confirmation on server-side

You can validate a cart awaiting payment event by generating a HTTP GET call on server-side:

https://YOURSSLCOLLECTDOMAIN/hit.xiti?s=XXXXX&col=2&events=[{"name":"transaction.confirmation","data":{"cart_id":"XXXXX", "transaction_id":"XXXXX", "offsite_confirmation":true}]&rdt=off

In this call, you must replace values XXXXX by :

  • the site number concerned by the transaction:
    ?s=XXXXX
  • the cart ID to be validated:
    "cart_id":"XXXXX"
  • the transaction ID:
    "transaction_id":"XXXXX"
Last update: 12/08/2020