Because users can launch Apple Watch apps independently of the “main” iOS app (running on the iOS device to which the Apple Watch is paired), it is necessary to integrate MobileAppTracker (MAT) in both AppDelegate and WKInterfaceController.
The watch app sessions and events are measured as part of the parent iOS app, so the same param values for — advertiser id, conversion key and package name — are to be used for the watch app MAT integration.
To configure session and event measurement with your Apple Watch app extension, first initialize MobileAppTracker in AppDelegate
applicationDidFinishLaunching: and WKInterfaceController
awakeWithContext:, as shown in the following code sample.
// sample code to initialize MobileAppTracker [MobileAppTracker initializeWithMATAdvertiserId:MAT_ADVERTISER_ID MATConversionKey:MAT_CONVERSION_KEY]; // [MobileAppTracker setDebugMode:YES]; [MobileAppTracker setDelegate:self];
The last call to MobileAppTracker “setDelegate” method is the one to receive the delegate responses moving forward. For more info please refer Reading Server Responses.
Each time a user launches an Apple Watch app, call “measureSession” in AppDelegate
willActivate, as shown in the following code sample.
// measure app session [MobileAppTracker measureSession];
To measure a specific event of interest, you can optionally call “measureEvent” as shown in the following code sample. Notice the inclusion of event.attribute5 = @”watch” to indicate this event is watch-specific.
// measure event, e.g. "purchase", "levelChanged" MATEvent *event = [MATEvent eventWithName:@"anEventOnWatch"]; event.attribute5 = @"watch"; [MobileAppTracker measureEvent:event];