Localytics

Localytics is an analytics and marketing automation product. You can track Rover events into Localytics 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 Localytics Events

After integrating both the Rover and Localytics SDKs into your project, your goal will be to send the Rover events to Localytics as Localytics custom events. You can also tag Rover Experiences and Experience Screens as content to Localytics.


Create a Listener for Rover Events

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

Experience Presented

Use the Localytics Content Viewed tag:

override fun onExperiencePresented(event: RoverEvent.ExperiencePresented) {
    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()

    Localytics.tagContentViewed(
        event.experience.name,
        event.experience.id,
        "Rover Experience",
        attributes
    )
}

Experience Dismissed

Use the Localytics generic Event:

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()

    Localytics.tagEvent("Rover Experience Dismissed", attributes)
}

Experience Viewed

This event describes the session (duration, primarily) spent viewing a Rover Experience. It does not map directly to any Localytics concept, so use the Localytics generic Event:

override fun onExperienceViewed(event: RoverEvent.ExperienceViewed) {
    val campaignId = event.campaignId
    val attributes = hashMapOf(
        "experienceID" to event.experience.id,
        "experienceName" to event.experience.name,
        "duration" to event.duration.toString()
    ) + if(campaignId != null) hashMapOf("campaignID" to campaignId) else hashMapOf()

    Localytics.tagEvent("Rover Experience Viewed", attributes)
}

Screen Presented

Use the Localytics Content Viewed tag:

override fun onScreenPresented(event: RoverEvent.ScreenPresented) {
    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()

    Localytics.tagContentViewed(
        event.screen.name,
        event.screen.id,
        "Rover Screen",
        attributes
    )
}

Screen Dismissed

Use the Localytics generic Event:

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()

    Localytics.tagEvent(
        "Rover Screen Dismissed",
        attributes
    )
}

Screen Viewed

This event describes the session (duration, primarily) spent viewing an individual screen within a Rover Experience. It does not map directly to any Localytics concept, so use the Localytics generic Event:

override fun onScreenViewed(event: RoverEvent.ScreenViewed) {
    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,
        "duration" to event.duration.toString()
    ) + if(campaignId != null) hashMapOf("campaignID" to campaignId) else hashMapOf()

    Localytics.tagEvent(
        "Rover Screen Viewed",
        attributes
    )
}

Block Tapped

Use the Localytics generic Event:

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()

    Localytics.tagEvent(
        "Rover Block Tapped",
        attributes
    )
}