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

  1. To track screen views in a SwiftUI application, add a tracking call to the view’s onAppear modifier.
  2. The onAppear modifier runs each time the view becomes visible.
  3. In this example, Matomo records a screen view named Home each time the Home screen appears.
    add tracking to ios home screen

  4. 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

  1. Build and run the app.
  2. On a device or simulator, open your app and navigate to the screens you are tracking.
  3. In Matomo, open the Visitors > Real-time report or Visits Log.
  4. Verify that the screen views you tracked appear within the visit details.
    screenviews in ios app

  5. 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 onAppear block to verify that the tracking call runs when the screen is displayed.
  • Verify tracking is not disabled: If you use the isOptedOut property 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.

Previous FAQ: Set up tracking with the Matomo SDK for iOS