Identified visitors

  • iOS
  • watchOS
  • tvOS
 

Foreword

Identified visitors are the visitors you’re able to recognise following authentication (sign up, subscription, sign in…). These visitors can be regrouped into categories to give you a greater overall view during your analyses.

A visitor can be identified with a numerical or textual ID.

If different values are recorded in the same visit, only the first one will be taken into account

 

Get off to a good start

Once your tag is initialised, you can add visitor identification information.

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 SmartTracker-Swift.h

 

Tagging

The tracker possesses an identifiedVisitor property. This property offers a group of methods for enabling or disabling visitor identification. This type of tagging is persistent by default, meaning that even if the application is exited, the visitor identification data will be present in the hits, once the application is reopened. In “non persistent” mode, data will be automatically erased once the application is exited. It is also possible to manually delete identification data.

 

Tagging examples

  1. Tagging a screen with a numerical visitor ID

    let tracker = ATInternet.sharedInstance.defaultTracker
    
    override func viewWillAppear(animated: Bool) {
        _ = tracker.identifiedVisitor.set(123456)
        tracker.screens.add("MyAccount").sendView()
    }
    @interface ViewController ()
    @property (nonatomic, strong) Tracker* tracker;
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        
        self.tracker = [ATInternet sharedInstance].defaultTracker;
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
        
        [self.tracker.identifiedVisitor setInt:123456];
        [[self.tracker.screens addWithName:@"MyAccount"] sendView];
    }
    
    @end
  2. Tagging a screen with a numerical ID and a category

    let tracker = ATInternet.sharedInstance.defaultTracker
    
    override func viewWillAppear(animated: Bool) {
        _ = tracker.identifiedVisitor.set(123456, visitorCategory: 101)
        tracker.screens.add("MyAccount").sendView()
    }
    @interface ViewController ()
    @property (nonatomic, strong) Tracker* tracker;
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        
        self.tracker = [ATInternet sharedInstance].defaultTracker;
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
        
        [self.tracker.identifiedVisitor set:123456 :101];
        [[self.tracker.screens addWithName:@"MyAccount"] sendView];
    }
    
    @end
  3. Tagging a screen with the addition of a textual visitor ID

    let tracker = ATInternet.sharedInstance.defaultTracker
    
    override func viewDidAppear(animated: Bool) {
        let _ = tracker.identifiedVisitor.set("user12345")
        tracker.screens.add("MyScreen").sendView()
    }
    @interface ViewController ()
    @property (nonatomic, strong) Tracker* tracker;
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        
        self.tracker = [ATInternet sharedInstance].defaultTracker;
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
        
        [self.tracker.identifiedVisitor setString:@"user12345"];
        [[self.tracker.screens addWithName:@"MyScreen"] sendView];
    }
    
    @end
  4. Tagging a screen with the addition of a textual ID and a category

    let tracker = ATInternet.sharedInstance.defaultTracker
    
    override func viewDidAppear(animated: Bool) {
        _ = tracker.identifiedVisitor.set("user12345", visitorCategory: 101)
        tracker.screens.add("MyScreen").sendView()
    }
    @interface ViewController ()
    @property (nonatomic, strong) Tracker* tracker;
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        
        self.tracker = [ATInternet sharedInstance].defaultTracker;
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
        
        [self.tracker.identifiedVisitor setString:@"user12345" :101];
        [[self.tracker.screens addWithName:@"MyScreen"] sendView];
    }
    
    @end
  5. To disable visitor identification (e.g. when a user logs off)

    @IBAction func logOut(sender: UIButton) {
        ATInternet.sharedInstance.defaultTracker.identifiedVisitor.unset()
    }
    - (IBAction)logOut:(UIButton *)sender {
        [[ATInternet sharedInstance].defaultTracker.identifiedVisitor unset];
    }
  6. Disabling persistent mode

    let tracker = ATInternet.sharedInstance.defaultTracker
    override func viewDidLoad() {
        tracker.setConfig("persistIdentifiedVisitor", value: "false") { (isSet) -> Void in
            print("Visitor id won't be persisted anymore")
        }
    }
    @interface ViewController ()
    @property (nonatomic, strong) Tracker* tracker;
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        
        self.tracker = [ATInternet sharedInstance].defaultTracker;
        [self.tracker setConfig:@"persistIdentifiedVisitor" value:@"false" completionHandler:^(BOOL isSet) {
            NSLog(@"%@", @"Visitor id won't be persisted anymore");
        }];
    }
    
    @end
 

Was this post helpful?

Last update: 27/02/2019