MMP向けのインプレッションレベルのユーザー収益API
このAPIは、パブリッシャー - サブスクライバーアーキテクチャを使用しています。
MAX SDKはMAXの広告収益イベントをブロードキャストし、MMPはmax_revenue_events
トピックをサブスクライブします。
AppLovinは、アプリの起動後、すぐにそのトピックをサブスクライブすることを推奨しています。
これにより、イベントを見逃すことがなくなります。
各ブロードキャストイベントには、以下のパラメーターが含まれます。
名 | 説明 | 例 |
---|---|---|
ad_format | 広告の広告フォーマット | BANNER , MREC , INTER , REWARDED |
country_code | 収益の国コード | US (アメリカ合衆国の場合) |
id | サーバーの一意の内部ID。 | 19017d954ffcded6c42772b09ec36699efe0bfc2 |
max_ad_unit_id | MAX広告ユニットID。 | 65d8d0195e50bda6 |
network_name | 広告を表示するネットワークの表示名。 | AppLovin |
revenue | 収益額を表す倍精度浮動小数点数。 | 0.002067201 |
third_party_ad_placement_id | 広告のプレースメントID(該当する場合)。ただし、入札広告にはプレースメントIDがない場合があります。 | inter_regular |
user_segment | 広告を表示するユーザーのユーザーセグメント。 | experiment5 |
次の例は、SDKがブロードキャストするイベントをサブスクライブして処理する方法を示しています。
package «your.package.name»;
import android.app.Activity;import android.os.Bundle;
import com.applovin.communicator.AppLovinCommunicator;import com.applovin.communicator.AppLovinCommunicatorMessage;import com.applovin.communicator.AppLovinCommunicatorSubscriber;
import androidx.annotation.Nullable;
public class ExampleActivity extends Activity implements AppLovinCommunicatorSubscriber{ @Override protected void onCreate(@Nullable final Bundle savedInstanceState) { super.onCreate( savedInstanceState );
AppLovinCommunicator.getInstance( getApplicationContext() ).subscribe( this, "max_revenue_events" ); }
@Override protected void onDestroy() { // Unsubscribe when subscription is no longer needed AppLovinCommunicator.getInstance( getApplicationContext() ).unsubscribe( this, "max_revenue_events" );
super.onDestroy(); }
@Override public void onMessageReceived(final AppLovinCommunicatorMessage message) { // If you are subscribed to multiple topics, check for the desired one if ( "max_revenue_events".equals( message.getTopic() ) ) { Bundle data = message.getMessageData(); double revenue = data.getDouble( "revenue" );
// Miscellaneous data String countryCode = data.getString( "country_code" ); // "US" for the United States, etc - Note: Do not confuse this with currency code which is "USD" String networkName = data.getString( "network_name" ); // Display name of the network which showed the ad String adUnitId = data.getString( "max_ad_unit_id" ); // The MAX Ad Unit ID String thirdPartyAdPlacementId = data.getString( "third_party_ad_placement_id" ); // The ad's placement id, if any (bidding may not have one) String adFormat = data.getString( "ad_format" ); // The ad format of the ad (e.g. "BANNER", "MREC", "INTER", "REWARDED", "REWARDED_INTER") } }
@Override public String getCommunicatorId() { return "«your_company_name_in_snake_case»"; }}
package «your.package.name»
import android.app.Activityimport android.os.Bundleimport com.applovin.communicator.AppLovinCommunicatorimport com.applovin.communicator.AppLovinCommunicatorMessageimport com.applovin.communicator.AppLovinCommunicatorSubscriber
class ExampleActivity : Activity(), AppLovinCommunicatorSubscriber{ override fun onCreate(savedInstanceState: Bundle?) { super.onCreate( savedInstanceState )
AppLovinCommunicator.getInstance( applicationContext ).subscribe( this, "max_revenue_events" ) }
override fun onDestroy() { // Unsubscribe when subscription is no longer needed AppLovinCommunicator.getInstance( applicationContext ).unsubscribe( this, "max_revenue_events" )
super.onDestroy() }
override fun onMessageReceived(message: AppLovinCommunicatorMessage) { // In the case that you are subscribed to multiple topics, check for the desired one if ( "max_revenue_events" == message.topic ) { val data: Bundle = message.messageData val revenue = data.getDouble( "revenue" )
// Miscellaneous data val countryCode = data.getString( "country_code" ) // "US" for the United States, etc - Note: Do not confuse this with currency code which is "USD" val networkName = data.getString( "network_name" ) // Display name of the network which showed the ad val adUnitId = data.getString( "max_ad_unit_id" ) // The MAX Ad Unit ID val thirdPartyAdPlacementId = data.getString( "third_party_ad_placement_id" ) // The ad's placement id, if any (bidding may not have one) val adFormat = data.getString( "ad_format" ) // The ad format of the ad (e.g. "BANNER", "MREC", "INTER", "REWARDED") } }
override fun getCommunicatorId(): String { return "«your_company_name_in_snake_case»" }}