Documentation Index

Fetch the complete documentation index at: https://docs.mapp.com/llms.txt

Use this file to discover all available pages before exploring further.

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:).

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

campaignId

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

String

action

Defines how the campaign contact is counted (MICampaignAction). See the values below.

Enum

mediaCode

Custom media code; defaults to wt_mc when not provided.

String

oncePerSession

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

Boolean

customParameters

Numbered custom campaign parameters.

Dictionary

The action property accepts two values:

Value (Swift)

Value (Objective-C)

Description

.click

click

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.

.view

view

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

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

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