Ad Placements
You can set a placement name for each ad unit (for example, “Rewarded VideoLevels”, “INTER_levelEnd”, or “RewardedVideoCoinStore”). This can help you aggregate statistics for different placement categories. Below are code snippets that show how you set the placement name for various ad formats. Note that for banners and MRECs you must set the placement name immediately after you create the banner or MREC.
-
MaxSdk.CreateBanner(ad_unit_id, position); MaxSdk.SetBannerPlacement(ad_unit_id, "placement");
-
MaxSdk.CreateMRec(ad_unit_id, position); MaxSdk.SetMRecPlacement(ad_unit_id, "placement");
-
MaxSdk.ShowInterstitial(ad_unit_id, "placement");
-
MaxSdk.ShowRewardedAd(ad_unit_id, "placement");
Mute Audio
You can mute audio for certain mediated SDK networks when you launch your app. The networks that support this functionality via the AppLovin SDK are Google bidding and Google AdMob, AppLovin, DT Exchange, Google Ad Manager, LINE, Mintegral, Tencent, and Verve. For other networks, consult your network’s account team to learn whether this functionality is available and how to access it. The following code snippet shows how you mute audio on the supported networks:
MaxSdk.setMuted(true); // to mute MaxSdk.setMuted(false); // to unmute
Set the mute state before you load ads. Some networks (like Google bidding and Google AdMob) return muted or unmuted videos depending on what the mute state is before ad load.
Enable Verbose Logging
Enable verbose logs with the following call:
MaxSdk.SetVerboseLogging(true);
To verify that you enabled verbose logs successfully you can check for the line that reads Verbose Logging On: true in the initialization section of the AppLovin SDK logs:
AppLovin SDK Version: 11.4.2 ⋮ Verbose Logging On: true ⋮
AppLovin SDK tags its logs with the tag /AppLovinSdk: [AppLovinSdk].
Segment Name
You can compartmentalize your users into “segments.” This can help you analyze users with particular characteristics, or can be helpful as a part of A/B testing. Each segment has a name of your choice, in the form of a string of 32 or fewer alphanumeric characters. You can set or retrieve the segment name of the current user from the AppLovin SDK by means of the UserSegment
property:
MaxSdk.UserSegment.Name = "mysegmentname"
Creative ID and Network Name
You can retrieve the creative ID and the network name of displayed ads of various mediated networks. Refer to the Creative Debugger documentation for more information.
DSP Name
You can retrieve the name of the DSP for a MAX ad served from AppLovin Exchange via the ad’s DspName
property:
private void OnInterstitialLoadedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo) { Debug.Log("AppLovin Exchange DSP Name: " + adInfo.DspName); }
Impression-Level User Revenue API
Starting in Unity Plugin 4.3.0, you can access impression-level user revenue data on the client side. You can use this data to compare different sources and campaigns. You can also access this data by using the MAX User Revenue API.
You can share impression-level ad revenue data with your mobile measurement partner of choice, such as Adjust for all supported networks.
You can retrieve the revenue amount in all ad lifecycle callbacks. The following example shows how to do this within the “ad revenue paid” callback:
// Attach callbacks based on the ad format(s) you are using MaxSdkCallbacks.Interstitial.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent; MaxSdkCallbacks.Rewarded.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent; MaxSdkCallbacks.Banner.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent; MaxSdkCallbacks.MRec.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent; ⋮ private void OnAdRevenuePaidEvent(string adUnitId, MaxSdkBase.AdInfo adInfo) { double revenue = adInfo.Revenue; // Miscellaneous data string countryCode = MaxSdk.GetSdkConfiguration().CountryCode; // "US" for the United States, etc - Note: Do not confuse this with currency code which is "USD" string networkName = adInfo.NetworkName; // Display name of the network that showed the ad (e.g. "AdColony") string adUnitIdentifier = adInfo.AdUnitIdentifier; // The MAX Ad Unit ID string placement = adInfo.Placement; // The placement this ad's postbacks are tied to string networkPlacement = adInfo.NetworkPlacement; // The placement ID from the network that showed the ad }
The value of Revenue
may be -1
in the case of an error.
You can also retrieve a precision evaluation for the revenue value, as shown in the following example:
string revenuePrecision = adInfo.RevenuePrecision;
This precision is one of the following values:
- publisher_defined
- revenue is the price assigned by the publisher
- exact
- revenue is the resulting price of a real-time auction
- estimated
- the revenue amount is based on Auto CPM or FB Bidding estimates
- undefined
- no revenue amount is defined and there is not enough data to estimate
Selective Init
Starting in SDK version 10.0.0, you can initialize the SDK with specific ad units. If you do so, the SDK only initializes those networks that you have configured for the ad units you specify. If you do not specify any ad units, the SDK assumes the current session needs all of your ad units and so it initializes all networks that you have configured for them. The following example shows how you implement this feature:
MaxSdkCallbacks.OnSdkInitializedEvent += (MaxSdkBase.SdkConfiguration config) => { ⋮ }; MaxSdk.InitializeSdk(new[]{"ad_unit_id_1", "ad_unit_id_2"});
Waterfall Information API
This feature allows you to see the information about the current waterfall for an ad that has loaded or failed to load. The network responses provide the ad load state, latency, credentials, and mediated network information for each ad in the waterfall. If an ad in the waterfall fails to load, the network response provides error information. This API is supported as of Unity plugin version 4.3.13.
AdLoadState Values
0 | Ad Load Not Attempted |
1 | Ad Loaded |
2 | Ad Failed To Load |
Example
private void OnInterstitialLoadedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo) { print("Waterfall Name: " + adInfo.WaterfallInfo.Name + " and Test Name: " + adInfo.WaterfallInfo.TestName); print("Waterfall latency was: " + adInfo.WaterfallInfo.LatencyMillis + " milliseconds"); string waterfallInfoStr = ""; foreach (var networkResponse in adInfo.WaterfallInfo.NetworkResponses) { waterfallInfoStr = "Network -> " + networkResponse.MediatedNetwork + "\n...adLoadState: " + networkResponse.AdLoadState + "\n...latency: " + networkResponse.LatencyMillis + " milliseconds" + "\n...credentials: " + networkResponse.Credentials; if(networkResponse.Error != null) { waterfallInfoStr += "\n...error: " + networkResponse.Error; } } print(waterfallInfoStr); } private void OnInterstitialLoadFailedEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo) { print("Waterfall Name: " + errorInfo.WaterfallInfo.Name + " and Test Name: " + errorInfo.WaterfallInfo.TestName); print("Waterfall latency was: " + errorInfo.WaterfallInfo.LatencyMillis + " milliseconds"); foreach (var networkResponse in errorInfo.WaterfallInfo.NetworkResponses) { print("Network -> " + networkResponse.MediatedNetwork + "\n...latency: " + networkResponse.LatencyMillis + " milliseconds" + "\n...credentials: " + networkResponse.Credentials + "\n...error: " + networkResponse.Error); } }
Output
Waterfall Name: Default Waterfall and Test Name: Control Waterfall latency was: 10176 milliseconds Network -> [MediatedNetworkInfo name: Fyber, adapterClassName: ALInnteractiveMediationAdapter, adapterVersion: 8.1.1.0, sdkVersion: 8.1.1.0] ...latency: 1542 milliseconds ...credentials: System.Collections.Generic.Dictionary`2[System.String,System.Object] ...error: [ErrorInfo code: -5200, message: Unspecified Error, adLoadFailure: Load failed - Failed to load Interstitial ad] Network -> [MediatedNetworkInfo name: AppLovin, adapterClassName: ALAppLovinMediationAdapter, adapterVersion: 10.3.7, sdkVersion: 10.3.7] ...adLoadState: AdLoaded ...latency: 245 milliseconds ...credentials: System.Collections.Generic.Dictionary`2[System.String,System.Object] Network -> [MediatedNetworkInfo name: AdColony, adapterClassName: ALAdColonyMediationAdapter, adapterVersion: 4.7.2.0.0, sdkVersion: 4.7.2.0] ...adLoadState: AdLoadNotAttempted ...latency: -1000 milliseconds ...credentials: System.Collections.Generic.Dictionary`2[System.String,System.Object]
Customize Banner / MREC Ad Refresh
You can customize banner and MREC ad refresh intervals directly in your integration, just as you can configure them in the Ad Unit UI. The minimum and maximum refresh intervals allowed are 10 seconds and 120 seconds, respectively. Values outside of these limits are ignored. The following code sample shows you how to customize these refresh intervals:
MaxSdk.SetBannerExtraParameter(ad_unit_id, "ad_refresh_seconds", ad refresh rate) MaxSdk.SetMRecExtraParameter(ad_unit_id, "ad_refresh_seconds", ad refresh rate)