Experimentation Module
Welcome to the module. You are in the right place if you are looking to setup A/B experiments and config flags that can be remotely controlled in real time.
β
Benefits
Running experiments is essential to tweak certain part of your app without needing to go through code changes and Apple approval process. Whether you want to test your marketing copy, your pricing, or monitor what happens when showing or hiding certain parts of your app, experiments are the way to go.
This module integrates with Firebase Remote Configuration and A/B testing platform.
Setup
- Step 1. Head over to Firebase
- Step 2. Add a new project
- Step 3. Setup the newly created project:
- Select the app type to be iOS
- Fill up details (bundle identifier - can be found in Xcode or developer.apple.com, app id can be found on developer.apple.com under General > App Information > General Information)
- Step 4. Add Firebase SDK.
- In Xcode, File > Add Package Dependency > search for https://github.com/firebase/firebase-ios-sdk
- Add package might take a few minutes, itβs time to get some coffee
- Of the many options (Package Product) you only need a few, however there is a bug in Xcode that changes selection when scrolling, so add them all and we will clean this up in a later step
- Clean up: head over your target > under General (Frameworks, Libraries, and Embedded Content) remove all Firebase-prefixed dependencies except:
- FirebaseRemoteConfig
- FirebaseRemoteConfigSwift
- Skip any initialization code from the Firebase documentation, we got you covered and just continue to Console
Usage
Step 1. Setup your App Delegate In your AppDelegate::didFinishLaunchingWithOptions just adds the following line:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
Experimentation.shared.setup()
return true
}
β
Step 2. Create the remote config in Firebase
- Head over to Firebase
- Select your project
- Select Remote Configuration from the Release & Monitor menu
- Create a remote property (i.e. sample_xp_active). This property can be changed in real time in the Firebase console. For the sake of this tutorial make it a Boolean data type.
Step 3. Fetch remote config
From anywhere in your codebase: Experimentation.shared.getConfig(name: "sample_xp_active")
.
Use the result of the requested configuration to to customize some section of your app. For instance, the above could retrieve a Bool value to either display an element of the UI or not.
You can change the property in the Firebase console and fetch again in your app to get the updated value. All updates are streamed to the app, so there is no need to restart your app.
Step 4. (Optional) Create an A/B test
Optionally, you can create a A/B test to run on a certain section of your users:
- Head over to Firebase
- Select your project
- Select A/B Testing from the Engage menu
- Select Create Experiment > Remote Config
- Fill out the details using the property created in Step 2
The % of the user chosen in the A/B test configuration will consistently receive the same value for the remote configuration. Additionally Firebase will track metrics of choice, like conversion rate. Refer to the Analytic Module to setup your metrics and events.
β