Tracking deeplinks on iOS

Starting with version 4.0 of the iOS SDK, app openings with a Deeplink are tracked automatically.

Tracking app opening is necessary for correct tracking of the remarketing campaigns.

To manually track app openings using deeplinks or Universal Links, or deeplink processing in a running app, use the +handleOpenURL: method of the YMMYandexMetrica class.

To manually track app openings using deeplinks or deeplink processing in a running app, add the following changes to UIApplicationDelegate:

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
    return [YMMYandexMetrica handleOpenURL:url];
}
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
    return [YMMYandexMetrica handleOpenURL:url];
}

// Delegate for tracking Universal links.
- (BOOL)application:(UIApplication *)application
    continueUserActivity:(NSUserActivity *)userActivity
    restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler
{
    if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
        [YMMYandexMetrica handleOpenURL:userActivity.webpageURL];
    }
    return YES;
}
Copied to clipboard