Skip to main content

Screen tracking — iOS

OpenCDP can auto-track UIViewController appearances and accepts explicit trackScreenView calls. Screen names feed the workspace screen catalog used by in-app Include / Exclude page rules.

Auto-track​

With autoTrackScreens = true, when a view controller appears OpenCDP uses, in order:

  1. title / navigationItem.title when non-empty
  2. Otherwise a cleaned type name (module prefix stripped), e.g. ProfileViewController

System and container controllers are skipped (UINavigationController, UITabBarController, UIInputWindowController, and other UI*Controller types) so they do not flood the catalog.

let config = OpenCDPConfig(
cdpApiKey: "YOUR_CDP_API_KEY",
autoTrackScreens: true
)
OpenCDP.shared.initialize(config: config)

Call trackScreenView with a stable string on appear — especially for SwiftUI and coordinator-based apps:

.onAppear {
OpenCDP.shared.trackScreenView(title: "/profile/personal-details")
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
OpenCDP.shared.trackScreenView(title: "Checkout")
}

Recommended shapes: /profile, Home, checkout/payment. Avoid empty strings and framework dumps.

Manual-only mode​

Set autoTrackScreens: false and call trackScreenView(title:) on every screen you care about for page rules.