Unlocking User Engagement: A Comprehensive Guide to Firebase In-App Messaging | by Pankaj Rai 🇮🇳 | Sep, 2023

How frequently do you execute campaigns within your app or aspire to display contextual alerts triggered by user actions? For instance, consider the scenario of presenting a pop-up dialog with a coupon code when a user adds items to their cart to potentially boost their purchase motivation. Alternatively, envision a situation where you aim to reward users each time they open your app on a daily basis.

One of the most common challenges associated with such implementations is the necessity for not only client-side (Android, iOS) modifications but also server-side adjustments to ensure contextual alerts. However, the complexity doesn’t end there. Consider the intricacies involved in managing events when we’re targeting user actions. Now, envision a scenario: Would you hard-code these actions into the app-side logic? This would imply that for any new events, you’d have to release a new app update on the Play Store. Even if you incorporate such logic on the server side, there’s still a substantial amount of client-side management required to interpret the action events and subsequently display the dialog.

How about achieving this functionality without managing any client side or server side code?

Firebase In-App Messaging
Let’s add the functionality with the Firebase In-App Messaging, so for that we have to add Firebase to our project first and also the Firebase Analytics service.

Add the following dependencies

dependencies     
implementation(platform("com.google.firebase:firebase-bom:32.3.1"))
implementation("com.google.firebase:firebase-inappmessaging-display-ktx")
implementation("com.google.firebase:firebase-analytics-ktx")

Now as we have added the dependency for In-App Messaging so let’s get started

There are four types of templates that we can use for our use case, they are
Card, Modal, Image only, Top Banner

Card

From the Firebase console, you have the capability to write the title, description, image, and you can specify two action buttons. What’s particularly convenient is that you can also preview how the display will appear in the right-side panel.

The next step is to define the target condition

Write a campaign name and provide a descriptive campaign description. This will help you easily recall the purpose of this campaign in the future. Afterward, select the eligible users by specifying the app and combining various targeting conditions. For instance, you can target users who had their last engagement 10 days before or include a specific user audience as the target group.

Now comes the interesting part, in the third step you have to select the schedule, you can specify if you want this campaign to start now or with some predefined date also how long do you want this campaign to run by specifying the end date.

Up to this point, we’ve explored how to target specific user groups based on various conditions and how to schedule campaigns. However, what about the trigger condition for displaying the card template that we discussed earlier? The solution is straightforward: integrate the appropriate analytics event into your app’s code. Once you’ve done that, you can select these events on the Firebase console to act as trigger points.

For example, in the screenshot above, you can see two target events: ‘on_foreground’ and ‘clear_canvas.’ Whenever any of these specified events occur, the dialog will be displayed. If your goal is to show the card template only when a user takes a specific action, such as clicking the ‘clear canvas’ button, you just need to set ‘clear_canvas’ as the trigger event.

This being as optional step is quite useful if you want to monitor how effective your campaign is basically conversion events are actions that you want your users to take after seeing your in-app message. For example, you might want users to visit a specific page in your app, make a purchase, or sign up for a newsletter. When a user takes a conversion event, Firebase tracks the event and adds it to your campaign’s conversion history. You can then use this data to see how effective your campaign is at driving conversions.

Now, we are fully prepared to proceed, as this configuration covers all the necessary steps to kickstart Firebase In-App Messaging. At client just adding the SDK is sufficient.

Earlier we have seen card template and we have other 3 types too

Modal

In this type, you have the option to input the title, description, and image through a URL, as well as configure the primary button.

Image Only

In this type, you have the option to provide image through URL and configure the action when user clicks on image.

Top Banner

In this type, you have the option to input the title, body, and image through a URL, as well as configure the action when clicked on top banner.

That’s it, now we can run campaign effectively by using In-App Messaging with these little steps.

By