Reducing ad frequency for engaged players


This document describes how to use a a sample game that illustrates:

  • How to display an ad to a player at the time that the player's character is eliminated ("dies").
  • How you can target engaged players.
  • How to change the frequency of engaged players they see. (An engaged player is a player who has played every day for the past seven days).

We’ll be working with a Unity project called “Platformer Microgame”, but this use case can be applied to any other game.


  • Unity 2019.4 and above
  • Unity Ads*
  • Authentication
  • Remote Config
  • Sign up to Unity Analytics Beta

Note: Unity Ads will not be covered for this example. However, you can call the ShowAd function within your premade class. See Unity advertising.


Here's an overview of the steps. Each step is described in more detail below.

  1. Install Authentication, Remote Config, and Analytics.
  2. Link your game to Analytics in the Unity Editor.
  3. Set up a Remote Config key with a default value.
  4. Retrieve values from Remote Config in your game.
  5. Decide when to show ads.
  6. Set up an Override to adjust your Remote Config key for an Audience.

Install Analytics, Authentication and Remote Config packages

Log in to the Unity Cloud Dashboard and find the packages (Analytics, Authentication, and Remote Config) required for this use case.

Download and install each  package. Add the package directly to your project’s PACKAGES folder. Open the manifest.json file and append the following to the dependencies:

"": "1.0.0-pre.4",
"": "3.0.0-pre.2",
"com.unity.remote-config": "3.0.0-pre.3"

In the Unity Editor, click Edit > Project Settings > Services. Choose the relevant project and link it. This will link your project to the Unity Cloud Dashboard.

Set up a Remote Config key

There are two ways of setting up a Remote Config key: from the Unity Cloud Dashboard or from the Editor.

In the Unity Cloud Dashboard, open Remote Config.

To add the config key that will be changed for engaged players:

  1. Click Add Key.
  2. Enter the key name adFrequency.
  3. Select the type Integer and enter a value of 1.
  4. Click Add.

This will be the default value for all players.

Alternatively, you can update these config values in the Unity Editor. Click Window in the menu bar, then Remote Config: it has a similar editing panel as the Unity Cloud Dashboard.

Setting up your game

Use the following code to fetch the adFrequency data from Remote Config. Attach this code to an empty object in the scene.

using Unity.RemoteConfig;
using Unity.Services.Authentication;
using Unity.Services.Core;
using UnityEngine;
public class UGS : MonoBehaviour
    public struct userAttributes { }
    public struct appAttributes { }
    public int adFrequency = 1; //Default is 1 ad on death
    async void Start()
        await UnityServices.InitializeAsync();
        // remote config requires authentication for managing environment information
        if (!AuthenticationService.Instance.IsSignedIn)
            await AuthenticationService.Instance.SignInAnonymouslyAsync();
        ConfigManager.FetchCompleted += ConfigManager_FetchCompleted;
        ConfigManager.FetchConfigs(new userAttributes(), new appAttributes());
    void ConfigManager_FetchCompleted(ConfigResponse configResponse)
        switch (configResponse.requestOrigin)
            case ConfigOrigin.Default:
                Debug.Log("Default values will be returned");
            case ConfigOrigin.Cached:
                Debug.Log("Cached values loaded");
            case ConfigOrigin.Remote:
                Debug.Log("Remote Values loaded");
                adFrequency = ConfigManager.appConfig.GetInt("adFrequency");

When the object loads it’ll initialize an anonymous user. You now have the config value of adFrequency from Remote Config.

For example, if the adFrequency value is changed to 3 then you want to show an ad every third time a player dies or fails the level.

The death logic counts the number of times a player dies. If the death count is equal to the frequency, the ad is displayed. If not, the ad won’t be displayed.

    if(ugs.adFrequency == countDeath)
        countDeath = 0;

Setting up an Override

The initial setup is complete after following the above steps.

Goal for this example: Create an Override to target engaged players, lowering adFrequency to show an ad on every third death. Non-engaged players will continue seeing an ad every time they die.

In the Unity Cloud Dashboard, open Game Overrides.

  1. Click Create Override.

  2. Enter a name for your Override then click Next.

  3. Click Audiences, select the pre-defined Audience “Engaged Players”, then click Next.

    1. Note: To enable Stateful Audiences ensure Unity Analytics is installed.
  4. Click Choose Content Type, select Config Overrides, and click Done.

  5. Select adFrequency from the Key Name dropdown, enter a value of 3, and click Next.

  6. Schedule the Override to run immediately, indefinitely, with a medium priority, and click Finish. You can adjust the priority to manage potential conflicts between Overrides.

  7. Check your changes and click Enable.

Your Override is now active and engaged players will receive an ad on every third death.

If you have any questions, open a support ticket.