Campaign Tracking via Deep Links

Prev Next

You can attribute an app open to a marketing campaign by passing the deep link the user followed (Universal Link or custom URL scheme) to the SDK. The SDK reads campaign parameters from the URL query and attaches them to the next page request.

Method

Method

Description

trackUrl(_ url: URL?, withMediaCode mediaCode: String?)

Parses campaign parameters from a URL and stores them. They are attached to the next page event that does not already carry campaign parameters. If mediaCode is nil, wt_mc is used as the default key.

@available(iOS 13.0, *)
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
    if userActivity.activityType == NSUserActivityTypeBrowsingWeb {
        MappIntelligence.shared()?.trackUrl(userActivity.webpageURL, withMediaCode: nil)
    }
}
- (void)scene:(UIScene *)scene continueUserActivity:(NSUserActivity *)userActivity {
    if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
        [[MappIntelligence shared] trackUrl:userActivity.webpageURL withMediaCode:nil];
    }
}

Example: handle a custom URL scheme

func application(
    _ app: UIApplication,
    open url: URL,
    options: [UIApplication.OpenURLOptionsKey: Any] = [:]
) -> Bool {
    MappIntelligence.shared()?.trackUrl(url, withMediaCode: nil)
    return true
}
- (BOOL)application:(UIApplication *)app
            openURL:(NSURL *)url
            options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {
    [[MappIntelligence shared] trackUrl:url withMediaCode:nil];
    return YES;
}

The campaign parameters parsed from the URL are stored and attached to the next page request that does not already carry its own campaign parameters.

Related: Campaigns, Pages.