I don’t know if any particular country has a dislike of the colour red, but if such a country exists and you normally have red in your app, that doesn’t need to apply to them! Users from the country can have a much bluer experience while the rest of the world keeps their red experience!
Such power is possible with Remote Config. With it, we can give segments of our users a different experience from others, and we do this by setting parameters on the cloud. The different segments of users will load their corresponding value of that parameter and in your app, you can control what happens.
Importing the Dependency
You’ll need this in your app-level build.gradle file.
Initialising Remote Config
You’ll need an instance of the Remote Config singleton before you do anything with it.
FirebaseRemoteConfig remote = FirebaseRemoteConfig.getInstance();
Setting In-App Default Parameter Values
Create an XML file like this one and add it to your res/xml folder (or wherever you want. It doesn’t really matter).
Then on your FirebaseRemoteConfig object, call setDefaults() passing in the XML file to set your parameters and their default values.
Getting Parameter Values
On your FirebaseRemoteConfig object, you can call methods like getDouble() passing in the key of the parameter to retrieve its data. If you haven’t specifically set a value to that key, you’ll retrieve the default value.
Setting Parameter Values
Head to Grow > Remote Config for this one. Define parameters with the same names as those you’ve set in your XML file and their default values (which will override those in the XML).
You’ll see a button that says Add Value for Condition there as well. This is where you define conditions (based on audience, user property, random percentile, etc.) and different values to apply to users matching those conditions.
These won’t apply to your app though until you “fetch” the values in your app.
Fetching Parameter Values
On your FirebaseRemoteConfig object, you can call fetch() to retrieve all the parameters you set on the console. However, these won’t apply to your app until you call activateFetched() .
This is so that you can choose to apply new parameter values at an appropriate time that will ensure a smooth experience for your users.
And that’s it. It’s rather simple. All of User Segmentation is rather simple. This is also the final chapter of the mini-course about exploiting the power of User Segmentation.
If you haven’t already, check out the other parts of this mini-course.
- User Segmentation 1: Defining User Segments
- User Segmentation 2: Sending Targeted Messages
- User Segmentation 3: Conducting A/B Tests