Track screen views with the Matomo SDK for iOS
Screen views record when users view a screen or section of your app (similar to pageviews on websites). Tracking screen views can uncover which areas of the app users visit, how they move between screens, and which parts of the user journey receive the most engagement.
This guide explains how to track screen views in an iOS app using the Matomo SDK for iOS. The examples use a demo project built with SwiftUI.
Before you start
Ensure tracking is already set up and working in your app. Follow the guide: setup tracking with the Matomo SDK for iOS.
Track screen views
- To track screen views in a SwiftUI application, add a tracking call to the view’s
onAppearmodifier. - The
onAppearmodifier runs each time the view becomes visible. -
In this example, Matomo records a screen view named
Homeeach time the Home screen appears.
-
Add the tracking snippet to each screen that you want to track, replacing
"Home"with the relevant screen name:
.onAppear {
MatomoTracker.shared.track(view: ["Home"])
}
The SDK also supports hierarchical screen names, which can help organise screen views in Matomo reports. For example:
MatomoTracker.shared.track(view: ["Home"])
MatomoTracker.shared.track(view: ["Contact"])
MatomoTracker.shared.track(view: ["Settings"])
MatomoTracker.shared.track(view: ["Settings", "Notifications"])
Test the screen view tracking setup
- Build and run the app.
- On a device or simulator, open your app and navigate to the screens you are tracking.
- In Matomo, open the Visitors > Real-time report or Visits Log.
-
Verify that the screen views you tracked appear within the visit details.
-
You can also view tracked screen views in Behaviour > Pages after the data has been processed.
Note: The SDK queues tracking requests and sends them in batches, so tracking data may not appear immediately in Matomo.
Troubleshooting
If screen views do not appear in Matomo, check the following:
- Allow time for queued requests: The SDK queues tracking requests and sends them in batches, so data may not appear immediately in Matomo.
- Confirm the tracking code executes: Add a breakpoint or debug message inside the
onAppearblock to verify that the tracking call runs when the screen is displayed. - Verify tracking is not disabled: If you use the
isOptedOutproperty elsewhere in your application, confirm that tracking has not been disabled before the screen view is sent. - Inspect the Xcode console: Build and run the application in Xcode and check the console for SDK warnings, configuration errors, or network-related messages.
Next steps
After confirming that screen views are recorded correctly, you can extend tracking to events, goals, User IDs, and custom dimensions with the Matomo SDK for iOS.
For advanced SDK options, see the Matomo SDK for iOS page on GitHub.