Orders

  • iOS
  • watchOS
  • tvOS
 

Foreword

AT Internet’s SDK allows you to tag orders placed by your users while using your application.

 

Get off to a good start

Once your tag is initialised, you can add order information to your screen hit.

In the case of a Swift project, be sure to import the Tracker module in your ViewController. In the case of an Objective-C project, be sure to import the header SmartTracker-Swift.h

 

Tagging

The tracker makes an orders property available. This property exposes an add method allowing the inclusion of order information, and the addition of this information to your screen tagging.

This method sends back an Order-type object.

 

Tagging examples

  1. Tagging an order and a main goal screen
    Without the SalesTracker option

    Even without the SalesTracker option enabled, you can measure the order confirmation screen (main goal) and insert the order total (turnover) as well as the order number (orderId).

     


    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
        let tracker: Tracker = ATInternet.sharedInstance.defaultTracker
        
        override func viewDidLoad() {
            super.viewDidLoad()
        }
        
        override func viewWillAppear(_ animated: Bool) {
            let screen = tracker.screens.add("Main goal screen")
            screen.order = Order(orderId: "8235", turnover: 2049.30)
            screen.sendView()
        }
    }

    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    @property (nonatomic, strong) Tracker* tracker;
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        
        self.tracker = [ATInternet sharedInstance].defaultTracker;
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
        [self.tracker.orders add:@"8235" turnover:2049.30];
        [[self.tracker.screens add:@"Main goal screen"] sendView];
    }
    
    @end

    With the SalesTracker option

    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
        let tracker: Tracker = ATInternet.sharedInstance.defaultTracker
        
        override func viewDidLoad() {
            super.viewDidLoad()
        }
        
        override func viewWillAppear(_ animated: Bool) {            
            let order = tracker.orders.add("cmd1", turnover: 94.30, status: 1)
            // First order from that customer
            order.isNewCustomer = true
            // Payment Method
            order.paymentMethod = 1
            // Order Status
            order.status = 1
            // Order amount
            order.amount.set(80, amountTaxIncluded: 94.30, taxAmount: 14)
            // Order delivery info
            order.delivery.set(5, shippingFeesTaxIncluded: 7.5, deliveryMethod: "1[UPS]")
            // Discount info
            order.discount.set(5, discountTaxIncluded: 7.5, promotionalCode: "SUMMER")
            
            let confirmOrderScreen = tracker.screens.add("Order confirmation")
            confirmOrderScreen.sendView()
        }
    }
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    @property (nonatomic, strong) Tracker* tracker;
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        
        self.tracker = [ATInternet sharedInstance].defaultTracker;
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
       
        Order* order = [self.tracker.orders add:@"cmd1" turnover: 94.30 status: 1];
        // First order from that custom
        order.isNewCustomer = YES;
        // Payment Method
        order.paymentMethod = 1;
        // Order Status
        order.status = 1;    
        // Order amount
        [order.amount set:80 amountTaxIncluded:94.30 taxAmount: 14];
        // Order delivery info
        [order.delivery set:5 shippingFeesTaxIncluded: 7.5 deliveryMethod: @"1[UPS]"];
        // Discount info
        [order.discount set:5 discountTaxIncluded: 7.5 promotionalCode: @"SUMMER"];
        
        Screen *confirmOrderScreen = [self.tracker.screens add:@"Order confirmation"];
        [confirmOrderScreen sendView];
    }
    
    @end
  2. Tagging an order with cart information
    For more information on tagging your cart, please visit this page: Cart (SalesTracker)

    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
        let tracker: Tracker = ATInternet.sharedInstance.defaultTracker
        
        override func viewDidLoad() {
            super.viewDidLoad()
        }
        
        override func viewWillAppear(_ animated: Bool) {
            tracker.cart.set("1")
            
            let p1 = tracker.cart.products.add("ID[p1]")
            p1.category1 = "10[Shoes]"
            p1.quantity = 1
            p1.unitPriceTaxFree = 70
            p1.unitPriceTaxIncluded = 85
            p1.promotionalCode = "ATInternet"
            p1.discountTaxFree = 0
            p1.discountTaxIncluded = 0
            
            let p2 = tracker.cart.products.add("ID[p2]")
            p2.category1 = "20[Socks]"
            p2.quantity = 2
            p2.unitPriceTaxFree = 5
            p2.unitPriceTaxIncluded = 7
            
            let order = tracker.orders.add("cmd1", turnover: 94.30, status: 1)
            // First order from that custom
            order.isNewCustomer = true
            // Payment Method
            order.paymentMethod = 1
            // Order Status
            order.status = 1
            // Order amount
            order.amount.set(80, amountTaxIncluded: 94.30, taxAmount: 14)
            // Order delivery info
            order.delivery.set(5, shippingFeesTaxIncluded: 7.5, deliveryMethod: "1[UPS]")
            // Discount info
            order.discount.set(5, discountTaxIncluded: 7.5, promotionalCode: "SUMMER")
            
            let confirmOrderScreen = tracker.screens.add("Order confirmation")
            confirmOrderScreen.sendView()
            
            tracker.cart.unset()
        }
    }
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    @property (nonatomic, strong) Tracker* tracker;
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        
        self.tracker = [ATInternet sharedInstance].defaultTracker;
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
    
        [self.tracker.cart set:@"1"];
        
        Product *p1 = [self.tracker.cart.products addString:@"ID[p1]"];
        p1.category1 = @"10[Shoes]";
        p1.quantity = 1;
        p1.unitPriceTaxFree = 70;
        p1.unitPriceTaxIncluded = 85;
        p1.promotionalCode = @"ATInternet";
        p1.discountTaxFree = 0;
        p1.discountTaxIncluded = 0;
        
        Product *p2 = [self.tracker.cart.products addString:@"ID[p2]"];
        p2.category1 = @"20[Socks]";
        p2.quantity = 2;
        p2.unitPriceTaxFree = 5;
        p2.unitPriceTaxIncluded = 7;
        
        Order* order = [self.tracker.orders add:@"cmd1" turnover:94.30 status: 1];
        // First order from that custom
        order.isNewCustomer = YES;
        // Payment Method
        order.paymentMethod = 1;
        // Order Status
        order.status = 1;
        // Order amount
        [order.amount set:80 amountTaxIncluded: 94.30 taxAmount: 14];
        // Order delivery info
        [order.delivery set:5 shippingFeesTaxIncluded: 7.5 deliveryMethod: @"1[UPS]"];
        // Discount info
        [order.discount set:5 discountTaxIncluded: 7.5 promotionalCode: @"SUMMER"];
        
        Screen *confirmOrderScreen = [self.tracker.screens add:@"Order confirmation"];
        [confirmOrderScreen sendView];
        
        [self.tracker.cart unset];
    }
    
    @end
  3. Tagging an order confirmation screen on an app or external site
    The goal here is to be able to measure completed orders and reservations, despite the fact that the confirmation screen is hosted by an app or on an external site (like banking platforms, PayPal…). The tag must be placed on the screen preceding the user’s detour toward the banking or payment platform (the screen containing all information about the order/reservation and its content).

    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
        let tracker: Tracker = ATInternet.sharedInstance.defaultTracker
        
        override func viewDidLoad() {
            super.viewDidLoad()
        }
        
        override func viewWillAppear(_ animated: Bool) {        
            let order = tracker.orders.add("cmd1", turnover: 94.30, status: 1)
            // First order from that custom
            order.isNewCustomer = true
            // Payment Method
            order.paymentMethod = 1
            // Order Status
            order.status = 1
            // Order needs confirmation (bank validation)
            order.isConfirmationRequired = true
            // Order amount
            order.amount.set(80, amountTaxIncluded: 94.30, taxAmount: 14)
            // Order delivery info
            order.delivery.set(5, shippingFeesTaxIncluded: 7.5, deliveryMethod: "1[UPS]")
            // Discount info
            order.discount.set(5, discountTaxIncluded: 7.5, promotionalCode: "SUMMER")
            
            let myScreen = tracker.screens.add("Order info before payment")
            myScreen.sendView()
        }
    }
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    @property (nonatomic, strong) Tracker* tracker;
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        
        self.tracker = [ATInternet sharedInstance].defaultTracker;
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
    
        Order* order = [self.tracker.orders add:@"cmd1" turnover:94.30 status: 1];
        // First order from that custom
        order.isNewCustomer = YES;
        // Payment Method
        order.paymentMethod = 1;
        // Order Status
        order.status = 1;
        // Order needs confirmation (bank validation)
        order.isConfirmationRequired = YES;
        // Order amount
        [order.amount set:80 amountTaxIncluded: 94.30 taxAmount: 14];
        // Order delivery info
        [order.delivery set:5 shippingFeesTaxIncluded: 7.5 deliveryMethod: @"1[UPS]"];
        // Discount info
        [order.discount set:5 discountTaxIncluded: 7.5 promotionalCode: @"SUMMER"];
        
        Screen *myScreen = [self.tracker.screens add:@"Order info before payment"];
        [myScreen sendView];
    }
    
    @end
  4. Tagging an order with the addition of custom variables

    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
        let tracker: Tracker = ATInternet.sharedInstance.defaultTracker
        
        override func viewDidLoad() {
            super.viewDidLoad()
        }
        
        override func viewWillAppear(_ animated: Bool) {        
            let order = tracker.orders.add("cmd1", turnover: 94.30, status: 1)
            // First order from that custom
            order.isNewCustomer = true
            // Payment Method
            order.paymentMethod = 1
            // Order Status
            order.status = 1
            // Order amount
            order.amount.set(80, amountTaxIncluded: 94.30, taxAmount: 14)
            // Order delivery info
            order.delivery.set(5, shippingFeesTaxIncluded: 7.5, deliveryMethod: "1[UPS]")
            // Discount info
            order.discount.set(5, discountTaxIncluded: 7.5, promotionalCode: "SUMMER")
            // Custom variables
            order.customVariables.add(1, value: "fr")
            order.customVariables.add(2, value: "fr_FR")
            
            let myScreen = tracker.screens.add("Order info before payment")
            myScreen.sendView()
        }
    }
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    @property (nonatomic, strong) Tracker* tracker;
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        
        self.tracker = [ATInternet sharedInstance].defaultTracker;
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
    
        Order* order = [self.tracker.orders add:@"cmd1" turnover: 94.30 status: 1];
        // First order from that custom
        order.isNewCustomer = YES;
        // Payment Method
        order.paymentMethod = 1;
        // Order Status
        order.status = 1;
        // Order amount
        [order.amount set:80 amountTaxIncluded: 94.30 taxAmount: 14];
        // Order delivery info
        [order.delivery set:5 shippingFeesTaxIncluded: 7.5 deliveryMethod: @"1[UPS]"];
        // Discount info
        [order.discount set:5 discountTaxIncluded: 7.5 promotionalCode: @"SUMMER"];
        // Custom variables
        [order.customVariables add:1 value:@"fr"];
        [order.customVariables add:2 value:@"fr_FR"];
        
        Screen *myScreen = [self.tracker.screens add:@"Order info before payment"];
        [myScreen sendView];
    }
    
    @end
 

