Analytics

The Rover SDK offers you a stream of events informing you of user interactions with Rover. This may be of particular use for integrating with your analytics or marketing automation solutions. The Rover iOS SDK offers you two separate methods for receiving these events.


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.
}

Poll Answered

NotificationCenter.default.addObserver(forName: ScreenViewController.pollAnsweredNotification, object: nil, queue:nil) { notification in
    let experience = notification.userInfo?[ExperienceViewController.experienceUserInfoKey] as! Experience
    let campaignID = notification.userInfo?[ExperienceViewController.campaignIDUserInfoKey] as? String
    let screen = notification.userInfo?[ScreenViewController.screenUserInfoKey] as! Screen
    let block = notification.userInfo?[ScreenViewController.blockUserInfoKey] as! PollBlock
    let option = notification.userInfo?[ScreenViewController.optionUserInfoKey] as! PollOption

    // The question asked of the user.
    let pollID = block.pollID(containedBy: experience.id)
    let pollText = block.poll.question.rawValue
    // And the answer they selected.
    let optionID = option.id
    let optionText = option.text.rawValue

    // Rover Poll Answered.
}