Additional SDK settings for Unity

Define custom user segments and pass unique User IDs to tailor ad delivery and track user journeys across all mediation networks in Unity LevelPlay.

Read time 13 minutes

Set UserID

If you're using server-to-server callbacks to reward your users with ironSource SDK rewarded ad units, or using Ad Quality user journey, you must define a unique identifier for each user (“UserID”), using the setUserID method.

Set the UserID before the init request, to make sure you avoid any data losses, related to the user. Use a unique identifier, with up to 64 alphanumeric characters (String format for Android; NSString format for iOS).

IronSource.Agent.setUserId(YOUR_USER_ID);

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.

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

  • Device Properties: the ironSource 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

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 are familiar with the segment that the user belongs to, enter the segment name:

    IronSourceSegment segment = new IronSourceSegment ();
            segment.segmentName = "nameOfSegment";
    
    
  2. Send us the user details. ironSource 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 support user segment properties.

    // Create segment object
    IronSourceSegment segment = new IronSourceSegment ();
    // Set user age
    segment.age = age;
    // Set user gender
    segment.gender = "gender";
    // Set user's level
    segment.level = levelnumber;
    // Set user creation date
    segment.userCreationDate=creationData
    // Set user's total in-app purchases
    segment.iapt = numberOfInAppPurchases;
    // Set user's paying status, 1 is yes 0 is no
    segment.isPaying = payingStatus;
    

    In addition, you can set up to 5 custom user properties per segment:

    // Set custom parameters (up to 5)
    Dictionary<string,string> customParams = new Dictionary<string,string> ();
    customParams.Add ("customKey", "value");
    segment.customs = customParams;
           
    
    

Next, to serve your ad units based on segments, call the following function complete with either the segment name or user properties:

IronSource.Agent.setSegment (segment);

Supported User Segment Properties

Segment PropertiesTypeLimitationDescription
segmentNameString- alphanumeric - up to 32 lettersThe given name of the segment in your LevelPlay account
AgeInt1-99The user's age
GenderStringfemale or maleThe user's gender
PayingBooleanTrue or False- True if the user has spent any money on in-app purchases - False if the user has not spent any money on in-app purchases
iap_totalDouble1-999999.99The total amount of money that the user has spent on in-app purchases
userCreationDateLongCannot be smaller than 0

The date the user installed the app (for example: [NSDate date])

Custom Parameterskey=string, value=string- ironSource supports up to 5 custom parameters - alphanumeric - up to 32 lettersAny additional data you'd like to dispatch to our server

Register to the following callback to receive the segment name that your user belongs to. If the callback string (segment name) returns empty, there were no correlating segments found for the user in the ironSource Segment module.

 IronSourceEvents.onSegmentReceivedEvent += SegmentReceivedEvent;

Custom Parameters for Unity

The ironSource SDK supports custom parameters for Rewarded Video. You can pass custom parameters upon the initialization of the ad unit and receive the parameters upon a user's completion event. You can now pass custom parameters for all mediation networks on the LevelPlay mediation platform.

Implementation Code

Rewarded Video

IronSource.Agent.setRewardedVideoServerParams(Dictionary<string, string> parameters);
IronSource.Agent.clearRewardedVideoServerParams();

You will then receive a corresponding callback as exemplified below:

 http://www.mydomain.com/rewardsCallback?appUserId=\[USER\_ID\]&rewards=\[REWARDS\]&eventId=\[EVENT\_ID\]&itemName=\[ITEM\_NAME\]**&custom\_ip=1.0.0.9**

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 ironSource SDK, and as it affects all ads (Rewarded Video and Interstitial ads for Multiple AdUnit APIs) in the session.

LevelPlay.SetPauseGame(true);

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

LevelPlay.SetPauseGame(false);

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

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

// Deactivate the functionality in this session
IronSource.Agent.SetPauseGame(false);

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.

PropertyTypeDescription
Bid floordoubleThe price in USD that defines the minimum eCPM applied to traditional instances and bidders.

Interstitial ads example

// 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.

Rewarded ads example

// 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.

// 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.

ironSource SDK Error Codes

ironSource 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 ironSource Error object contains an error code and message. These are all the possible errors and their message based on their functions:

Error CodesAd UnitDescription
508N/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
509Interstitial, Rewarded VideoShow Fail: No ads to show
510Interstitial, Rewarded Video, BannerLoad Fail: Server response failed
520Interstitial, Rewarded Video

Show Fail: No internet connection; ShouldTrackNetworkState is enabled Show Fail: No internet connection

524Interstitial, Rewarded Video

Show Fail: Placement %@ has reached its limit as defined per pace Show Fail: Placement %@ has reached its capping limit

526Interstitial, Rewarded VideoShow Fail: Ad unit has reached its daily cap per session
604BannerCan’t load because the placement is capped
605BannerUnexpected exception while loading the banner
606BannerNo banner fill on all the networks on the first load
1007Interstitial, Rewarded VideoAuction Fail: Auction request did not contain all required information
1022Rewarded VideoShow Fail: Cannot show an RV while another RV is showing
1023Rewarded VideoShow Fail: Show RV called when there are no available ads to show
1035InterstitialEmpty Waterfall
1036InterstitialShow Fail: Cannot show an interstitial while another interstitial is showing
1037InterstitialLoad Fail: Cannot load an interstitial while another interstitial is showing
1039InterstitialException while calling show interstitial