Experiment with monetization strategies using Firebase Predictions

Firebase Predictions makes it easy to provide your app's users a different experience depending on your users' predicted behavior. For example, you can provide an ad-free experience to users who are likely to make in-app purchases in the future, and show ads to everyone else. However, before you deploy this monetization strategy across the board, it's important to be sure that such a strategy actually improves your app's overall revenue.

This guide shows you how you can accomplish both goals using Firebase Predictions and Firebase A/B Testing: you will enable an ads-based monetization strategy for users who are predicted not to make in-app purchases, and you will verify the effectiveness of this new strategy.

Before you begin

Before you can start using predictions to determine your app's ads policy, you must be using Google Analytics in your app. In particular, you must:

  • Enable Analytics data sharing in the Firebase console.
  • Optional: Explicitly log any Analytics events relevant to your app that aren't automatically logged. By logging these events, you can improve the quality of future classifications.
  • Have a sufficient number of users. Although Predictions does its best to predict behavior for apps with any size user base, you typically need at least 500 daily active users to have meaningful predictions.
  • Make sure your users are logging some positive examples of the event you want to predict—for example, when predicting spend, your users must already be logging some in_app_purchase events.

1. Make your ads remotely configurable

First, set up your app to show or hide ads depending on the value of a Remote Config parameter. In the steps that follow, you will configure Predictions and A/B Testing to set the parameter remotely based on various criteria, but for now, your app will always display ads.

For example, using AdMob for ads:

  1. Import the Analytics, Remote Config, and AdMob SDKs:

    iOS (Swift)

    Add the SDKs to your Podfile:

    pod 'Firebase/Analytics'
    pod 'Firebase/RemoteConfig'
    pod 'Firebase/AdMob'

    Then, import them:

    import Firebase


    implementation 'com.google.firebase:firebase-analytics:17.2.2'
    implementation 'com.google.firebase:firebase-config:19.1.0'
    implementation 'com.google.firebase:firebase-ads:18.3.0'
  2. Initialize Remote Config and set the default value of the ads_enabled variable to true. Later, you will set up Predictions and A/B Testing to set this variable remotely, but by setting a default value in your app, you ensure that your app functions correctly before remotely-configured variables are retrieved.

    iOS (Swift)

    self.remoteConfig = RemoteConfig.remoteConfig()
    self.remoteConfig.setDefaults(["ads_enabled": true])


    mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
    Map<String, Object> remoteConfigDefaults = new HashMap<>();
    remoteConfigDefaults.put("ads_enabled", "true");


    firebaseRemoteConfig = FirebaseRemoteConfig.getInstance()
    val remoteConfigDefaults = HashMap<String, Any>()
    remoteConfigDefaults["ads_enabled"] = "true"
  3. Show or hide ads based on the value of ads_enabled. Until you set up Predictions, this value will always be true and ads will always be displayed.

    iOS (Swift)

    self.remoteConfig.fetch() { (status, error) -> Void in
        if status == .success {
        // Act on the retrieved parameters
        // Show ads based on the ad policy retrieved with Remote Config
        // ...
    // ...
    func executeAdsPolicy() {
        let showAds = self.remoteConfig["ads_enabled"].booleanValue
        if showAds {
            self.bannerView.isHidden = false
        } else {
            self.bannerView.isHidden = true


            .addOnCompleteListener(this, new OnCompleteListener<Void>() {
        public void onComplete(@NonNull Task<Void> task) {
            if (task.isSuccessful()) {
            // Act on the retrieved parameters
            // Show ads based on the ad policy retrieved with Remote Config
            // ...
    // ...
    private void executeAdsPolicy() {
        boolean showAds = mFirebaseRemoteConfig.getBoolean("ads_enabled");
        AdView mAdView = findViewById(R.id.adView);
        if (showAds) {
            AdRequest adRequest = new AdRequest.Builder().build();
        } else {


            .addOnCompleteListener(this) { task ->
                if (task.isSuccessful) {
                // Act on the retrieved parameters
                // Show ads based on the ad policy retrieved with Remote Config
                // ...
    // ...
    private fun executeAdsPolicy() {
        val showAds = firebaseRemoteConfig.getBoolean("ads_enabled")
        val adView = findViewById<AdView>(R.id.adView)
        if (showAds) {
            val adRequest = AdRequest.Builder().build()
            adView.visibility = View.VISIBLE
        } else {
            adView.visibility = View.GONE

At this point, you can deploy your app to the App Store or Play Store. Users will get the default ads experience (ads always displayed), but because ad display is controlled by a remotely configurable variable, you can change and experiment with your ads' behavior using only the Firebase console, without having to push app updates to your users.

2. Start predicting user spending

Next, set up your Firebase project to start predicting your users' spending behavior.

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 agreed to the terms of service, Predictions will be enabled for your project. The Predictions section of the Firebase console allows you to define custom predictions. However, for spending predictions, you can make use of the built-in spend prediction, which uses an aggregation of Analytics events to predict whether a user will make an in-app purchase. These predictions will become available after you enable Predictions and have logged a few weeks' worth of spending events.

3. Create a monetization strategy experiment

Now create an A/B Testing experiment that tests the effect of the prediction-based monetization strategy on revenue compared to always displaying ads.

It is beneficial for an experiment to have three variants—a control group, a group that unconditionally sets a parameter, and a prediction-based group—so the experiment can determine whether the prediction-based approach has a greater benefit than from simply applying the treatment to everyone.

To create the experiment:

  1. In the Firebase console, open the A/B Testing section.

  2. Create a new experiment:

    1. Click Create experiment > Remote Config.

    2. Choose your app from the list and specify how many of your users you want to include in the experiment. You can also choose to exclude certain user categories, such as high spenders, from the experiment.

    3. Choose Estimated total revenue from the list of goal metrics, and select any additional metrics you want to track, such as user engagement, retention, app removals, and ad clicks.

    4. Define three variants:

      • Control group (created automatically)
      • Never display ads
      • No ads for likely spenders

      For the Control group, create an ads_enabled parameter and set it to (no change). Users assigned to the control group will get the default behavior, which is to always see ads.

      For the Never display ads variant, set the ads_enabled parameter to false. Users assigned to this variant never see ads.

      For the No ads for likely spenders variant:

      1. Set the ads_enabled parameter to false.
      2. Click Limit to a subset of users and choose Predictions (Beta) > Predict: spend.
      3. Set the percentile range you want to target. To target likely spenders, the 95-100 percentile range is a good place to start.

      Users assigned to this variant won't see ads if they are predicted to spend in the next 7 days.

Start the experiment and let it run for several days or more, until A/B Testing declares a leader. If the experiment cannot determine a leader, you might need to expand the experiment to more users.

4. Roll out the winning variant to all users

After A/B Testing has collected enough information to declare a leader—in this case, the variant that maximized app revenue—you can decide whether to roll out the winning variant (or another variant) to all of your users.

In the A/B Testing section of the Firebase console, open the details view of the completed experiment. From this view, you can see how each variant performed according to your goal metric and any secondary metrics you selected. With this information, you can decide whether to roll out the leading variant or another variant.

To roll out a variant to all users, click more_vert > Roll out variant on the experiment's details page.