Developers » AS2 tagging » Apple » Content » Screens
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
Declare a Tracker 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 Trackers dispatch method.
Tagging examples
- Tagging a screen:
override func viewWillAppear(_ animated: Bool) { tracker.screens.add("Home").sendView() }
- (void)viewWillAppear:(BOOL)animated { [[self.tracker.screens addWithName:@"Home"] sendView]; }
- 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]; }
- 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]; }
- 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]; }
- 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]; }
- 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]; }
- 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
Name | Type | Default value | Description |
---|---|---|---|
name | String | Empty string | Gets or sets the screen name |
chapter1 | String? | nil | Gets or sets the first chapter |
chapter2 | String? | nil | Gets or sets the second chapter |
chapter3 | String? | nil | Gets or sets the third chapter |
action | Enum | Action.View | Gets or sets the action type |
level2 | Int? | nil | Gets or sets the level 2 ID |
isBasketScreen | Bool | false | Indicates that the screen displays the content of a cart (in the case where the SalesTracker option is used) |
customObjects | CustomObjects | CustomObjects | Allows you to associate information by passing a dictionary |
customVars | CustomVars | CustomVars | Allows you to associate information with a users activity while s/he is using your application |
aisle | Aisle | nil | Allows you to tag your product aisles or sections. |
customTreeStructure | CustomTreeStructure | nil | Allow you to create a custom tree structure for your application. |
publishers | PublisherImpressions | PublisherImpressions | Allows you to tag third-party campaigns on your app |
selfPromotions | SelfPromotionImpressions | SelfPromotionImpressions | Allows you to tag self-promotional items on your site |
location | Location | nil | Allows you to add geolocalisation data (latitude, longitude) in a screen hit |
campaign | Campaign | nil | Allows you to tag different types of campaigns |
internalSearch | InternalSearch | nil | Allows you to tag your applications internal search engine |
order | Order | nil | Allows you to tag orders placed by your users while using your application |
cart | Cart | nil | Allows you to tag your applications basket or cart, as well as its contents |
Methods
Name | Return | Description |
---|---|---|
sendView | void | Send screen hit |