sendViews
The sendViews() method records a single hierarchical screen view on your mobile app. The values you pass are joined into one path (for example, screen/Onboarding/Welcome) and dispatched as a single event. Use it to group related screens under a logical hierarchy in reports.
Syntax
PiwikTracker.sharedInstance()?.sendViews(views: ["Onboarding", "Welcome"])[[PiwikTracker sharedInstance] sendViews:@[@"Onboarding", @"Welcome"]];Parameters
- views
array<string>, required- Screen names from parent to child; the SDK joins them with/into one hierarchy and sends one event. Example:["Settings", "Privacy", "Cookies"].
Notes
- The SDK builds a synthetic URL for that screen view:
http://{appName}/{path}, whereappNamecomes from your app bundle (display name, or bundle name if missing), with spaces removed. WhenisPrefixingEnabledis true (the default),screencomes first, then your array values in order, for examplehttp://MyApp/screen/Settings/Privacy/Cookiesfor["Settings", "Privacy", "Cookies"].
Examples
To track a hierarchical screen view that combines Settings, Privacy, and Cookies into one path:
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
PiwikTracker.sharedInstance()?.sendViews(views: ["Settings", "Privacy", "Cookies"])
}- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[[PiwikTracker sharedInstance] sendViews:@[@"Settings", @"Privacy", @"Cookies"]];
}Call sendViews() from the .onAppear modifier on the view that represents that hierarchy (here, the privacy & cookies screen under Settings):
struct SettingsPrivacyCookiesView: View {
var body: some View {
Text("Privacy & cookies")
.onAppear {
PiwikTracker.sharedInstance()?
.sendViews(views: ["Settings", "Privacy", "Cookies"])
}
}
}