Order class

 

Properties

NameTypeDefault valueDescription
orderIdStringEmpty stringGets or sets the order ID
turnoverDouble0.0Gets or sets the order revenue/turnover
statusInt0Gets or sets the order status
discountOrderDiscountnilGets or sets discount information
amountOrderAmountnilGets or sets total amount information
deliveryOrderDeliverynilGets or sets delivery information
customVariablesOrderCustomVarsnilGets or sets custom variables
isNewCustomerBool?falseGets or sets if the user is a new customer or not
paymentMethodInt?-1Gets or sets the payment method
isConfirmationRequiredBoolfalseGets or sets whether the order is awaiting confirmation from an external site (bank, PayPal…)
 

OrderAmount class

 

Properties

NameTypeDefault valueDescription
amountTaxFreeDouble?-1Gets or sets the order total (without tax)
amountTaxIncludedDouble?-1Gets or sets the order total (with tax)
taxAmountDouble?-1Gets or sets the tax amount
 

Methods

NameReturn typeDescription
setOrderIncludes information about the order total
 

OrderDiscount class

 

Properties

NameTypeDefault valueDescription
discountTaxFreeDouble?-1Gets or sets the discount total (without tax)
discountTaxIncludedDouble?-1Gets or sets the discount total (with tax)
promotionalCodeString?nilGets or sets the promotional code used by the user
 

