Braze
Braze is an analytics and marketing automation product. You can track Rover events into Braze 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.
Sending Rover events to Braze
After integrating both the Rover and Braze SDKs into your project, your goal will be to send all the Rover events to Braze as Braze custom events.
Conversion Tracking
A method for including the Rover conversion tracking tags is to continually append them to a Braze custom attribute array. Braze arrays are ordered sets with a size limit that act as a FIFO (first-in, first-out), and so old conversion tracking tags will eventually rotate out of the Braze array, which typically have a limit of 100.
Create a Listener for Rover Events
Rover.shared?.eventEmitter?.addEventListener(object : RoverEventListener {
… // see below for implementations.
})
Experience Presented
override fun onExperiencePresented(event: RoverEvent.ExperiencePresented) {
val properties = AppboyProperties()
properties.addProperty("experienceID", event.experience.id)
properties.addProperty("experienceName", event.experience.name)
event.campaignId?.let {
properties.addProperty("campaignID", it)
}
Appboy.getInstance(this@SampleApplication).logCustomEvent(
"Rover Experience Presented",
properties
)
}
Experience Dismissed
override fun onExperienceDismissed(event: RoverEvent.ExperienceDismissed) {
val properties = AppboyProperties()
properties.addProperty("experienceID", event.experience.id)
properties.addProperty("experienceName", event.experience.name)
event.campaignId?.let {
properties.addProperty("campaignID", it)
}
Appboy.getInstance(this@SampleApplication).logCustomEvent(
"Rover Experience Dismissed",
properties
)
}
Experience Viewed
This event describes the session (duration, primarily) spent viewing a Rover Experience.
override fun onExperienceViewed(event: RoverEvent.ExperienceViewed) {
val properties = AppboyProperties()
properties.addProperty("experienceID", event.experience.id)
properties.addProperty("experienceName", event.experience.name)
properties.addProperty("duration", event.duration)
event.campaignId?.let {
properties.addProperty("campaignID", it)
}
Appboy.getInstance(this@SampleApplication).logCustomEvent(
"Rover Experience Viewed",
properties
)
}
Screen Presented
override fun onScreenPresented(event: RoverEvent.ScreenPresented) {
val properties = AppboyProperties()
properties.addProperty("experienceID", event.experience.id)
properties.addProperty("experienceName", event.experience.name)
properties.addProperty("screenID", event.screen.id)
properties.addProperty("screenName", event.screen.name)
event?.campaignId?.let {
properties.addProperty("campaignID", event.campaignId)
}
Appboy.getInstance(this@SampleApplication).logCustomEvent(
"Rover Screen Presented",
properties
)
}
Screen Dismissed
override fun onScreenDismissed(event: RoverEvent.ScreenDismissed) {
val properties = AppboyProperties()
properties.addProperty("experienceID", event.experience.id)
properties.addProperty("experienceName", event.experience.name)
properties.addProperty("screenID", event.screen.id)
properties.addProperty("screenName", event.screen.name)
event.campaignId?.let {
properties.addProperty("campaignID", event.campaignId)
}
Appboy.getInstance(this@SampleApplication).logCustomEvent(
"Rover Screen Dismissed",
properties
)
}
Screen Viewed
This event describes the session (duration, primarily) spent viewing an individual screen within a Rover Experience.
override fun onScreenViewed(event: RoverEvent.ScreenViewed) {
val properties = AppboyProperties()
properties.addProperty("experienceID", event.experience.id)
properties.addProperty("experienceName", event.experience.name)
properties.addProperty("screenID", event.screen.id)
properties.addProperty("screenName", event.screen.name)
properties.addProperty("duration", event.duration)
event?.campaignId?.let {
properties.addProperty("campaignID", event.campaignId)
}
val currentUser = Appboy.getInstance(this@SampleApplication).currentUser
event.screen.conversion?.tag?.let { conversionTag ->
currentUser?.addToCustomAttributeArray("rover_conversions", conversionTag)
}
Appboy.getInstance(this@SampleApplication).logCustomEvent(
"Rover Screen Viewed",
properties
)
}
Block Tapped
override fun onBlockTapped(event: RoverEvent.BlockTapped) {
val properties = AppboyProperties()
properties.addProperty("experienceID", event.experience.id)
properties.addProperty("experienceName", event.experience.name)
properties.addProperty("screenID", event.screen.id)
properties.addProperty("screenName", event.screen.name)
properties.addProperty("blockID", event.block.id)
properties.addProperty("blockName", event.block.name)
event?.campaign?.let {
properties.addProperty("campaignID", event.campaignId)
}
val currentUser = Appboy.getInstance(this@SampleApplication).currentUser
event.block.conversion?.tag?.let { conversionTag ->
currentUser?.addToCustomAttributeArray("rover_conversions", conversionTag)
}
Appboy.getInstance(this@SampleApplication).logCustomEvent(
"Rover Block Tapped",
properties
)
}
Poll Answered
override fun onPollAnswered(event: RoverEvent.PollAnswered) {
val properties = AppboyProperties()
properties.addProperty("experienceID", event.experience.id)
properties.addProperty("experienceName", event.experience.name)
properties.addProperty("screenID", event.screen.id)
properties.addProperty("screenName", event.screen.name)
properties.addProperty("blockID", event.block.id)
properties.addProperty("blockName", event.block.name)
properties.addProperty("optionID", event.option.id)
properties.addProperty("optionText", event.option.text)
event.option.image?.let {
properties.addProperty("optionImage", it)
}
event.campaignId?.let {
properties.addProperty("campaignID", it)
}
val currentUser = Appboy.getInstance(this@SampleApplication).currentUser
event.block.conversion?.tag?.let { conversionTag ->
// Retrieving poll option text to append selected poll answer to conversion tag
val formattedPollOption = event.option.text.replace(" ", "_").toLowerCase(Locale.ROOT)
currentUser?.addToCustomAttributeArray("rover_conversions", "${conversionTag}_${formattedPollOption}")
}
Appboy.getInstance(this@SampleApplication).logCustomEvent(
"Rover Poll Answered",
properties
)
}