高级设置

广告位

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

横幅 / MREC

对于横幅和 MREC,您必须在加载横幅或 MREC 之前设置广告位名称。

adView.setPlacement( "«placement»" );
adView.loadAd();

插屏

interstitial.showAd( "«placement»" );

激励广告

rewardedAd.showAd( "«placement»" );

原生广告

nativeAdLoader.setPlacement( "«placement»" );

原生广告 (Ad Placer)

MaxAdPlacerSettings settings = new MaxAdPlacerSettings( "«ad-unit-ID»" );
settings.setPlacement( "«placement»" );

静音

您可以在启动应用时将某些聚合 SDK 平台的音频设为静音。 通过 AppLovin SDK 支持此功能的平台如下:

  • AppLovin
  • Bigo (仅限原生广告)
  • DT Exchange
  • Google Ad Manager
  • Google 竞价 and Google AdMob.
  • LINE
  • Mintegral

对于其他平台,请咨询平台客户团队,了解此功能是否可用以及如何访问。

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

AppLovinSdk sdk = AppLovinSdk.getInstance( context );
sdk.getSettings().setMuted( true );  // to mute
sdk.getSettings().setMuted( false ); // to unmute

在加载广告之前设置静音状态。 有些平台 (如 Google 竞价和 Google AdMob) 会基于广告加载前的静音状态返回静音或未静音的视频。

注意:静音广告可能会导致广告收入下降。

启用详细日志

在 SDK 设置对象中设置布尔标记,以启用详细日志:

通过编程方式

AppLovinSdk.getInstance( context ).getSettings().setVerboseLogging( true );

Android Manifest

您还可以编辑应用程序的 Android Manifest 文件,以启用详细日志。 为此,请按照下列方式添加 <meta-data> 元素:

<application>
⋮
  <meta-data android:name="applovin.sdk.verbose_logging" android:value="true" />
⋮
</application>

验证

要验证是否已成功启用详细日志,请查看 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 名称

要调取 AppLovin Exchange 投放的 MAX 广告的 DSP 名称,请调用广告的 getDspName() 方法:

@Override
public void onAdLoaded(final MaxAd ad)
{
  System.out.println( "AppLovin Exchange DSP name: " + ad.getDspName() );
}

展示层级用户收入 API

您可以在客户端访问展示级别的用户收入数据,并且使用此数据来比较不同的来源和 campaign。 您也可以使用 MAX 用户收入 API 访问此数据。需要访问此数据的 MMP,请参阅针对 MMP 的展示层级用户收入 API 文档。

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

您可以在所有广告生命周期回传中调取收入金额。 为此,请创建一个 MaxAdRevenueListener,安装它的 onAdRevenuePaid() 方法,然后将该监听器传递至 setRevenueListener()。 以下示例展示了如何在 "ad revenue paid" 回传中执行此操作:

@Override
void onAdRevenuePaid(final MaxAd ad)
{
  double revenue = ad.getRevenue(); // In USD

  // Miscellaneous data
  String countryCode = AppLovinSdk.getInstance( context ).getConfiguration().getCountryCode(); // "US" for the United States, etc - Note: Do not confuse this with currency code which is "USD"
  String networkName = ad.getNetworkName(); // Display name of the network that showed the ad
  String adUnitId = ad.getAdUnitId(); // The MAX Ad Unit ID
  MaxAdFormat adFormat = ad.getFormat(); // The ad format of the ad (e.g. BANNER, MREC, INTERSTITIAL, REWARDED)
  String placement = ad.getPlacement(); // The placement this ad's postbacks are tied to
  String networkPlacement = ad.getNetworkPlacement(); // The placement ID from the network that showed the ad
}

出现错误时,ad.getRevenue()/ad.revenue 的值可能为 -1

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

String revenuePrecision = ad.getRevenuePrecision();

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

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

建立广告请求回传

To listen for an ad request, set a MaxAdRequestListener, implement its onAdRequestStarted() method, and pass that listener to setRequestListener(). The following example shows how to implement such an “ad request started” callback:

@Override
public void onAdRequestStarted(final String adUnitId)
{
  // Ad request started here
}

选择性初始化

