Page tracking records screen views in your iOS app. The SDK offers three entry points so you can pick the level of detail that fits your use case — see Methods below.
Before you start, complete the Quickstart so the SDK is initialized.
Methods
Method | Use for |
|---|---|
| Quick page tracking by page name only — no extra parameters. |
| Object-oriented tracking with attached page, session, user, e-commerce, or campaign parameters. |
| Track a page from inside a view controller. The SDK reads the page name from the controller's class name when the event is omitted. |
Build a page event
Use MIPageViewEvent to assemble a page request. Attach MIPageParameters for page-level data. You can additionally attach any of these optional parameter objects:
MISessionParameters— see SessionsMIUserCategories— see UsersMIEcommerceParameters+MIProduct— see Products and OrdersMICampaignParameters— see Campaigns
MIPageParameters
Property | Description |
|---|---|
| Internal search term entered on the page. |
| Dictionary of numbered page parameters ( |
| Dictionary of numbered page categories (groups). |
Examples
Track a page by name
The simplest form — pass a page name string. Useful for quick instrumentation when you don't yet need parameters.
MappIntelligence.shared()?.trackPage(with: "Home")[[MappIntelligence shared] trackPageWith:@"Home"];Track a page with detailed parameters
Build an MIPageViewEvent and attach the parameter objects you need. This example combines page parameters with session parameters.
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let pageEvent = MIPageViewEvent(name: "Product Detail")
pageEvent.pageParameters = MIPageParameters(dictionary: [
1: "category-shoes",
2: "running"
])
pageEvent.sessionParameters = MISessionParameters(dictionary: [
1: "loggedIn"
])
MappIntelligence.shared()?.trackPage(pageEvent)
}- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
MIPageViewEvent *pageEvent = [[MIPageViewEvent alloc] initWithName:@"Product Detail"];
pageEvent.pageParameters = [[MIPageParameters alloc] initWithDictionary:@{
@1: @"category-shoes",
@2: @"running"
}];
pageEvent.sessionParameters = [[MISessionParameters alloc] initWithDictionary:@{
@1: @"loggedIn"
}];
[[MappIntelligence shared] trackPage:pageEvent];
}Track a page from a view controller
Pass self and let the SDK derive the page name from the view controller's class name. Pass nil as the second argument when you don't need to attach any parameters.
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
MappIntelligence.shared()?.trackPage(with: self, pageViewEvent: nil)
}- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[[MappIntelligence shared] trackPageWithViewController:self pageViewEvent:nil];
}For SwiftUI views, trigger page tracking from
.onAppearusingtrackPage(with:)ortrackPage(_:).