ZOFTINO.COM android and web dev tutorials

Predicting App User Behavior Using Firebase Predictions

Firebase predictions service applies Google’s machine learning on analytics data and comes up with predictions. Prediction identifies a group of users who are most likely to perform certain events in the next seven days. Using the predicted behavior, apps can be customized to create different user experiences or to show different features or products.

Predictions data will be available in Firebase remote config service. This allows you to define a remote config parameter to have a value based on a prediction condition. So apps can be customized using remote config parameter which derives values based on predictions.

Predictions data can also be used with notification composer. Predictions data is available in notification composer when notification target is user segment. Predictions can be used to define conditions which defines user segment to target for a notification.

Now let’ see how to enable predictions.

Enabling Firebase Predictions

Since Firebase predictions use analytics data, you need to first add Firebase analytics to your app to use predictions. You can see Firebase analytics tutorial to know how to add analytics to your app and how to add default and custom events and parameters to analytics.

After that, you need to enable analytics data sharing so that the analytics data will be shared within your project and will be available for Firebase predictions. You can enable sharing of analytics data in Firebase console by going to project settings, then to analytics tab and select the sharing options like shown in the picture below.

firebase predictions enable analytics data sharing

Then in Firebase console, you need to enable Firebase predictions by selecting predictions in the left navigation and accepting terms of service.

firebase predictions enable predictions

Default Predictions

Firebase prediction service creates default predictions. The default predictions are generated based on apps analytics data. The default predictions are churn, not_churn, spend and not_spend.

Prediction churn represents a group of users who are active in the last seven days and will likely to become inactive in the next seven days. Not_chrun prediction gives users who are activie in the last seven days and will continue to be active in the next seven days. Users whose behavior can’t be predicted may or may not be part of either or both of these churn groups.

Spend prediction gives users who are likely to purchase in the next seven days and not_spend predicts users who may not spend in the next seven days.

Creating Prediction

Creating prediction is nothing but adding one of the conversion analytics events to prediction definition. In the process of creating predictions, first identify analytics events that you want to use for predictions and mark them as conversion events by going to analytics and events in Firebase console, as only conversion events can be tied to predictions.

firebase predictions enable predictions

Then to create a prediction, click predictions in the left navigation to see predictions and suggestion page that lists default predictions as shown below. Then click create prediction link. Create prediction link will be enabled only after analytics data is available for at least one of the default or custom conversion events.

firebase predictions create prediction

Select an event from the list of events that you want to create a prediction for and save it.

firebase predictions creation prediction select analytics event to predict

Once prediction is created, it will take time depending on the number of app users for the service to create predictions.

Using Predictions

Once predictions are calculated, the data will be available in remote config and notification composer. As a prediction identifies users whose likelihood of behaving in certain way is more, you can use the prediction to customize your app in that context of the behavior using remote config for only predicted users and send notification to only predicted users to improve the chance of achieving target goals.

Customizing Apps Using Predictions and Firebase Remote Config

You can create a remote config parameter with default value in Firebase console and add prediction condition to assign a different value based on a prediction. The value will indicate whether a user is predicted to behave in a certain way or not in the next 7 days.

To add a remote config parameter, login to firebase console, click remote config in the left navigation, click add parmeter and enter name and default value. Please see, Firebase remote config tutorial to lean how to define and use remote config in android app.

firebase predictions remote config

After adding parameter name and default value, click add value for condition link in the create parameter window, screen shot above. Then click define new condition, enter condition name, select applies if, choose prediction, select the target prediction and click create condition.

firebase predictions remote config condition definition using prediction

Once remote config parameter with prediction condition is defined, you can use the parameter in the app to create different user experience. For example, if a particular user is predicted to like a xyz store offer, then the xyz_store_offer remote parameter value will be true for the user.

 boolean likesXyzStoreOffer = firebaseRemoteConfig.getBoolean("xyz_store_offer");

//show different content
//show common content

Sending Notifications Using Predictions and Firebase Notification Composer

You can send notifications to a specific device, user groups or a topic using Firebase notification composer. Since predictions data is available in notification composer, you can send certain notifications to only predicted users.

To send a notification to only predicted users of a prediction, choose target as user segment, select app for app condition, click and, select prediction and risk tolerance as shown below. The prediction condition chooses users who are predicted to behave in certain way and notification will be sent to only those users.

firebase predictions notification composer

Predictions Accuracy

Predictions service allows you to choose level of accuracy by setting risk tolerance level. Risk tolerance level allows you to tell prediction service to give few users with high accuracy or more users with low accuracy for a prediction. There are three levels of risk tolerance: High risk tolerance, medium risk tolerance and low risk tolerance.

The option to choose risk tolerance is available when you try to add a prediction condition in remote config and notification composer.