Screens

  • iOS
  • watchOS
  • tvOS
 

Get off to a good start

Once your tag is initialised, you can start tagging your screens.

In the case of a Swift project, be sure to import the Tracker (or TrackerExtension if your target is an extension) module in your ViewController. In the case of an Objective-C project, be sure to import the headers Tracker-Swift.h or SmartTracker-Swift.h

Declare a Tracker (or AutoTracker)  variable in your ViewController

import UIKit
import Tracker

class ViewController: UIViewController {
    let tracker: Tracker = ATInternet.sharedInstance.defaultTracker
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}
#import "Tracker/Tracker-Swift.h"

@interface ViewController ()
@property (nonatomic, strong) Tracker *tracker;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.tracker = [ATInternet sharedInstance].defaultTracker;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

 

Tagging

To tag a screen, the tracker exposes a screens property.

Two solutions are available to tag a screen:

  • Define one or several tagging and send the hit(s) at the desired moment
  • Send screen tagging directly

To do this, the screens property of the Tracker class offers an add method.
This method enables the addition of screen tagging which can be sent at the desired moment (e.g. viewDidLoad, viewWillAppear …).

The add method sends back a Screen-type object. To send the defined information, you must manually call the sendView method of your Screen method, or call the Tracker’s dispatch method.

 

Tagging examples

  1. Tagging a screen:
    override func viewWillAppear(_ animated: Bool) {
        tracker.screens.add("Home").sendView()
    }
    - (void)viewWillAppear:(BOOL)animated {
        [[self.tracker.screens addWithName:@"Home"] sendView];
    }
  2. Tagging a screen with a level 2:
    override func viewWillAppear(_ animated: Bool) {
        let myHomeScreen = tracker.screens.add("Home")
        myHomeScreen.level2 = 1 // Set a level 2 ID for myHomeScreen
        myHomeScreen.sendView()
    }
    - (void)viewWillAppear:(BOOL)animated {
        Screen *myHomeScreen = [tracker.screens add:@"Home"];
        myHomeScreen.level2 = 1; // Set a level 2 ID for myHomeScreen
        [myHomeScreen sendView];
    }
  3. Tagging a screen with chapters:
    override func viewWillAppear(_ animated: Bool) {
        tracker.screens.add("Today News", chapter1: "Home", chapter2: "News").sendView()
    }
    - (void)viewWillAppear:(BOOL)animated {
       [[self.tracker.screens add:@"Today News" chapter1:@"Home" chapter2:@"News"] sendView];
    }
  4. Tagging a screen with the addition of a custom object:
    override func viewWillAppear(_ animated: Bool) {
        let screen = tracker.screens.add()
        screen.customObjects.add(["lng": "fr"])
        screen.sendView()
    }
    - (void)viewWillAppear:(BOOL)animated {
        Screen *screen = [[tracker screens] add];
        [screen.customObjects addDictionary:@{@"lng":@"fr"}];
        [screen sendView];
    }
  5. Tagging a screen with use of dispatcher:
    override func viewWillAppear(_ animated: Bool) {
        let screen = tracker.screens.add()
        screen.customVars.add(1, value: "fr", type: CustomVar.CustomVarType.Screen)
        screen.sendView()
    }
    - (void)viewWillAppear:(BOOL)animated {
        Screen *screen = [[tracker screens] add];
        [screen.customVars add:1 value:@"fr" type:CustomVarTypeScreen];
        [self.tracker dispatch];
    }
  6. Tagging a screen with a name defined via a CustomObject (the name will be treated via DataManager)

    override func viewWillAppear(_ animated: Bool) {
        let screen = tracker.screens.add()
        screen.customObjects.add(["screenName": "Home"])
        screen.sendView()
    }
    - (void)viewWillAppear:(BOOL)animated {
        Screen *screen = [[tracker screens] add];
        [screen.customObjects addDictionary:@{@"screenName": @"Home"}];
        [[self.tracker.screens add] sendView];
    }
  7. Tagging a basket :
    override func viewWillAppear(animated: Bool) {
        let screen = tracker.screens.add("Home")
        screen.cart = tracker.cart.set("myCart")
        screen.sendView()
    }
    - (void)viewWillAppear:(BOOL)animated {
        Screen *screenCart = [self.tracker.screens add:@"cart"];
        screenCart.cart = [self.tracker.cart set:@"mycart"];
        [screenCart sendView];
    }
 

Screen Class

NameTypeDefault valueDescription
nameStringEmpty stringGets or sets the screen name
chapter1String?nilGets or sets the first chapter
chapter2String?nilGets or sets the second chapter
chapter3String?nilGets or sets the third chapter
actionEnumAction.ViewGets or sets the action type
level2Int?nilGets or sets the level 2 ID
isBasketScreenBoolfalseIndicates that the screen displays the content of a cart (in the case where the SalesTracker option is used)
customObjectsCustomObjectsCustomObjectsAllows you to associate information by passing a dictionary
customVarsCustomVars CustomVars Allows you to associate information with a user’s activity while s/he is using your application
aisleAislenilAllows you to tag your product “aisles” or sections.
customTreeStructureCustomTreeStructurenilAllow you to create a custom tree structure for your application.
publishers

PublisherImpressions

PublisherImpressionsAllows you to tag third-party campaigns on your app
selfPromotions

SelfPromotionImpressions

SelfPromotionImpressionsAllows you to tag self-promotional items on your site
locationLocationnilAllows you to add geolocalisation data (latitude, longitude) in a screen hit
campaignCampaignnilAllows you to tag different types of campaigns
internalSearchInternalSearchnilAllows you to tag your application’s internal search engine
orderOrdernilAllows you to tag orders placed by your users while using your application
cartCartnilAllows you to tag your application’s basket or cart, as well as its contents
 

Methods

NameReturnDescription
sendViewvoidSend screen hit
 

Was this post helpful?

Last update: 13/03/2018