Mixpanel

Mixpanel is an analytics and marketing automation product. You can track Rover events into Mixpanel to use it for either or both using the following sample integration. You may need to customize it to get the best value out of the tool.


Mapping Rover Events to Mixpanel Events

After integrating both the Rover and Mixpanel SDKs into your project, your goal will be to send the Rover events to Mixpanel as Mixpanel events.


Create a Listener for Rover Events

Rover.shared?.eventEmitter?.addEventListener(object : RoverEventListener {
     // see below for implementations.
}

Experience Viewed

We’ll use Mixpanel’s timeEvent and trackMap methods to aggregate the Presented and Dismissed events so a duration will be calculated by Mixpanel.

override fun onExperiencePresented(event: RoverEvent.ExperiencePresented) {
    mixpanel.timeEvent("Rover Experience Viewed")
}
override fun onExperienceDismissed(event: RoverEvent.ExperienceDismissed) {
    val campaignId = event.campaignId
    val attributes = hashMapOf(
        "experienceID" to event.experience.id,
        "experienceName" to event.experience.name
    ) + if(campaignId != null) hashMapOf("campaignID" to campaignId) else hashMapOf()

    mixpanel.trackMap(
        "Rover Experience Viewed",
        attributes
    )
}

Screen Viewed

We’ll use Mixpanel’s timeEvent and trackMap methods to aggragate the Presented and Dismissed events so a duration will be calculated by Mixpanel.

override fun onScreenPresented(event: RoverEvent.ScreenPresented) {
    mixpanel.timeEvent("Rover Screen Viewed")
}
override fun onScreenDismissed(event: RoverEvent.ScreenDismissed) {
    val campaignId = event.campaignId
    val attributes = hashMapOf(
        "experienceID" to event.experience.id,
        "experienceName" to event.experience.name,
        "screenID" to event.screen.id,
        "screenName" to event.screen.name,
    ) + if(campaignId != null) hashMapOf("campaignID" to campaignId) else hashMapOf()

    mixpanel.trackMap(
        "Rover Experience Viewed",
        attributes
    )
}

Block Tapped

override fun onBlockTapped(event: RoverEvent.BlockTapped) {
    val campaignId = event.campaignId
    val attributes = hashMapOf(
        "experienceID" to event.experience.id,
        "experienceName" to event.experience.name,
        "screenID" to event.screen.id,
        "screenName" to event.screen.name,
        "blockID" to event.block.id,
        "blockName" to event.block.name
    ) + if(campaignId != null) hashMapOf("campaignID" to campaignId) else hashMapOf()

    mixpanel.trackMap(
        "Rover Block Tapped",
        attributes
    )
}