Analytics

Rover provides a simple mechansim to capture the usage patterns of Rover experiences and send them to your mobile analtyics provider.


Observing Notifications

As a user engages with a Rover experience, the SDK will broadcast NSNotification objects through the default iOS NotificationCenter. You can observe these notifications and log the information and/or send it your mobile analytics provider.

Rover includes NSNotification.Name constants on its ExperienceViewController and ScreenViewController classes that you can add Notification Center observers for.

Each of the NSNotification objects broadcast by the Rover SDK contains additional information in the NSNotification’s userInfo property. The structure of the data is different for each type of event, and has to be unpacked manually.


Observable Events

An exhaustive list of all the Rover event notifications you can observe and how to unpack their userInfo follows:

Experience Presented

NotificationCenter.default.addObserver(forName: ExperienceViewController.experiencePresentedNotification, object: nil, queue: nil) { notification in
    let experience = notification.userInfo?[ExperienceViewController.experienceUserInfoKey] as! Experience
    let campaignID = notification.userInfo?[ExperienceViewController.campaignIDUserInfoKey] as? String
    
    // Rover Experience presented.
}

Experience Dismissed

NotificationCenter.default.addObserver(forName: ExperienceViewController.experienceDismissedNotification, object: nil, queue: nil) { notification in
    let experience = notification.userInfo?[ExperienceViewController.experienceUserInfoKey] as! Experience
    let campaignID = notification.userInfo?[ExperienceViewController.campaignIDUserInfoKey] as? String

    // Rover Experience dismissed.
}

Experience Viewed

This event describes the session (duration, primarily) spent viewing a Rover Experience.

NotificationCenter.default.addObserver(forName: ExperienceViewController.experienceViewedNotification, object: nil, queue: nil) { notification in
    let experience = notification.userInfo?[ExperienceViewController.experienceUserInfoKey] as! Experience
    let duration = notification.userInfo?[ExperienceViewController.durationUserInfoKey] as! Double
    let campaignID = notification.userInfo?[ExperienceViewController.campaignIDUserInfoKey] as? String
    
    // Rover Experience viewed.
}

Screen Presented

NotificationCenter.default.addObserver(forName: ScreenViewController.screenPresentedNotification, object: nil, queue: nil) { notification in
    let experience = notification.userInfo?[ScreenViewController.experienceUserInfoKey] as! Experience
    let screen = notification.userInfo?[ScreenViewController.screenUserInfoKey] as! Screen
    let campaignID = notification.userInfo?[ScreenViewController.campaignIDUserInfoKey] as? String
    
    // Rover Screen presented.
}

Screen Dismissed

NotificationCenter.default.addObserver(forName: ScreenViewController.screenDismissedNotification, object: nil, queue: nil) { notification in
    let experience = notification.userInfo?[ScreenViewController.experienceUserInfoKey] as! Experience
    let screen = notification.userInfo?[ScreenViewController.screenUserInfoKey] as! Screen
    let campaignID = notification.userInfo?[ScreenViewController.campaignIDUserInfoKey] as? String
    
    // Rover Screen dismissed.
}

Screen Viewed

This event describes the session (duration, primarily) spent viewing an individual screen within a Rover Experience.

NotificationCenter.default.addObserver(forName: ScreenViewController.screenViewedNotification, object: nil, queue: nil) { notification in
    let experience = notification.userInfo?[ScreenViewController.experienceUserInfoKey] as! Experience
    let screen = notification.userInfo?[ScreenViewController.screenUserInfoKey] as! Screen
    let duration = notification.userInfo?[ScreenViewController.durationUserInfoKey] as! Double
    let campaignID = notification.userInfo?[ScreenViewController.campaignIDUserInfoKey] as? String
    
    // Rover Screen viewed.
}

Block Tapped

NotificationCenter.default.addObserver(forName: ScreenViewController.blockTappedNotification, object: nil, queue: nil) { notification in
    let experience = notification.userInfo?[ScreenViewController.experienceUserInfoKey] as! Experience
    let screen = notification.userInfo?[ScreenViewController.screenUserInfoKey] as! Screen
    let block = notification.userInfo?[ScreenViewController.blockUserInfoKey] as! Block    
    let campaignID = notification.userInfo?[ScreenViewController.campaignIDUserInfoKey] as? String
    
    // Rover Block tapped.
}