Tracking deeplinks on iOS

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

You need to track app openings to correctly track remarketing campaigns.

Note

To work with Universal Links, configure them for your application.

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;
}

You need to track app openings to correctly track remarketing campaigns.

Note

To work with Universal Links, configure them for your application.

To track app openings via deeplinks or universal links, use the handleOpen(_:) method of the YMMYandexMetrica class.

To track app opens using a deeplink, make the following changes in UIApplicationDelegate:

func application(_ application: UIApplication, handleOpenURL url: URL) -> Bool {
    return YMMYandexMetrica.handleOpen(url)
}

func application(_ application: UIApplication, openURL url: URL, sourceApplication: String?, annotation: AnyObject) -> Bool {
    return YMMYandexMetrica.handleOpen(url)
}

// Delegate for tracking universal links.
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
    if userActivity.activityType == NSUserActivityTypeBrowsingWeb {
        if let url = userActivity.webpageURL {
            YMMYandexMetrica.handleOpen(url)
        }
    }
    return true
}

If you didn't find the answer you were looking for, you can use the feedback form to submit your question. Please describe the problem in as much detail as possible. Attach a screenshot if possible.

Contact support