# Advanced settings for Unity

> Configure advanced settings for Unity, including defining custom user segments and tracking user journeys across all mediation networks in Unity LevelPlay.

## Define Segments

You can now easily tailor the way you serve your ads to fit a specific audience! You'll need to inform our servers of the users' details so the SDK will know to serve ads according to the segment the user belongs to.

LevelPlay SDK supports three methods to convey data to our servers to outline the user segment, namely:

* **Device Properties**: the LevelPlay SDK collects certain standard parameters that pertain to the users' device automatically such as device model, device manufacturer, app version, and OS. You do not need to convey this data to us
* **User Properties**: user data which is not collected by our SDK (for example, age, gender, or creation date) must be relayed through the API. (See a full list of supported segment properties with descriptions in the following section). Follow the instructions to send us these details so our SDK can apply the relevant ad settings to the segments you defined on the LevelPlay platform
* **Custom Segments**: you can create a custom segment without conveying user details to our servers and tailor ad settings for that user segment

> **Note:**
>
> **Dynamic Segmentation:** If you're using LevelPlay SDK 7.2.0, you can use LevelPlaySegment API to change your segmentation during the session. This will affect the next loaded ad, and can be called before loading each ad unit, to dynamically affect the waterfall. You can learn more about LevelPlay segmentation [here](/grow/levelplay/platform/settings/segments.md).

### Pass User Properties

After you've defined segments on the LevelPlay platform, you'll need to inform our servers of the user's particulars.

Define what properties to send to our servers on which to base the segments. You can transmit this information through **one** of the following methods:

1. If you know which segment the user belongs to, create a new segment and set its name:

   ```cs
   var segment = new LevelPlaySegment();
   segment.SegmentName = "nameOfSegment";
   ```

2. Otherwise, send us the user details. LevelPlay provides a range of standard user properties that you can set to attribute a user to a segment in the API. Scroll down for a table of the supported user segment properties.

   ```cs
   var segment = new LevelPlaySegment();
   segment.Level = 5;
   segment.UserCreationDate = 1758100075134;
   segment.IapTotal = 100;
   segment.IsPaying = 1;
   ```

   You can also set up to 5 custom user properties per segment:

   ```cs
   var key = "key1";
   var val = "value1";

   var segment = new LevelPlaySegment();
   segment.SetCustom(key, val);
   ```

   Finally, call the following function, passing the newly created segment to it:

   ```cs
   LevelPlay.SetSegment(segment);
   ```

### Supported User Segment Properties

| **Segment Properties** | **Type**                 | **Limitation**                                                             | **Description**                                                                                                 |
| ---------------------- | ------------------------ | -------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| SegmentName            | String                   | alphanumeric up to 32 letters                                              | The given name of the segment in your LevelPlay account                                                         |
| IsPaying               | Int                      | 0 or 1                                                                     | 1 if the user has spent any money on in-app purchases 0 if the user has not spent any money on in-app purchases |
| IapTotal               | Double                   | 1-999999.99                                                                | The total amount of money that the user has spent on in-app purchases                                           |
| UserCreationDate       | Long                     | Cannot be smaller than 0                                                   | The date the user installed the app, e.g. DateTimeOffset.UtcNow\.ToUnixTimeMilliseconds()                       |
| Custom Parameters      | key=string, value=string | LevelPlay supports up to 5 custom parameters alphanumeric up to 32 letters | Any additional data you'd like to dispatch to our server                                                        |

## Custom Parameters for Rewarded server to server callbacks

LevelPlay reward-based ad units support server-side events to notify you of rewards that must be granted to your users after successful ad completion events. You can learn more [here](/grow/levelplay/platform/settings/server-to-server-callback.md).

In addition to the server params, you can share run-time custom parameters through the client. To implement this, simply pass custom parameters to LevelPlay\_Rewarded\_Server\_Params using the setMetadata API. Custom parameters can be updated several times throughout a session overriding previous values.

To reset the custom parameters, set LevelPlay\_Rewarded\_Server\_Params to an empty array.

### Example implementation Code

> **Note:**
>
> Min LevelPlay SDK 8.11.0

```cs
LevelPlay.SetMetaData("LevelPlay_Rewarded_Server_Params", new [] { "key1=value1", "key2=value2" });
```

You will then receive a corresponding callback as exemplified below:

```text
http://www.mydomain.com/rewardsCallback?appUserId=[USER_ID]&rewards=[REWARDS]&eventId=[EVENT_ID]&itemName=[ITEM_NAME]&custom_key1=value1&custom_key2=value2
```

## Pause Game

The API SetPauseGame is introduced into the LevelPlay class as part of the LevelPlay SDK version 8.5.0 and is relevant for iOS apps only.

When setting your PauseGame status to "true", all your Unity 3D game activities will be paused (except the ad callbacks). The game activity will be resumed automatically when the ad is closed.

