iOS Web View Tracking

Overview

Real User Monitoring allows you to monitor web views and eliminate blind spots in your hybrid iOS and tvOS applications.

You can perform the following:

  • Track user journeys across web and native components in mobile applications
  • Scope the root cause of latency to web pages or native components in mobile applications
  • Support users that have difficulty loading web pages on mobile devices

Setup

Prerequisites

Set up the web page you want rendered on your mobile iOS and tvOS application with the RUM Browser SDK first. For more information, see RUM Browser Monitoring.

Instrument your web views

The RUM iOS SDK provides APIs for you to control web view tracking. To add Web View Tracking, declare the following as an extension of WKUserContentController.

trackDatadogEvents(in hosts: Set<String>)
Enables RUM event tracking in a web view for certain hosts.
stopTrackingDatadogEvents()
Disables RUM event tracking in a web view. When a web view is about to be de-allocated or you are done with the web view, call this API.

For example:

import WebKit
import Datadog
 
webView.configuration.userContentController.trackDatadogEvents(in: ["example.com"])

Access your web views

Your web views appear as events and views in the RUM Explorer with associated service and source attributes. The service attribute indicates the web component the web view is generated from, and the source attribute denotes the mobile application’s platform, such as iOS.

Filter on your iOS and tvOS applications, and click a session. A side panel with a list of events in the session appears.

Webview events captured in a session in the RUM Explorer

Click Open View waterfall to navigate from the session to a resource waterfall visualization in the view’s Performance tab.

Further Reading

Additional helpful documentation, links, and articles: