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 attributes = mutableMapOf(
        "experienceID" to event.experience.id,
        "experienceName" to event.experience.name
    )

    event.campaignId?.let {
        attributes.put("campaignID", it)
    }

    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 attributes = mutableMapOf(
        "experienceID" to event.experience.id,
        "experienceName" to event.experience.name
    )

    event.campaignId?.let {
        attributes.put("campaignID", it)
    }

    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 attributes = mutableMapOf(
        "experienceID" to event.experience.id,
        "experienceName" to event.experience.name,
        "duration" to event.duration.toString()
    )

    event.campaignId?.let {
        attributes.put("campaignID", it)
    }

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

Screen Presented

Use the Localytics Content Viewed tag:

override fun onScreenPresented(event: RoverEvent.ScreenPresented) {
    val attributes = mutableMapOf(
        "experienceID" to event.experience.id,
        "experienceName" to event.experience.name,
        "screenID" to event.screen.id,
        "screenName" to event.screen.name
    )

    event.campaignId?.let {
        attributes.put("campaignID", it)
    }

    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 attributes = mutableMapOf(
        "experienceID" to event.experience.id,
        "experienceName" to event.experience.name,
        "screenID" to event.screen.id,
        "screenName" to event.screen.name
    )

    event.campaignId?.let {
        attributes.put("campaignID", it)
    }

    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 = mutableMapOf(
        "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()
    )

    event.campaignId?.let {
        attributes.put("campaignID", it)
    }

    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 = mutableMapOf(
        "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
    )

    event.campaignId?.let {
        attributes.put("campaignID", it)
    }

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

Poll Answered

override fun onPollAnswered(event: RoverEvent.PollAnswered) {
    val attributes = mutableMapOf(
        "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,
        "optionID" to event.option.id,
        "optionText" to event.option.text
    )

    event.option.image?.let {
        attributes.put("optionImage", it)
    }

    event.campaignId?.let {
        attributes.put("campaignID", it)
    }

    Localytics.tagEvent(
        "Rover Poll Answered",
        attributes
    )
}