Appearance
PageView Events
Also referred as Screen Views, defines which page is being currently viewed by the user and from which page/screen did he reach there.
Overview
PageView events are essential for understanding user navigation patterns, popular screens, and user journey through your application. These events help you track which screens users visit most frequently and how they navigate between different parts of your app.
Creating PageView Events
Basic Usage
objective-c
// Create a pageview event
[[BrandKinesis sharedInstance] createEvent:BKPageViewNative params:@{BKCurrentPage: @"Screen Name" } isTimed: YES];
swift
// Create a pageview event
BrandKinesis.sharedInstance().createEvent (BKPageViewNative, params: [BKCurrentPage: "Screen Name"], isTimed: true)
UIViewController Integration
Integrate pageview tracking in your view controllers:
objective-c
// In your UIViewController
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
// Track pageview when screen appears
[[BrandKinesis sharedInstance] createEvent:BKPageViewNative params:@{BKCurrentPage: NSStringFromClass([self class]) } isTimed: YES];
}
swift
// In your UIViewController
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
// Track pageview when screen appears
BrandKinesis.sharedInstance().createEvent (BKPageViewNative, params: [BKCurrentPage: String(describing: type(of: self))], isTimed: true)
}
Navigation Controller Integration
Track pageviews automatically in navigation controllers:
objective-c
// In your UINavigationController subclass
- (void)viewControllerDidAppear:(UIViewController *)viewController {
// Track pageview when any view controller appears
NSString *screenName = NSStringFromClass([viewController class]);
[[BrandKinesis sharedInstance] createEvent:BKPageViewNative params:@{BKCurrentPage: screenName } isTimed: YES];
}
// Alternative: Category method for all UIViewControllers
@implementation UIViewController (UpshotTracking)
- (void)upshot_viewDidAppear:(BOOL)animated {
[self upshot_viewDidAppear:animated];
// Track pageview automatically
NSString *screenName = NSStringFromClass([self class]);
[[BrandKinesis sharedInstance] createEvent:BKPageViewNative params:@{BKCurrentPage: screenName } isTimed: YES];
}
@end
swift
// In your UINavigationController subclass
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
if let topViewController = topViewController {
let screenName = String(describing: type(of: topViewController))
BrandKinesis.sharedInstance().createEvent (BKPageViewNative, params: [BKCurrentPage: screenName], isTimed: true)
}
}
// Alternative: Extension for all UIViewControllers
extension UIViewController {
func trackPageView() {
let screenName = String(describing: type(of: self))
BrandKinesis.sharedInstance().createEvent (BKPageViewNative, params: [BKCurrentPage: screenName], isTimed: true)
}
}
Tab Bar Controller Integration
Track pageviews in tab bar controllers:
objective-c
// In your UITabBarController subclass
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
// Track pageview when tab is selected
NSString *screenName = NSStringFromClass([viewController class]);
[[BrandKinesis sharedInstance] createEvent:BKPageViewNative params:@{BKCurrentPage: screenName } isTimed: YES];
}
swift
// In your UITabBarController subclass
override func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) {
let screenName = String(describing: type(of: viewController))
BrandKinesis.sharedInstance().createEvent (BKPageViewNative, params: [BKCurrentPage: screenName], isTimed: true)
}
Custom Screen Tracking
Track specific screens with custom names and parameters:
objective-c
// Custom screen tracking with parameters
- (void)trackCustomScreen:(NSString *)screenName {
// Create custom pageview event with additional data
[[BrandKinesis sharedInstance] createEvent:BKPageViewNative params:@{BKCurrentPage: screenName } isTimed: YES];
}
// Example usage in specific screens
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self trackCustomScreen:@"ProductDetailScreen"];
}
swift
// Custom screen tracking with parameters
func trackCustomScreen(_ screenName: String) {
// Create custom pageview event with additional data
BrandKinesis.sharedInstance().createEvent (BKPageViewNative, params: [BKCurrentPage: screenName], isTimed: true)
}
// Example usage in specific screens
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
trackCustomScreen("ProductDetailScreen")
}
Best Practices
- Consistent Naming: Use a unified naming convention for all screens to maintain consistency across the platform.
- Meaningful Names: Use descriptive names that clearly identify the screen
- Avoid Duplicates: Don't track the same screen view multiple times unnecessarily
- Error Handling: Always handle the callback response
- Use Class Names: Leverage
NSStringFromClass
orString(describing:)
for consistent naming - Track User Flow: Consider tracking screen transitions to understand user journeys
Validation
You can validate PageView events in the Dashboard Live Events section to ensure your events are being captured correctly.
Next Steps
- Custom Events - Learn how to track custom user interactions
- Attribution Events - Track campaign attribution data