For the complete documentation index, see llms.txt.

Customize autocaptured screen names

Last updated View as MarkdownSet up with AI

By default, UIKit and SwiftUI autocapture use view controller class names as the screen name. This can be overridden with the following techniques.

UIKit autocapture is powered by UIViewController lifecycles. When a view controller appears, the SDK uses its class name and title text as the default label for events.

For many apps, the class name provides enough information to uniquely identify the screen without applying code.

To refine the name for a given class, override the csqScreenNameOverride class property.

In the below example, SignUpFlowViewController is given the screen name "Main Signup Flow".

extension SignUpFlowViewController {
open override class var csqScreenNameOverride: String? {
"Main Signup Flow"
}
}

SwiftUI screenview autocapture builds on UIKit autocapture. When a view controller appears, for example through a NavigationLink, TabView, or UIHostingController, the SDK uses its class name and title text as the default label for events.

For hybrid SwiftUI/UIKit apps and apps with distinct screen titles, the default label is often enough without code changes.

For pure SwiftUI apps, the default label may not be specific enough, because SwiftUI can erase type information. To give the screenview a stable name, add the csqScreenName view modifier next to modifiers like navigationTitle or inside the view body.

In the below example, TransactionView is given the screen name "TransactionScreen".

struct TransactionView: View {
let transaction: Transaction
var body: some View {
ScrollView {
...
}
.navigationTitle("title-transaction")
.csqScreenName("TransactionScreen")
}
}