Methods

NameReturn typeDescription
setOrderIncludes information about the discount total
 

OrderDelivery class

 

Properties

NameTypeDefault valueDescription

shippingFeesTaxFree

Double?-1Gets or sets the shipping total (without tax)

shippingFeesTaxIncluded

Double?-1Gets or sets the shipping total (with tax)

deliveryMethod

String?nilGets or sets the shipping mode
 

Methods

NameReturn typeDescription
setOrderIncludes shipping information
 

OrderCustomVar class

 

Properties

NameTypeDefault valueDescription

varId

Int0Gets or sets the variable ID

value

StringEmpty stringGets or sets the variable value
 

Appendix

 

Identifiers for payment methods and order statuses

Below label/identifier correspondences for payment methods.
It is possible to enrich this list with your own payment methods in configuration part of your interface.

IdentifierLabelCategory
1Credit cardBank cards
2VisaBank cards
3MasterCardBank cards
4ChequeCheque
5Store credit cardsCredit cards
6FinancingCredit cards
7Wire transferBank transfer
8Direct debitDirect debit
9PayPalElectronic money

Below label/identifier correspondences for order statuses.

IdentifierLabel
0No information
1Pending
2Cancelled
3Approved
4Returned
 

Was this post helpful?

Last update: 21/11/2017