> For the complete documentation index, see [llms.txt](https://falcon-game-studio.gitbook.io/falcon-sdk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://falcon-game-studio.gitbook.io/falcon-sdk/falcon-core/2.-remoteconfig-and-ab-testing/b.-abtesting-and-remoteconfig-example.md).

# b. AbTesting & RemoteConfig Example

### b.1. Requirements set forth in the example:

* When players enter the game, we will give daily gifts to players, which is a certain amount of resources. In this example, the gift would be coins, the most basic currency in the game.
* The amount of resources awarded to players will be abTesting on 60% of new players with 2 cases:
  * Half will be given 50 coins.
  * Half will be given 100 coins.
* In the gift message to the player, the message in that message will be implemented remoteConfig so that it can be changed when the need arises.

### b.2. Implement the UI part

* We create a panel in the canvas as follows:

<figure><img src="/files/bZRDY3Zx83g4aK50iel1" alt=""><figcaption></figcaption></figure>

* We create a class containing the elements corresponding to the panel:

<figure><img src="/files/hAGWYPOvflMLLpxcO5gg" alt=""><figcaption></figcaption></figure>

Where:&#x20;

* Message: The message implements remoteConfig.&#x20;
* Amount: the number of resources donated in the daily gift performed abTesting, visible to the user.&#x20;
* OnClaim: the player button confirms the receipt of the daily gift.

### b.3. Perform AbTesting and RemoteConfig code generation

* Step 1: We create the FalconConfig inheritance code, declaring the values you want to use, where:

  * `DailyGiftAmount`: the amount of resources donated to players according to dailyGift (default value is 50).
  * `NotifyMessage`: gift message, the default value is ("Welcome Back Gift").

  ```
  public class AbTestingConfig : FalconConfig
  {
      public int DailyGiftAmount = 50;
      public string NotifyMessage = "Welcome Back Gift";
  }
  ```
* Step 2: We create AbTesting code to perform the DailyGiftPanel call.

  ```
  public class AbTestingScript : MonoBehaviour
  {
      private static bool Popped = false;
      [SerializeField] private DailyGiftPanel dailyGiftPanel;
      
      private IEnumerator Start()
      {
          //Snooze dailyGiftPanel when it is not finished
          dailyGiftPanel.gameObject.SetActive(false);
          
          // Wait for SDK init
          while (!FalconMain.InitComplete) yield return null;
          
          //Check that the daily gift popup is only made once per day
          //The value of RetentionCounter.RetentionChanged will show whether this is 
          //the player's first login of the day does not, this value is 
          //provided by SDK, see FalconAnalytics/Automatic log for details
          if (!Popped && RetentionCounter.RetentionChanged)
          {
              Popped = true;
              
              //Show dailyGiftPanel
              dailyGiftPanel.gameObject.SetActive(true);
              
              //Adjust values based on configs
              dailyGiftPanel.Amount.text = 
                      "x" + FalconConfig.Instance<AbTestingConfig>().DailyGiftAmount;
              dailyGiftPanel.Message.text = 
                      FalconConfig.Instance<AbTestingConfig>().NotifyMessage;

              dailyGiftPanel.OnClaim.onClick.AddListener(() =>
              {
                  //Adjust player resource and hide panel when the user confirm
                  GameDataHandler.Instance.IncreaseCoin(
                          FalconConfig.Instance<AbTestingConfig>().DailyGiftAmount, 
                          "DailyGift");
                          
                  dailyGiftPanel.gameObject.SetActive(false);
              });
          }
          
      }

  }
  ```

### b.4. Declare Config on the server

* Step 1: Access <https://data4game.com/falcon-x/ab-testing/v2/remote-config.xhtml>, find the correct name of the game you want to create a config for.

<figure><img src="/files/gZHLGlmewsMvqutsuHkE" alt=""><figcaption></figcaption></figure>

* Step 2: Click Create Remote Config button.

<figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjD7QfQ9Dr736LmutDGT1%2Fuploads%2FUYsEtcjXGxPHjUVgm26e%2Fimage.png?alt=media&#x26;token=bc4809a2-58e9-4c94-a1ac-82ae8b866f0c" alt=""><figcaption></figcaption></figure>

Step 3: Create a Remote Config for NotifyMessage (Enter the name, select the data type, enter the description and default value)

<figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjD7QfQ9Dr736LmutDGT1%2Fuploads%2FQbVR9zzOar9PA1oKY5CB%2Fimage.png?alt=media&#x26;token=44b5cee3-8c40-49e6-a65e-a2bc17008882" alt="" width="563"><figcaption></figcaption></figure>

Step 4: Create a Remote Config for Daily Gift Amount.

<figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjD7QfQ9Dr736LmutDGT1%2Fuploads%2FEyoH5yjXh7atJVbZwUts%2Fimage.png?alt=media&#x26;token=41dc5e49-5dfc-4e09-bbc3-091fc8536572" alt="" width="563"><figcaption></figcaption></figure>

Here the configs have been recorded by the system as remote config, the value of the config has been adjusted according to the server on 100% of users according to filters.

<figure><img src="/files/BswF2HsNNoSt6Vms0TYw" alt=""><figcaption><p>The local values have now been updated according to the remote config values on the server.</p></figcaption></figure>

### b.5. Create an A/B Testing Campaign

In the next steps, we will create abTesting on the DailyGiftAmount variable, performing abTesting on 60% of new players.

* Step 1: Create an A/B Testing campaign on data4game.

<figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjD7QfQ9Dr736LmutDGT1%2Fuploads%2FH7uefpxEpfsGXuVYbRu3%2Fimage.png?alt=media&#x26;token=b9837a0c-6e01-4551-8394-6af534be3ab8" alt=""><figcaption></figcaption></figure>

* Step 2: Fill in the Name and Description of the campaign and then click Next.

<figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjD7QfQ9Dr736LmutDGT1%2Fuploads%2Fq3xBdEftBrx1PkudIcWq%2Fimage.png?alt=media&#x26;token=7554b002-3298-475c-8454-8ee2e8443c57" alt=""><figcaption></figcaption></figure>

* Step 3: Create a Filter, then click Next.

<figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjD7QfQ9Dr736LmutDGT1%2Fuploads%2F6fd35oi8NwxPiwDNpaJl%2Fimage.png?alt=media&#x26;token=21ba7833-a882-4e58-bac8-9ce550bd2954" alt=""><figcaption></figcaption></figure>

* Step 4.1: Configure for each user group.

<figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjD7QfQ9Dr736LmutDGT1%2Fuploads%2FLWUEnBdXgNOatg0g3w3c%2Fimage.png?alt=media&#x26;token=bca48a10-448a-4511-9709-da2c7648f255" alt=""><figcaption></figcaption></figure>

* Step 4.2: Change the weight for each user group, then click Next.

<figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjD7QfQ9Dr736LmutDGT1%2Fuploads%2FfMHYUkr0NR48ExvqJVNX%2Fimage.png?alt=media&#x26;token=c582b0cd-31b1-4af7-b3e4-c4b8b73424bc" alt=""><figcaption></figcaption></figure>

* Step 5: Review the information once more before clicking Create.

<figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjD7QfQ9Dr736LmutDGT1%2Fuploads%2F5RZ8OdZyuwV9kbYWbgdI%2Fimage.png?alt=media&#x26;token=d78e207b-a050-4f8a-b5d2-898c7e52a7be" alt=""><figcaption></figcaption></figure>

After completing the creation of the A/B Testing campaign, you must click Start to begin. Once you click Start, the value of the remote config variable will be pushed to the respective user groups.

<figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjD7QfQ9Dr736LmutDGT1%2Fuploads%2FfdWrc2sPGPs5fiKKAPdm%2Fimage.png?alt=media&#x26;token=b3d9ca23-7520-487f-95f5-04277c949f96" alt=""><figcaption></figcaption></figure>

After a period of monitoring the data, you will be able to determine which user group finds your A/B Testing campaign more effective. At this point, you may want to apply the remote config value of that user group to all of your users. -> Choose Apply for the user group you want to do this with.

<figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjD7QfQ9Dr736LmutDGT1%2Fuploads%2FpGPW482FQQNSfwm13zyL%2Fimage.png?alt=media&#x26;token=2edebe81-0858-4aa8-8173-fd9cddb918d7" alt=""><figcaption></figcaption></figure>