You can initialize the SDK with specific ad units by specifying your ad units in the AppLovinSdkInitializationConfiguration. If you do so, the SDK only initializes those networks that you configured for the ad units you specify. If you do not specify any ad units, the SDK assumes the current session needs all your ad units. In such a case it initializes all networks that you configured for those ad units. The following example shows how you implement this feature:

AppLovinSdkInitializationConfiguration.Builder initConfigBuilder = AppLovinSdkInitializationConfiguration.builder( «your-SDK-key» );
initConfigBuilder.setMediationProvider( AppLovinMediationProvider.MAX );
List<String> adUnitIds = new ArrayList<>();
adUnitIds.add( "«ad-unit-ID-1»" );
adUnitIds.add( "«ad-unit-ID-2»" );
initConfigBuilder.setAdUnitIds( adUnitIds );

AppLovinSdk.getInstance( this ).initialize( initConfig, new AppLovinSdk.SdkInitializationListener()
  {
    @Override
    public void onSdkInitialized(final AppLovinSdkConfiguration sdkConfig)
    {
      ⋮
    }
  } );

您可以在 AppLovin 控制面板的 Account > General > Keys 部分找到 SDK Key。

When you use selective init, MAX excludes any ad units that you do not explicitly specify from serving ads for the current session.

Selective init has no effect when you enable Test Mode.

Waterfall Information API

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

AdLoadState 值

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

示例

@Override
public void onAdLoaded(final MaxAd ad)
{
  MaxAdWaterfallInfo waterfall = ad.getWaterfall();
  if ( waterfall == null ) return;
  System.out.println( "Waterfall Name: " + waterfall.getName() + " and Test Name: " + waterfall.getTestName() );
  System.out.println( "Waterfall latency was: " + waterfall.getLatencyMillis() + " milliseconds" );

  String waterfallInfoStr;
  for ( MaxNetworkResponseInfo networkResponse : waterfall.getNetworkResponses() )
  {
    waterfallInfoStr = "Network -> " + networkResponse.getMediatedNetwork() +
            "\n...adLoadState: " + networkResponse.getAdLoadState() +
            "\n...latency: " + networkResponse.getLatencyMillis() + " milliseconds" +
            "\n...credentials: " + networkResponse.getCredentials();
    if ( networkResponse.getError() != null )
    {
      waterfallInfoStr += "\n...error: " + networkResponse.getError();
    }
    System.out.println( waterfallInfoStr );
  }
}

@Override
public void onAdLoadFailed(final String adUnitId, final MaxError error)
{
  MaxAdWaterfallInfo waterfall = error.getWaterfall();
  if ( waterfall == null ) return;
  System.out.println( "Waterfall Name: " + waterfall.getName() + " and Test Name: " + waterfall.getTestName() );
  System.out.println( "Waterfall latency was: " + waterfall.getLatencyMillis() + " milliseconds" );

  for ( MaxNetworkResponseInfo networkResponse : waterfall.getNetworkResponses() )
  {
    System.out.println( "Network -> " + networkResponse.getMediatedNetwork() +
                        "...latency: " + networkResponse.getLatencyMillis() +
                        "...credentials: " + networkResponse.getCredentials() + " milliseconds" +
                        "...error: " + networkResponse.getError() );
  }
}

If the waterfall is empty, MaxError.getWaterfall() returns null. If so, you cannot interrogate the waterfall properties. However, you can retrieve the ad load latency for an empty waterfall by calling the getRequestLatencyMillis() method:

@Override
public void onAdLoaded(final MaxAd ad)
{
  System.out.println("Successful ad load latency: " + ad.getRequestLatencyMillis() + " ms");
}

@Override
public void onAdLoadFailed(final String adUnitId, final MaxError error)
{
  System.out.println("Failed ad load latency: " + error.getRequestLatencyMillis() + " ms");
}

自定义横幅 / MREC 广告刷新

You can customize banner and MREC ad refresh intervals via the API, 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. MAX ignores values outside these limits. The following code samples show you how to customize these refresh intervals:

// Where adView is an instance of MaxAdView
adView.setExtraParameter( "ad_refresh_seconds", «ad-refresh-rate» );

这篇文章有帮助吗?
这篇文章有帮助吗?
search