loading...

Remote Configuration — A/B Testing | Use And Analyze New Features Without Any Update

irene83018774 profile image Irene ・4 min read

Alt Text
Hello everyone. In this article, I would like to talk about Remote Configuration — A/B Testing. What are they and where are they used? I want to start with these.

Remote Configuration

With the service, you can make changes in the behavior and appearance of your application without any updates. This process is managed by determining various parameters on the Console.

Use Cases:

  • Displaying the Language by Country/Region
  • Displaying Different Content to Different Users
  • Adapting the App Theme by Time
  • Releasing New Functions

Configurations

Go to Growing> Remote Configuration. Click Enable now to enable Remote Configuration.
Alt Text
Add the Remote Configuration dependencies in the build.gradle file in the app directory.

implementation 'com.huawei.agconnect:agconnect-remoteconfig:1.4.0.300'

Development

I have prepared a demo app to explain this service better. I’ll talk about it step by step.

First, I set the parameter using the Parameter Management tab in the Remote Config tab.
Alt Text
Then I determined the condition in the Condition Management tab and defined it in the parameter tab.
Alt Text
After the integration process on AGC is completed, you can start writing code on the application. In the code part, you must first specify the parameter you defined in AGC. You can do this by using the “Map” object or “XML”. I used XML.

override fun onCreate(savedInstanceState: Bundle?)   
{   
   super.onCreate(savedInstanceState)   
   setContentView(R.layout.activity_main)   
   /*   
   - Using a Map object   
   val mapDefault = mapOf("language" to "other",   
                          "key2" to "val2",   
                          "key3" to "val3",   
                          "key4" to "val4")   
    - Using an XML resource file   
    <?xml version="1.0" encoding="utf-8"?>   
     <remoteconfig>   
         <value key="language">other</value>   
     </remoteconfig>   
    */   
   val agConnectConfig = AGConnectConfig.getInstance()   
   agConnectConfig.applyDefault(R.xml.remote_config)   
   remoteButton = findViewById(R.id.remote)   
   remoteButton?.setOnClickListener {   
       agConnectConfig.fetch(0).addOnSuccessListener {   
           agConnectConfig.apply(it)   
           val languageResponse = agConnectConfig.getValueAsString("language")   
           Toast.makeText(this, languageResponse, Toast.LENGTH_LONG).show()   
           if (languageResponse == "en"){   
               showUpdateAlert("Language is English")   
           }   
           else if(languageResponse == "other"){   
               showUpdateAlert("Language is not English")   
           }   
       }.addOnFailureListener {   
           // fail fetching from remote config   
           it.printStackTrace()   
       }   
   }   
}   

After writing the code, you can test the Remote Configuration by making changes on the device according to the parameter.
Alt Text

A/B Testing

You can use the service to create one or more A/B tests engaging different user groups to compare your variants of app UI design, copywriting, product functions, or marketing activities for performance metrics and find the best one that meets user requirements.

Use Cases:

  • App UI Design Testing
  • App Copywriting Testing
  • App Function Testing

Configurations

Go to Growing > A/B Testing. Click Enable now in the upper right corner.
Alt Text
After the service is enabled, the page shown in the following figure is displayed.
Alt Text

Notifications Experiment:

When you want to send notifications to existing users, you can use the A/B Testing to find out which user is affected by what type of notification.

Remote Configuration Experiment:

You can use A/B Testing to determine specific behaviors for specific user groups in your application or if you want to learn how it affects users before updating your application.

Development

I used the Remote Configuration Experiment. I’ll try to explain the steps here.
Firstly, you need to access Analytics Kit to obtain the target experiment users and experiment data, and generate experiment reports.

Enable Analytics Kit
Alt Text

Add the following code to the build.gradle file in the app directory

implementation 'com.huawei.hms:hianalytics:4.0.2.300'

Create User Attributes in this way to use the User Attributes condition.
Alt Text
Create a condition on the Remote Configuration tab.
Alt Text
Use Conditions to create your parameter.
Alt Text
Then you will see a four-step screen when you press the Create Remote Configuration Experiment button on the A/B Testing tab.
Set the basic information of the test.
Alt Text
Specify the conditions for finding the target users in this step.
Alt Text
In this step, select your Remote Configuration parameter.
Alt Text
You can select the indicators you want to see as a result of the test. A maximum of 5 options can be selected.
Alt Text
After these steps, you can start writing your code based on the conditions in your application.

override fun onCreate(savedInstanceState: Bundle?)   
{   
   super.onCreate(savedInstanceState)   
   setContentView(R.layout.activity_main)   
   /*   
   - Using a Map object   
   val mapDefault = mapOf("ABTest" to "c",   
                          "key2" to "val2",   
                          "key3" to "val3",   
                          "key4" to "val4")   
    - Using an XML resource file   
    <?xml version="1.0" encoding="utf-8"?>   
     <remoteconfig>   
         <value key="ABTest">c</value>   
     </remoteconfig>   
    */   
   val agConnectConfig = AGConnectConfig.getInstance()   
   agConnectConfig.applyDefault(R.xml.remote_config)   
   remoteButton = findViewById(R.id.remote)   
   remoteButton?.setOnClickListener {   
       agConnectConfig.fetch(0).addOnSuccessListener {   
           agConnectConfig.apply(it)   
           val abTestResponse = agConnectConfig.getValueAsString("ABTest")   
           if (abTestResponse == "a"){   
               showUpdateAlert("abTestResponse = A ")   
           }   
           else if(abTestResponse == "b"){   
               showUpdateAlert("abTestResponse = B ")   
           }   
       }.addOnFailureListener {   
           // fail fetching from remote config   
           it.printStackTrace()   
       }   
   }   
}   

Finally, you need to start your test on the A/B Testing screen. Sufficient data must be collected to obtain the test result.

I’d like to add the screenshots I took while I was doing the test.
Alt Text

Conclusion

By using these two services, you can diversify your application according to your users, thus increasing the interaction. Moreover, without updating the application.

I hope this article was useful.

References

Remote Configuration:https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-remoteconfig-introduction
A/B Testing
https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-abtest-introduction

Posted on by:

Discussion

markdown guide