跳转到内容

高级设置

广告位

您可以为每个广告单元设置广告位名称 (例如 “Rewarded VideoLevels”、“INTER_levelEnd” 或 “RewardedVideoCoinStore”)。 这可以帮助您汇总不同广告位类别的统计数据。 下面的片段展示了如何为不同的广告格式设置广告位名称。

MaxSdk.CreateBanner(«ad-unit-ID», «position»);
MaxSdk.SetBannerPlacement(«ad-unit-ID», "«placement»");

静音

您可以在启动应用时将某些 SDK 平台的音频设为关闭。 通过 AppLovin SDK 支持该功能的平台包括 Google 竞价和 Google AdMob、AppLovin、DT Exchange、Google Ad Manager、LINE、Mintegral、腾讯和 Verve。 对于其他平台,请咨询平台客户团队,了解此功能是否可用以及使用方法。

下面的代码片段展示了如何在支持静音的平台中设置静音:

MaxSdk.SetMuted(true);

启用详细日志

通过以下方式启用详细日志:

MaxSdk.SetVerboseLogging(true);

要验证是否已成功启用详细日志,请查看 AppLovin SDK 日志初始化部分中是否有 Verbose Logging On: true行。

AppLovin SDK
Version: 11.4.2
Verbose Logging On: true

AppLovin SDK 的日志标签为 “/AppLovinSdk: [AppLovinSdk]”。

Creative ID 和平台名称

您可以调取各个聚合平台已展示广告的 Creative ID 和平台名称。 请参阅 the Creative Debugger documentation 了解更多信息。

DSP 名称

您可以通过广告的 DspName 属性获取 AppLovin Exchange 投放的 MAX 广告的 DSP 名称:

private void OnInterstitialLoadedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
Debug.Log("AppLovin Exchange DSP Name: " + adInfo.DspName);
}

展示层级 User Revenue API

从 Unity 插件 4.3.0 版本开始,您可以在客户端访问展示级别的用户收入数据,并且使用此数据来比较不同的来源和 campaign。 您也可以使用 MAX 用户收入 API 访问此数据。

您可以针对所有受支持的平台与 Adjust 等移动监测合作伙伴分享展示层级广告收入数据。

您可以在所有广告生命周期回传中调取收入金额。 以下示例展示了如何在 “ad revenue paid” 回传中执行此操作:

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

您还可以获取收入值的精确度评估,如下所示:

string revenuePrecision = adInfo.RevenuePrecision;

该精确度采用下列值之一:

"publisher_defined"
收入金额为开发者指定的价格
"exact"
收入金额为实时竞价的结果
"estimated"
收入金额基于 Auto-CPM 或 FB 竞价估算
"undefined"
未定义收入金额,也没有足够的数据来估算
""
收入和精确度无效(例如在测试模式下)

选择性初始化

您可以针对指定广告单元初始化 SDK。 此时,SDK 只会初始化您为指定广告单元配置的广告平台。 (如果未指定任何广告单元,SDK 会假定当前会话需要您的所有广告单元。 此时,SDK 会初始化您为所有广告单元配置的全部平台。) 以下示例展示了如何实施此功能:

MaxSdkCallbacks.OnSdkInitializedEvent += (MaxSdkBase.SdkConfiguration config) => {
};
MaxSdk.InitializeSdk(new[]{"«ad-unit-ID-1»", "«ad-unit-ID-2»"});

Waterfall Information API

Waterfall Information API 可向您展示广告的当前瀑布流 (已加载或加载失败的广告)。 API 会返回瀑布流中每则广告的广告加载状态、延迟、配置信息和聚合平台信息。 如果瀑布流中的广告加载失败,API 会提供错误信息。

Unity 插件 4.3.13 及之后的版本支持该 API。

AdLoadState 值

解释
0未尝试加载广告
1广告已加载
2广告加载失败

示例

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);
}
}

输出

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]

自定义横幅 / MREC 广告刷新

您可以直接在集成中自定义横幅和 MREC 广告的刷新间隔,就像在广告单元 UI 中进行配置一样。 最短刷新间隔为 10 秒。 最长刷新间隔为 120 秒。 超出这些限制的值将被忽略。 以下代码示例展示了如何自定义刷新间隔:

MaxSdk.SetBannerExtraParameter(«ad-unit-ID», "ad_refresh_seconds", «ad-refresh-rate»)
MaxSdk.SetMRecExtraParameter(«ad-unit-ID», "ad_refresh_seconds", «ad-refresh-rate»)