Developers » AS2 tagging » Apple » Ecommerce » SalesTracker » Products 2.1.0
Products
- iOS
- watchOS
- tvOS
Foreword
AT Internet’s SDK enables you to tag products for sale that are viewed by your users during usage of your application.
The measurement of viewed products needs an option to be activated. Please contact the support centre for more information.
Get off to a good start
Once your tag has been initialised, you can send information of viewed products.
In cases of a Swift project, please import the Tracker module (or TrackerExtension if your target is an extension) in your ViewController. In case of an Objective-C project, please import the headers ATInternet.h, ATTracker.h, ATProduct.h
Tagging
The tracker makes a products property available. This property exposes the following methods :
- add (or addString in Objective-C) : Add a viewed product to the list and returns a Product object.
- remove : Removes a viewed product in the list.
- removeAll : Removes all viewed products.
- sendViews : Send all viewed products.
Tagging examples
- Tagging a viewed product
import UIKit import Tracker class ViewController: UIViewController { let tracker: Tracker = ATInternet.sharedInstance.defaultTracker override func viewDidLoad() { super.viewDidLoad() } override func viewWillAppear(animated: Bool) { tracker.products.add("1253[MF885FA]", category1: "1[Desktop]", category2: "10[iMac]").sendView() } }
#import "ViewController.h" #import "ATInternet.h" #import "ATTracker.h" #import "ATProduct.h" @interface ViewController () @property (nonatomic, strong) ATTracker* tracker; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; self.tracker = [ATInternet sharedInstance].defaultTracker; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [[self.tracker.products add:@"1253[MF885FA]" category1:@"1[Desktop]" category2: @"10[iMac]"] sendView]; } @end
- Tagging several viewed products
import UIKit import Tracker class ViewController: UIViewController { let tracker: Tracker = ATInternet.sharedInstance.defaultTracker override func viewDidLoad() { super.viewDidLoad() } override func viewWillAppear(animated: Bool) { tracker.products.add("1254[MF839FA]", category1: "2[Laptop]", category2: "20[Macbook Pro]") tracker.products.add("1253[MF885FA]", category1: "1[Desktop]", category2: "10[iMac]") tracker.products.sendViews() } }
#import "ViewController.h" #import "ATInternet.h" #import "ATTracker.h" #import "ATProduct.h" @interface ViewController () @property (nonatomic, strong) ATTracker* tracker; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; self.tracker = [ATInternet sharedInstance].defaultTracker; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self.tracker.products add:@"1254[MF839FA]" category1: @"2[Laptop]" category2: @"20[Macbook Pro]"]; [self.tracker.products add:@"1253[MF885FA]" category1: @"1[Desktop]" category2: @"10[iMac]"]; [self.tracker.products sendViews]; } @end
- Tagging viewed products with an add to cart
import UIKit import Tracker class ViewController: UIViewController { let tracker: Tracker = ATInternet.sharedInstance.defaultTracker var products: [Product] = [] override func viewDidLoad() { super.viewDidLoad() // Enable cart and set an ID tracker.cart.set("1") // Declare first product let p1 = tracker.products.add("1254[MF839FA]", category1: "2[Laptop]", category2: "20[Macbook Pro]") p1.quantity = 1 p1.unitPriceTaxFree = 1839 p1.unitPriceTaxIncluded = 2299 products.append(p1) // Declare second product let p2 = tracker.products.add("1253[MF885FA]", category1: "1[Desktop]", category2: "10[iMac]") p2.quantity = 1 p2.unitPriceTaxFree = 1199 p2.unitPriceTaxIncluded = 1499 products.append(p2) } override func viewWillAppear(animated: Bool) { // Send products views tracker.products.sendViews() // Send screen hit tracker.screens.add("Store").sendView() } @IBAction func addProductToCart(sender: UIButton) { // Add a previously declared product to the cart tracker.cart.products.add(products[0]) } override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { // Go to cart resume and send a screen hit with cart content let cartScreen = tracker.screens.add("Cart resume") // If isBasketScreen is not set to true, Cart info won't be added to Screen hit cartScreen.isBasketScreen = true cartScreen.sendView() } }
#import "ViewController.h" #import "ATInternet.h" #import "ATTracker.h" #import "ATScreen.h" #import "ATCart.h" #import "ATProduct.h" @interface ViewController () @property (nonatomic, strong) ATTracker* tracker; @property (nonatomic, strong) NSMutableArray* products; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; self.tracker = [ATInternet sharedInstance].defaultTracker; self.products = [[NSMutableArray alloc] init]; [self.tracker.cart setWithId:@"1"]; ATProduct *p1 = [self.tracker.products add:@"1254[MF839FA]" category1: @"2[Laptop]" category2: @"20[Macbook Pro]"]; p1.quantity = 1; p1.unitPriceTaxFree = 1839; p1.unitPriceTaxIncluded = 2299; [self.products addObject:p1]; ATProduct *p2 = [self.tracker.products add:@"1253[MF885FA]" category1: @"1[Desktop]" category2: @"10[iMac]"]; p2.quantity = 1; p2.unitPriceTaxFree = 1149; p2.unitPriceTaxIncluded = 1499; [self.products addObject:p2]; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; // Send products views [self.tracker.products sendViews]; [[self.tracker.screens addWithName:@"Store"] sendView]; } - (IBAction) addProductToCart:(UIButton *)sender { // Add a previously declared product to the cart [self.tracker.cart.products add:self.products[0]]; } - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Go to cart resume and send a screen hit with cart content ATScreen* cartScreen = [self.tracker.screens addWithName:@"Cart resume"]; // If isBasketScreen is not set to true, Cart info won't be added to Screen hit cartScreen.isBasketScreen = YES; [cartScreen sendView]; } @end
- Removal of a product
@IBAction func removeProduct(sender: UIButton) { tracker.products.remove("1254[MF839FA]") }
- (IBAction) removeProduct:(UIButton *)sender { [self.tracker.products removeWithId:@"1254[MF839FA]"]; }
- Removal of all products
@IBAction func removeProducts(sender: UIButton) { tracker.products.removeAll() }
- (IBAction) removeProducts:(UIButton *)sender { [self.tracker.products removeAll]; }
Product class
Properties
Name | Type | Default value | Description |
---|---|---|---|
productId | String | Empty string | Gets or sets the product ID |
category1 | String? | nil | Gets or sets the products 1st category |
category2 | String? | nil | Gets or sets the products 2nd category |
category3 | String? | nil | Gets or sets the products 3rd category |
category4 | String? | nil | Gets or sets the products 4th category |
category5 | String? | nil | Gets or sets the products 5th category |
category6 | String? | nil | Gets or sets the products 6th category |
quantity | Int? | nil | Gets or sets the product quantity |
unitPriceTaxIncluded | Double? | nil | Gets or sets the unit price, including tax |
unitPriceTaxFree | Double? | nil | Gets or sets the unit price, excluding tax |
discountTaxIncluded | Double? | nil | Gets or sets the total discount, including tax |
discountTaxFree | Double? | nil | Gets or sets the total discount, excluding tax |
promotionalCode | String? | nil | Gets or sets the products promotional code |