Developers » AS2 tagging » Apple » Ecommerce » SalesTracker » Orders
Orders
- iOS
- watchOS
- tvOS
Foreword
AT Internets 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
- Tagging an order and a main goal screen
Without the SalesTracker optionEven 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
- 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
- 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 users 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
- 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
Name | Type | Default value | Description |
---|---|---|---|
orderId | String | Empty string | Gets or sets the order ID |
turnover | Double | 0.0 | Gets or sets the order revenue/turnover |
status | Int | 0 | Gets or sets the order status |
discount | OrderDiscount | nil | Gets or sets discount information |
amount | OrderAmount | nil | Gets or sets total amount information |
delivery | OrderDelivery | nil | Gets or sets delivery information |
customVariables | OrderCustomVars | nil | Gets or sets custom variables |
isNewCustomer | Bool? | false | Gets or sets if the user is a new customer or not |
paymentMethod | Int? | -1 | Gets or sets the payment method |
isConfirmationRequired | Bool | false | Gets or sets whether the order is awaiting confirmation from an external site (bank, PayPal ) |
OrderAmount class
Properties
Name | Type | Default value | Description |
---|---|---|---|
amountTaxFree | Double? | -1 | Gets or sets the order total (without tax) |
amountTaxIncluded | Double? | -1 | Gets or sets the order total (with tax) |
taxAmount | Double? | -1 | Gets or sets the tax amount |
Methods
Name | Return type | Description |
---|---|---|
set | Order | Includes information about the order total |
OrderDiscount class
Properties
Name | Type | Default value | Description |
---|---|---|---|
discountTaxFree | Double? | -1 | Gets or sets the discount total (without tax) |
discountTaxIncluded | Double? | -1 | Gets or sets the discount total (with tax) |
promotionalCode | String? | nil | Gets or sets the promotional code used by the user |
Methods
Name | Return type | Description |
---|---|---|
set | Order | Includes information about the discount total |
OrderDelivery class
Properties
Name | Type | Default value | Description |
---|---|---|---|
shippingFeesTaxFree | Double? | -1 | Gets or sets the shipping total (without tax) |
shippingFeesTaxIncluded | Double? | -1 | Gets or sets the shipping total (with tax) |
deliveryMethod | String? | nil | Gets or sets the shipping mode |
Methods
Name | Return type | Description |
---|---|---|
set | Order | Includes shipping information |
OrderCustomVar class
Properties
Name | Type | Default value | Description |
---|---|---|---|
varId | Int | 0 | Gets or sets the variable ID |
value | String | Empty string | Gets 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.
Identifier | Label | Category |
---|---|---|
1 | Credit card | Bank cards |
2 | Visa | Bank cards |
3 | MasterCard | Bank cards |
4 | Cheque | Cheque |
5 | Store credit cards | Credit cards |
6 | Financing | Credit cards |
7 | Wire transfer | Bank transfer |
8 | Direct debit | Direct debit |
9 | PayPal | Electronic money |
Below label/identifier correspondences for order statuses.
Identifier | Label |
---|---|
0 | No information |
1 | Pending |
2 | Cancelled |
3 | Approved |
4 | Returned |