Skip to main content

Remote Configurations

Setup Remote Configurations

GameAnalytics' Remote Configurations feature offers the ability to set up and tune values in your game's dashboard.
These values can be changed on the whim without needing to release a new version of the game.
The remote configs are a custom set of key-pair values. Set up your Remote Configurations in the GameAnalytics dashboard.

Check Remote Config Updates in Unity

To monitor updates to Remote Configs, subscribe to the OnRemoteConfigsUpdatedEvent:

using UnityEngine;

public class RemoteConfigsHandler : MonoBehaviour
{
private void OnEnable()
{
// Subscribe to the event
GameAnalytics.OnRemoteConfigsUpdatedEvent += OnRemoteConfigsUpdated;
}

private void OnDisable()
{
// Unsubscribe to prevent memory leaks
GameAnalytics.OnRemoteConfigsUpdatedEvent -= OnRemoteConfigsUpdated;
}

private void OnRemoteConfigsUpdated()
{
// Add your logic here
Debug.Log("Remote Configs updated!");
}
}

To manually verify if the Remote Configs have been initialized, use the GameAnalytics.IsRemoteConfigsReady():

if(GameAnalytics.IsRemoteConfigsReady())
{
// the remote configs is ready, add your code here
}
caution

Remember the remote configs can be populated with an empty dictionary if the device is offline and there are no cached remote configs from a previous session.


Retrieve Remote Config Values

After you have checked if the configs have been populated you can use the following methods to retrive their values:

// Without custom default value (using normal default value)
string value = GameAnalytics.GetRemoteConfigsValueAsString("key");
// With custom default value
string valueWithCustomDefaultValue = GameAnalytics.GetRemoteConfigsValueAsString("key", "myDefaultValue");
info

If the specified key is not found in the Remote Configs it will return the default value either “normal” or “custom” default value.