कंसोल पर जाएं

Get Started with Firebase Predictions

You can use Firebase Predictions to predict user behavior. Your predictions are automatically available in Remote Config, the Notifications composer, Firebase In-App Messaging, and A/B Testing to help you customize the experience for different user segments. Or, you can export your predictions to BigQuery for analysis and use in your own tools.

This guide shows you how to use Predictions with your app, following these steps:

  1. Add Analytics to your app.
  2. Enable Analytics data sharing and Predictions
  3. Optional: Define custom predictions
  4. Use predictions in your app

Add Analytics to your app

Before you start using Predictions, add Analytics to your app.

It is helpful, though not required, to also add some additional events to capture key events and interactions in your app. Use the Firebase console to mark the most important events as conversion events.

This guide assumes that your app uses the predefined Churn and Spend predictions. But, you can also add additional Analytics events to your app so that you can predict other types of user behavior, such as the following:

  • When users spend a virtual in-app currency, as might occur in gaming apps. For this prediction, you need to use the spend_virtual_currency Analytics event in your app.
  • When users share app content, as might occur in most non-gaming apps with some type of social media integration. For this prediction, you need to use the share Analytics event in your app.
  • When users open a particular screen in your app, log a custom event.

To learn more about these events, see Events: All apps.

iOS

  1. Add Analytics to your app, using the instructions in the Analytics get started guide for iOS.

  2. Add additional events that you want to predict to your app, such as spend_virtual_currency or share. For instructions, see the Analytics log events guide for iOS. Use the following Analytics constants to log these events in your app: kFIREventSpendVirtualCurrency and kFIREventShare.

Android

  1. Add Analytics to your app, using the instructions in the Analytics get started guide for Android.

  2. Add additional events that you want to predict to your app, such as spend_virtual_currency or share. For instructions, see the Analytics log events guide for Android. Use the following Analytics constants to log these events in your app: SPEND_VIRTUAL_CURRENCY and SHARE.

Enable Analytics data sharing and Predictions

  1. Open the Integrations page of the Firebase console.

  2. If you haven't already enabled Google Analytics integration, do so.

  3. On the Integrations page, click Manage on the Google Analytics card, and then make sure the Share Analytics data with all Firebase features setting is enabled.

    To learn more about sharing settings, see Manage data sharing.

  4. In the Firebase console, open the Predictions section. If you haven't already agreed to the Predictions terms of service, do so.

After you have enabled data sharing and have agreed to the terms of service, Predictions will be enabled for your project. You can stop making predictions any time by disabling data sharing with Firebase Predictions from this page.

Create custom predictions

By default, Predictions is preconfigured to predict churning users and spending users. You can create a custom prediction by specifying an Analytics event—Firebase Predictions will predict which users will trigger that event.

For instructions on creating a prediction, see Create a prediction.

Use a prediction with your app

After you enable Predictions or create a custom prediction, the service will begin preparing a model to make predictions for your users. When preparation finishes, you can start using the prediction with your app:

  1. On the Firebase console Predictions page, find the card for the prediction you want to use, and click Explore and use prediction.

  2. Select the user segment you want to target.

    A user segment is made up of the users that fall inside a range of percentile values, which you specify. A user's percentile value represents the relative likelihood of the user performing an action (churn, spend, and so on), compared to all users. Each user's percentile value is assigned by sorting your users according to their likelihood of performing the predicted action and then splitting the sorted list into 100 equal-sized groups.

    For example, when predicting spending, a user in the 25th percentile is as likely or more likely to spend than 25% of your users, and users in the segment containing percentiles 1-25 are the 25% of your users least likely to spend.

    Firebase Predictions predefines the following user segments:

    Least likely The 25% of users least likely to perform the action (percentiles 1-25).
    Middle The middle 50% of users (percentiles 26-75). This segment often represents your most convinceable users.
    Most likely The 25% of users most likely to perform the action (percentiles 76-100).

    If you want to target a percentile range other than one of the presets, you can define a custom user segment by specifying your own upper and lower bounds. In the Firebase console, the lower bound of the range is exclusive and the upper bound inclusive, so the ranges 0-50 and 50-100 don't overlap.

  3. Choose the product you want to use with the prediction—Remote Config, FCM, or Firebase In App Messaging—then click Continue. The product's configuration page will open, with the Target section pre-filled with the user segment you selected.

Next steps

For an example of how you can use Remote Config and A/B Testing with Predictions, see the Optimize monetization strategies use case guide.