You should call the SetPauseGame API once in your session, before or after initializing the LevelPlay SDK, and as it affects all ads (Rewarded Video and Interstitial ads for Multiple AdUnit APIs) in the session.

```cs
LevelPlay.SetPauseGame(true);
```

You can deactivate the functionality in this session, by calling the SetPauseGame with the value false:

```cs
LevelPlay.SetPauseGame(false);
```

For legacy LevelPlay SDK (from 7.2.4 until 8.4.0), use the following API:

```cs
// Pause all game activities except ad callbacks. The game activity will be resumed automatically when the ad is closed
LevelPlay.SetPauseGame(true);

// Deactivate the functionality in this session
LevelPlay.SetPauseGame(false);
```

## Price Floor Configuration##price-floor-configuration

The Floor Configuration API lets you set a price floor for a specific ad unit. By setting a price floor for each user, you can improve targeting efficiency, reduce latency, and optimize ad performance.

The price floor must be assigned when creating the ad object, and it applies to all subsequent loads for that object.

> **Note:**
>
> Min LevelPlay package 8.9.0

| **Property** | **Type** | **Description**                                                                              |
| ------------ | -------- | -------------------------------------------------------------------------------------------- |
| Bid floor    | double   | The price in USD that defines the minimum eCPM applied to traditional instances and bidders. |

### Interstitial ads example

```cs
// Define a price floor configuration
var adConfig = new LevelPlayInterstitialAd.Config.Builder()
   .SetBidFloor(1.23) // Set the price floor in USD
   .Build()
// Apply the configuration to an interstitial ad unit
var interstitialAd = new LevelPlayInterstitialAd("adUnitId", adConfig);
```

Full interstitial implementation is available [here](/grow/levelplay/sdk/unity/interstitial-integration.md).

### Rewarded ads example

```cs
// Define a price floor configuration
var adConfig = new LevelPlayRewardedAd.Config.Builder()
   .SetBidFloor(1.23) // Set the price floor in USD
   .Build()
// Apply the configuration to a rewarded ad unit
var rewardedAd = new LevelPlayRewardedAd("adUnitId", adConfig);
```

Full rewarded ads implementation is available [here](/grow/levelplay/sdk/unity/rewarded-ad-integration-package.md).

#### Banner ads example

```cs
// Define a price floor configuration
var adConfig = new LevelPlayBannerAd.Config.Builder()
   .SetBidFloor(1.23) // Set the price floor in USD
   .Build();
// Apply the configuration to a banner ad unit
var bannerAd = new LevelPlayBannerAd("adUnitId", adConfig);

```

Full banner ads implementation is available [here](/grow/levelplay/sdk/unity/banner-integration.md).

## LevelPlay SDK Error Codes

LevelPlay provides an error feedback mechanism to provide explanation for any failure in the SDK integration. You will receive these errors when something went wrong or an aspect of the integration wasn't completed correctly.

The LevelPlay Error object contains an **error code** and **message**. These are all the possible errors and their message based on their functions:

| Error Codes | Ad Unit                              | Description                                                                                                                                     |
| ----------- | ------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| 508         | N/A                                  | * Init failure of the mediation/Network
* Calling a Demand Only API in non Demand Only mode
* Calling a non Demand Only API in Demand Only mode |
| 509         | Interstitial, Rewarded Video         | **Show Fail**: No ads to show                                                                                                                   |
| 510         | Interstitial, Rewarded Video, Banner | **Load Fail**: Server response failed                                                                                                           |
| 520         | Interstitial, Rewarded Video         | **Show Fail**: No internet connection; ShouldTrackNetworkState is enabled&#xA;**Show Fail**: No internet connection                             |
| 524         | Interstitial, Rewarded Video         | **Show Fail**: Placement %@ has reached its limit as defined per pace&#xA;**Show Fail**: Placement %@ has reached its capping limit             |
| 526         | Interstitial, Rewarded Video         | **Show Fail**: Ad unit has reached its daily cap per session                                                                                    |
| 604         | Banner                               | Can’t load because the placement is capped                                                                                                      |
| 605         | Banner                               | Unexpected exception while loading the banner                                                                                                   |
| 606         | Banner                               | No banner fill on all the networks on the first load                                                                                            |
| 1007        | Interstitial, Rewarded Video         | **Auction Fail**: Auction request did not contain all required information                                                                      |
| 1022        | Rewarded Video                       | **Show Fail**: Cannot show an RV while another RV is showing                                                                                    |
| 1023        | Rewarded Video                       | **Show Fail**: Show RV called when there are no available ads to show                                                                           |
| 1035        | Interstitial                         | **Empty Waterfall**                                                                                                                             |
| 1036        | Interstitial                         | **Show Fail**: Cannot show an interstitial while another interstitial is showing                                                                |
| 1037        | Interstitial                         | **Load Fail**: Cannot load an interstitial while another interstitial is showing                                                                |
| 1039        | Interstitial                         | Exception while calling show interstitial                                                                                                       |
