Skip to content

A/B Testing using Firebase Remote Config & Firebase Analytics

Notifications You must be signed in to change notification settings

NoelChew/RemoteConfigExercise

Repository files navigation

RemoteConfigExercise

A/B Testing using Firebase Remote Config & Firebase Analytics - Exercise

This exercise will attempt to conduct A/B test on an "Add To Cart" UI component in either one of the following forms:

  1. Button
  2. FloatingActionButton

using Firebase Remote Config and Firebase Analytics.

alt text alt text

Part 1: Implementing Firebase Remote Config

  1. Download the source code from this repo.

  2. Install Firebase SDK.

  3. Add Firebase Remote Config dependency into the app.

compile 'com.google.firebase:firebase-core:11.2.2'
compile 'com.google.firebase:firebase-config:11.2.2'
  1. Create default values for Remote Config locally.

Add

<?xml version="1.0" encoding="utf-8"?>
<defaultsMap>
    <entry>
        <key>useFAB</key>
        <value>true</value>
    </entry>
</defaultsMap>

into res/xml/remote_config_defaults.xml.

  1. Take a look at MainActivity.java and activity_main.xml. Some codes are missing in areas labelled with TODO.

Start with TODO: Part 1

Initialise Remote Config. Please refer to guide.

  • create Remote Config Singleton object
  • set Remote Config settings
  • set default values
  1. Create parameter in Firebase Console.

Set the parameter key as "useFAB" with default value of true.

Then, click on "Add value for condition" and key in these conditions:

  • "Use FAB for Add To Cart", with condition: User with random percentile <= 50%
  • "Use Button for Add To Cart", with condition: User with random percentile > 50% AND User with random percentile <= 100%

alt text

Publish changes.

  1. Get parameter values from the Remote Config object. Refer to getBoolean documentation, this guide and this example.

  2. Update UI after fetching value from Remote Config.

For more guidance, please refer to this quick start.

Part 2: Tracking User Behaviour via Firebase Analytics

  1. Add Firebase Analytics dependency to the app.

  2. Enable debug mode for Firebase Analytics by sending this command to device

adb shell setprop debug.firebase.analytics.app com.noelchew.remoteconfigsample

Without this, events logged will be batched together over the period of approximately one hour and uploaded together.

For more information (and how to disable this), please refer to this link.

  1. Locate TODO: Part 2 and try to call logEvent(FirebaseAnalytics.Event.ADD_TO_CART, bundle) with a custom boolean parameter called "usingFAB" to Firebase Analytics.

Refer to this guide.

  1. Create user property called "usingFAB" in Firebase Analytics.

  2. Uncomment setting of user property inside displayAddToCartUI() function.

Refer to this guide to learn more about setting user property.

  1. Run the app and check the events in DebugView (toggle StreamView if you can't find it).

  2. To check the user behaviour for different UI, check the Events tab and add filter to show "usingFAB" User Property.

However, data will only be available after 24 hours.

alt text

alt text

Done!

That's it! You have successfully implemented Firebase Remote Config and Firebase Analytics for a simple A/B testing. Note that in this exercise, there's not much sample data for you to tinker with in the Firebase Analytics console. You probably only have 1 sample size to play with. You can install the app into more devices if you wish to see more data (24 hours later).

Please refer to the solution if required.

About

A/B Testing using Firebase Remote Config & Firebase Analytics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages