3

My A/B Testing has a parameter "POSITION".

"TOP" is set to the parameter "POSITION" in 50% of users as control group

and "BOTTOM" is so in 50% of users as variant.

Then, I tried to get the value of the parameter in the following code.

    mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance();

    FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings.Builder().setDeveloperModeEnabled(BuildConfig.DEBUG).build();

    mFirebaseRemoteConfig.setConfigSettings(configSettings);

    ....................

     mFirebaseRemoteConfig.fetch().addOnCompleteListener(this, new OnCompleteListener<Void>() {
        @Override
        public void onComplete(@NonNull Task<Void> task) {
            if(task.isSuccessful()){
                mFirebaseRemoteConfig.activateFetched();




                String abtest = mFirebaseRemoteConfig.getString("POSITION");


                switch (abtest){
                    case "TOP":
                        ........
                        break;

                    case "BOTTOM":
                        ........

                    case "":
                        Log.v("abtest",empty);

                }

            }
        }
    });


    ......................

Above code is contained in class MainActivity and mFirebaseRemoteConfig is

its field.

But mFirebaseRemoteConfig.getString("POSITION") sometimes returns "".

Why does this happen?

ToyMod
  • 33
  • 4
  • Are you using testing devices? If an experiment is on draft, then Firebase doesn't assign the variants to devices. Therefore, you will not get any variant. You should follow this guide on how to test the variants: https://firebase.google.com/docs/ab-testing/abtest-config#validate_your_experiment_on_a_test_device – Giorgos Neokleous Apr 07 '19 at 12:13
  • Thank you for your comment! But my A/B Testing is running. Actually `mFirebaseRemoteConfig.getString("POSITION")` also returns `"TOP"` or `"BOTTOM"` , but sometimes returns `""`.... – ToyMod Apr 07 '19 at 13:06
  • Did you roll out the experiment to all your audience? If not Firebase will not return anything (probably empty string) if the user is not assigned to a variant. – Giorgos Neokleous Apr 08 '19 at 14:03
  • I don't use `Limit to a subset of users` in this experiment and `Percentage of target users` is set to 50%. So any user has to be assigned to control group or the variant.... – ToyMod Apr 09 '19 at 09:37

1 Answers1

2

Percent of target users should be set to 100% for all users to receive an experiment.