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

  1. 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
  2. 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
  3. 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
  4. Removal of a product

    @IBAction func removeProduct(sender: UIButton) {
        tracker.products.remove("1254[MF839FA]")
    }
    - (IBAction) removeProduct:(UIButton *)sender {
        [self.tracker.products removeWithId:@"1254[MF839FA]"];
    }
  5. Removal of all products

    @IBAction func removeProducts(sender: UIButton) {
        tracker.products.removeAll()
    }
    - (IBAction) removeProducts:(UIButton *)sender {
        [self.tracker.products removeAll];
    }
 

Product class

 

Properties

NameTypeDefault valueDescription
productIdStringEmpty stringGets or sets the product ID
category1String?nilGets or sets the product’s 1st category
category2String?nilGets or sets the product’s 2nd category
category3String?nilGets or sets the product’s 3rd category
category4String?nilGets or sets the product’s 4th category
category5String?nilGets or sets the product’s 5th category
category6String?nilGets or sets the product’s 6th category
quantityInt?nilGets or sets the product quantity
unitPriceTaxIncludedDouble?nilGets or sets the unit price, including tax
unitPriceTaxFreeDouble?nilGets or sets the unit price, excluding tax
discountTaxIncludedDouble?nilGets or sets the total discount, including tax
discountTaxFreeDouble?nilGets or sets the total discount, excluding tax
promotionalCodeString?nilGets or sets the product’s promotional code
 

Was this post helpful?

Last update: 11/06/2018