Tracker initialisation

  • iOS
  • watchOS
  • tvOS

Get off to a good start

Once the AT Internet library has been integrated with your project, you should initialise your tracker in order to tag your different views or actions.

The ATInternet class allows you to initialise one or several trackers, name them, and memorise them.



To make the most of all features offered by AT Internet’s tracker, it is strongly recommended you initialise the trackers in your application’s AppDelegate class.


Using a unique tracker in a multithreaded application

Be careful, the same instance of Tracker must not be shared in a concurrent programming,
otherwise the application will crash. The SDK code is not thread-safe, so it is necessary to use a different instance of Tracker per thread.


Using a unique tracker for your application

If your application does not require the use of several trackers, the ATInternet class exposes a defaultTracker property that allows you to easily manage a tracker.

To initialise this tracker, add the following code to the app delegate AppDelegate:

[[ATInternet sharedInstance] defaultTracker];

Access to the defaultTracker property allows you to instantiate a tracker named defaultTracker and memorise its instance. When you call this property in the future, you will recover the same instance.


Using several trackers

If you need to manage several trackers, the ATInternet class enables you to instantiate, name, and memorise these different instances.

To initialise your different trackers, add the following code in the app delegate AppDelegate:

import Tracker
// import Tracker if you downloaded it from Cocoapods

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    return true
import UIKit
import Tracker
// import Tracker if you downloaded if from Cocoapods

class ViewController: UIViewController {
    let tracker: Tracker = ATInternet.sharedInstance.defaultTracker
    let audioTracker: Tracker = ATInternet.sharedInstance.tracker("audioTracker")
    let cartTracker: Tracker = ATInternet.sharedInstance.tracker("cartTracker")
    override func viewDidLoad() {
#import "AppDelegate.h"
#import "Tracker-Swift.h" // with Cocoapods
#import "Tracker/Tracker-Swift.h" // with TagComposer

@interface AppDelegate ()


@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [[ATInternet sharedInstance] defaultTracker];
    [[ATInternet sharedInstance] tracker:@"audioTracker"];
    [[ATInternet sharedInstance] tracker:@"videoTracker"];
    return YES;
#import "ViewController.h"
#import "Tracker-Swift.h" // with Cocoapods
#import "Tracker/Tracker-Swift.h" // with TagComposer

@interface ViewController ()


@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    Tracker *defaultTracker = [[ATInternet sharedInstance] defaultTracker];
    Tracker *audioTracker = [[ATInternet sharedInstance] tracker:@"audioTracker"];
    Tracker *videoTracker = [[ATInternet sharedInstance] tracker:@"videoTracker"];

In the above example, three tracker instances are created:

  1. defaultTracker: instance by default
  2. audioTracker: a tracker used to tag your audio streams
  3. cartTracker: a tracker used to tag your product cart

When calling these properties/methods (e.g. in a ViewController), you will recover these previously created instances.

Last update: 26/02/2019