Skip to content
This repository was archived by the owner on May 5, 2026. It is now read-only.

Custom screen and application variables b930d5

Benjamin Diolez edited this page May 5, 2026 · 1 revision

Data collection / Apple / Content / Custom screen and application variables

Foreword

Custom application variables allow you to associate information with a user’s activity while s/he is using your application.

Custom screen variables focus on a view in particular, and allow you, notably, to tag the fields of an entry form.

Get off to a good start

Once your tag is initialised, you can add your custom variables to your screen hit.

In the case of a Swift project, be sure to import the SmartTracker (or tvOSTracker/watchOSTracker if your target is an Apple TV or an Apple Watch) module in your ViewController. In the case of an Objective-C project, be sure to import the headers SmartTracker-Swift.h or Tracker-Swift.h in case of Cocoapods integration.

Tagging

The Screen object makes available a CustomVars-type object that exposes an add method. This method accepts three parameters:

  • varId: index of the indicator
  • value: value of the indicator, character string in the format:
    • text: [lorem]
    • decimal: “,” or “.” separator, two characters maximum after the separator
    • date: yyyymmdd
    • country: ISO
    • duration: integer
  • type : type of indicator

Tagging example

  1. Site indicator, with a date value

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("My Screen with Custom Var")
        let _ = screen.customVars.add(1, value: "20141224", type: CustomVar.CustomVarType.app)
        screen.sendView()
    }
}
#import "SmartTracker/SmartTracker-Swift.h"

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

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    Screen *screen = [[[[ATInternet sharedInstance] defaultTracker] screens ] add:@"My Screen With Custom Var"];
    [screen.customVars add:1 value:@"20141224" type:CustomVarTypeApp];
    [screen sendView];
}

@end
  1. Screen indicator, with a text value

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("My Screen With Custom Var")
        let _ = screen.customVars.add(1, value: "[object]", type: CustomVar.CustomVarType.screen)
        screen.sendView()
    }
}
#import "ViewController.h"
#import "SmartTracker/SmartTracker-Swift.h"

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

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    Screen *screen = [[[[ATInternet sharedInstance] defaultTracker] screens ] add:@"My Screen With Custom Var"];
    [screen.customVars add:1 value:@"[objet]" type:CustomVarTypeScreen];
    [screen sendView];
}

@end

Wiki contents

Clone this wiki locally