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.
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; }
Copied to clipboard
Tracking app opening is necessary for correct tracking of the 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 openings 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, continueUserActivity userActivity: NSUserActivity, restorationHandler: ([AnyObject]?) -> Void) -> Bool { if userActivity.activityType == NSUserActivityTypeBrowsingWeb { if let url = userActivity.webpageURL { YMMYandexMetrica.handleOpen(url) } } return true }
Copied to clipboard