Campaigns

Prev Next

Campaign tracking attributes a tracking request to a marketing campaign — for example, an ad, a newsletter, or a deep link that brought the user into your app. The iOS SDK lets you attach campaign data either directly via MICampaignParameters on a page or action event, or by passing a campaign URL to trackUrl(_:withMediaCode:).

For deep‑link‑driven campaigns (Universal Links, custom URL schemes), see Campaign Tracking via Deep Links.

MICampaignParameters

Property

Description

campaignId

Identifier of the campaign (matches the campaign tracking value in your account).

action

MICampaignAction enum value (for example a click vs. a view).

mediaCode

Custom media code; defaults to wt_mc when not provided.

oncePerSession

If true, the campaign is counted only once per session.

customParameters

Dictionary of numbered custom campaign parameters.

Method (URL based)

Method

Description

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

Parses campaign parameters from a URL and tracks them. If mediaCode is nil, wt_mc is used as the default key.

Examples

Attach a campaign to a page event

let campaign = MICampaignParameters(with: "spring-sale-2026")
campaign.mediaCode = "wt_mc"
campaign.oncePerSession = true

let pageEvent = MIPageViewEvent(name: "Landing")
pageEvent.campaignParameters = campaign

MappIntelligence.shared()?.trackPage(pageEvent)
MICampaignParameters *campaign = [[MICampaignParameters alloc] initWith:@"spring-sale-2026"];
campaign.mediaCode = @"wt_mc";
campaign.oncePerSession = YES;

MIPageViewEvent *pageEvent = [[MIPageViewEvent alloc] initWithName:@"Landing"];
pageEvent.campaignParameters = campaign;

[[MappIntelligence shared] trackPage:pageEvent];

Track a campaign URL on app launch

If the user opened the app via a Universal Link or custom URL scheme that contains campaign parameters, forward the URL to the SDK:

func application(
    _ application: UIApplication,
    continue userActivity: NSUserActivity,
    restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void
) -> Bool {
    if userActivity.activityType == NSUserActivityTypeBrowsingWeb {
        MappIntelligence.shared()?.trackUrl(userActivity.webpageURL, withMediaCode: nil)
    }
    return true
}
- (BOOL)application:(UIApplication *)application
    continueUserActivity:(NSUserActivity *)userActivity
    restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> *))restorationHandler {
    if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
        [[MappIntelligence shared] trackUrl:userActivity.webpageURL withMediaCode:nil];
    }
    return YES;
}

Related: Campaign Tracking via Deep Links, Pages, Object Oriented Tracking.