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:).
Before you start, complete the Quickstart so the SDK is initialized.
For deep-link-driven campaigns (Universal Links, custom URL schemes), see Campaign Tracking via Deep Links.
MICampaignParameters
Property | Description | Data type |
|---|---|---|
| Identifier of the campaign (matches the campaign tracking value in your account). | String |
| Defines how the campaign contact is counted ( | Enum |
| Custom media code; defaults to | String |
| If | Boolean |
| Numbered custom campaign parameters. | Dictionary |
The action property accepts two values:
Value (Swift) | Value (Objective-C) | Description |
|---|---|---|
|
| The user reached your app by clicking the campaign, for example a link in a newsletter or ad. This is the standard case for campaign tracking. |
|
| The campaign was displayed to the user without a click (an impression). Set this value only when you want to measure how often a campaign was shown. |
If you do not set action, the campaign is tracked as a click.
Method (URL based)
Method | Description |
|---|---|
| Parses campaign parameters from a URL and tracks them. If |
Examples
Attach a campaign to a page event
Build an MICampaignParameters with the campaign ID and attach it to the page event for the landing screen.
let campaign = MICampaignParameters(with: "spring-sale-2026")
campaign.mediaCode = "wt_mc"
campaign.oncePerSession = true
campaign.action = .click
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;
campaign.action = click;
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;
}