広告収益アトリビューションについて
広告収益アトリビューションは、ユーザーをアプリに導いた特定のキャンペーンと広告収益を結びつけるのに役立ちます。これにより、キャンペーンコスト、アプリ内収益、広告収益のすべてを一度に表示することで、広告のパフォーマンスを明確に把握できます。また、この機能により、広告収益データを広告ネットワークに送信し、広告パフォーマンスを改善することができます。
キーポイント
- 機能:広告収益アトリビューションは、モバイルアプリの広告収益を、アプリのユーザーを生み出したマーケティングキャンペーンに結び付けます。こうすることで、各キャンペーンからどれだけの収益を得たか、そしてそれが全体的な広告ROIにどのように影響するかを確認することができます。
- データソース:このデータは通常メディエーションプラットフォームから取得し、ユーザーレベルまたはインプレッションレベルとなります。Singularはこのアトリビューションデータを取得する様々な方法をサポートしています。
- もっと読む詳細については、Singularの広告収益アトリビューションに関するFAQとトラブルシューティングをご覧ください。
重要な注意事項
- 通貨コード:3文字のISO 4217通貨コードを使用してください(例:米ドルは "USD"、ユーロは "EUR"、インドルピーは "INR")。多くのメディエーション・プラットフォームは "USD "を使用しているので、それを使用している場合は、コードがこれと一致していることを確認してください。異なる通貨を使用する場合は、バリデーションコードを適宜更新してください。
- データの正確性:Singularにデータを送信する前に、収益と通貨のデータが正しいことを必ず確認してください。不正確なデータは後で修正できないため、正確であることを確認することは非常に重要です。
広告収益アトリビューションの実装
- SDKをアップデートします:Singular SDKが最新バージョンであることを確認してください。
- コードスニペットを追加します:お使いのメディエーションプラットフォームに応じて、Singular SDKのセットアップに適切なコードスニペットを追加します。
これらのステップに従うことで、広告収益アトリビューションを正しく設定し、広告データを最大限に活用することができます。
パートナーの注意事項
- この機能はAdMobアカウントで有効にする必要があります。
AdMobサポートを参照してください。
-
広告フォーマット("App Open"、"Banner"、"Interstitial"、"Native"、"Rewarded "など)を読み込む際に、広告が収益を生成するたびにトリガーされるコールバック関数としてpaidEventHandlerを設定します。Google Mobile Ads SDKは、インプレッションイベントをトラッキングし、広告が発生した収益でこのハンドラを呼び出します。
これを行うには、広告フォーマットの"load"関数を変更し、paidEventHandlerを含めます。このコールバック内で広告収益データを管理し、検証し、Singular.adRevenue関数を使ってSingularに送信します。
例えば、"報酬付き広告" が正常にロードされると、paidEventHandler は広告の収益情報(adValue)を受け取ります。この関数で収益データを処理し、Singularに送信します。
詳細については、AdMob のドキュメントを参照してください。
重要:AdMob SDKはプラットフォームによって異なる収益を報告します。例えば、$0.005の広告収益はUnityとAndroidプラットフォームでは5000として返されますが、iOSでは0.005として返されます。iOSの場合は、Singular SDKに直接0.005を送信します。その他のプラットフォームでは、Singularに送信する前にadValueをマイクロからドルに変換してください。
SDK実装のコードベースを選択してください:
仕組み
- Google AdMob Mobile Ads SDK(iOS)を実装します: 入門ガイドをご覧ください。
- AdMobとの統合:AdMobから広告をロードし、広告収益イベントを処理するためにsetOnPaidEventListenerを設定します。
- 収益の検証:収益が0より大きいことを確認するチェックを追加します。これにより、ゼロまたはマイナスの収益値を送信することを防ぎます。
- 通貨の検証:データをSingularに送信する前に、通貨がゼロまたは空でないことを確認する。
- 無効なデータのログ:データがバリデーションに失敗した場合、デバッグ用にログメッセージを表示し、Singularにデータを送信しません。
import Singular
private let adUnitID = "AD_UNIT_ID"
var rewardedAd: GADRewardedAd?
func loadRewardedAd() {
let request = GADRequest()
GADRewardedAd.load(withAdUnitID: adUnitID, request: request) { [weak self] ad, error in
guard let self = self else { return }
if let error = error {
print("Rewarded ad failed to load with error: \(error.localizedDescription)")
return
}
self.rewardedAd = ad
self.rewardedAd?.paidEventHandler = { adValue in
// Ensure valid revenue data
let revenue = adValue.value
let currency = adValue.currencyCode
// Validate the revenue and currency before sending to Singular
guard revenue > 0, let currency = currency, !currency.isEmpty else {
print("Invalid ad revenue data: revenue = \(revenue), currency = \(String(describing: currency))")
return
}
let data = SingularAdData(
adPlatform: "Admob",
currency: currency,
revenue: revenue
)
// Send Ad Revenue data to Singular
Singular.adRevenue(data: data)
// Log the data for debugging
print("Ad Revenue reported to Singular: \(data)")
}
}
}
どのように動作するか
- Google AdMob Mobile Ads SDK(iOS)を実装します: 入門ガイドをご覧ください。
- AdMobとの統合:AdMobから広告を読み込み、広告収益イベントを処理するためにpaidEventHandlerを設定します。
- 収益の検証:収益が0より大きいことを確認するチェックを追加します。これにより、ゼロまたはマイナスの収益値を送信することを防ぎます。
- 通貨の検証:Singularにデータを送信する前に、通貨がゼロまたは空でないことを確認する。
- 無効なデータのログ:データがバリデーションに失敗した場合、デバッグ用にログメッセージを表示し、Singularにデータを送信しません。
#import <Singular/Singular.h>
static NSString *const adUnitID = @"AD_UNIT_ID";
// Initialize and load the rewarded ad
@interface YourClassName () <GADRewardedAdDelegate>
@property(nonatomic, strong) GADRewardedAd *rewardedAd;
@end
@implementation YourClassName
- (void)loadRewardedAd {
GADRequest *request = [[GADRequest alloc] init];
[GADRewardedAd loadWithAdUnitID:adUnitID
request:request
completionHandler:^(GADRewardedAd *ad, NSError *error) {
if (error) {
NSLog(@"Rewarded ad failed to load with error: %@", [error localizedDescription]);
return;
}
self.rewardedAd = ad;
self.rewardedAd.fullScreenContentDelegate = self;
self.rewardedAd.paidEventHandler = ^(GADAdValue *adValue) {
// Ensure valid revenue data
NSDecimalNumber *revenue = adValue.value;
NSString *currency = adValue.currencyCode;
if (revenue.doubleValue > 0 && currency.length > 0) {
SingularAdData *data = [[SingularAdData alloc] initWithAdPlatfrom:@"Admob"
currency:currency
revenue:revenue.doubleValue];
// Send Ad Revenue data to Singular
[Singular adRevenue:data];
// Log the data for debugging
NSLog(@"Ad Revenue reported to Singular: %@", data);
} else {
NSLog(@"Invalid ad revenue data: revenue = %@, currency = %@", revenue, currency);
}
};
}];
}
@end
どのように動作するか
- Google AdMob Mobile Ads SDK(Android)を実装します: スタートガイドをご覧ください。
- AdMobとの統合:AdMobから広告を読み込み、広告収益イベントを処理するためにsetOnPaidEventListenerを設定します。
- 収益の検証:収益が0より大きいことを確認するチェックを追加します。これにより、ゼロまたはマイナスの収益値を送信することを防ぎます。
- 通貨の検証:データをSingularに送信する前に、通貨がゼロまたは空でないことを確認する。
- 無効なデータのログ:データがバリデーションに失敗した場合、デバッグ用にログメッセージを表示し、Singularにデータを送信しません。
import com.singular.sdk.Singular
import com.singular.sdk.SingularAdData
private const val AD_UNIT_ID = "AD_UNIT_ID"
class AdManager(private val context: Context) {
private var rewardedAd: RewardedAd? = null
fun loadRewardedAd() {
val adRequest = AdRequest.Builder().build()
RewardedAd.load(context, AD_UNIT_ID, adRequest, object : RewardedAdLoadCallback() {
override fun onAdLoaded(ad: RewardedAd) {
rewardedAd = ad
rewardedAd?.fullScreenContentCallback = object : FullScreenContentCallback() {
override fun onAdShowedFullScreenContent() {
Log.d("AdManager", "Rewarded ad displayed.")
}
override fun onAdFailedToShowFullScreenContent(adError: AdError) {
Log.d("AdManager", "Rewarded ad failed to show with error: ${adError.message}")
}
override fun onAdDismissedFullScreenContent() {
Log.d("AdManager", "Rewarded ad dismissed.")
}
}
rewardedAd?.setOnPaidEventListener { adValue: AdValue ->
// Ensure valid revenue data
val revenue = adValue.valueMicros / 1_000_000.0
val currency = adValue.currencyCode
if (revenue > 0 && !currency.isNullOrEmpty()) {
val data = SingularAdData(
"Admob",
currency,
revenue
)
// Send Ad Revenue data to Singular
Singular.adRevenue(data)
// Log the data for debugging
Log.d("AdManager", "Ad Revenue reported to Singular: $data")
} else {
Log.d("AdManager", "Invalid ad revenue data: revenue = $revenue, currency = $currency")
}
}
}
override fun onAdFailedToLoad(loadAdError: LoadAdError) {
Log.d("AdManager", "Rewarded ad failed to load with error: ${loadAdError.message}")
}
})
}
}
どのように動作するか
- Google AdMob Mobile Ads SDK(Android)を実装します: スタートガイドをご覧ください。
- AdMobとの統合:AdMobから広告を読み込み、広告収益イベントを処理するためにsetOnPaidEventListenerを設定します。
- 収益の検証:収益が0より大きいことを確認するチェックを追加します。これにより、ゼロまたはマイナスの収益値を送信することを防ぎます。
- 通貨の検証:データをSingularに送信する前に、通貨がゼロまたは空でないことを確認する。
- 無効なデータのログ:データがバリデーションに失敗した場合、デバッグ用にログメッセージを表示し、Singularにデータを送信しません。
import com.singular.sdk.Singular;
import com.singular.sdk.SingularAdData;
// Define constants for better maintainability
private static final String AD_UNIT_ID = "AD_UNIT_ID";
public class AdManager {
private RewardedAd rewardedAd;
private Context context;
public AdManager(Context context) {
this.context = context;
}
public void loadRewardedAd() {
AdRequest adRequest = new AdRequest.Builder().build();
RewardedAd.load(context, AD_UNIT_ID, adRequest, new RewardedAdLoadCallback() {
@Override
public void onAdLoaded(RewardedAd ad) {
rewardedAd = ad;
rewardedAd.setFullScreenContentCallback(new FullScreenContentCallback() {
@Override
public void onAdShowedFullScreenContent() {
Log.d("AdManager", "Rewarded ad displayed.");
}
@Override
public void onAdFailedToShowFullScreenContent(AdError adError) {
Log.d("AdManager", "Rewarded ad failed to show with error: " + adError.getMessage());
}
@Override
public void onAdDismissedFullScreenContent() {
Log.d("AdManager", "Rewarded ad dismissed.");
}
});
rewardedAd.setOnPaidEventListener(new OnPaidEventListener() {
@Override
public void onPaidEvent(AdValue adValue) {
double revenue = adValue.getValueMicros() / 1_000_000.0;
String currency = adValue.getCurrencyCode();
// Validate the revenue value
if (revenue <= 0 || currency == null || currency.isEmpty()) {
Log.d("AdManager", "Invalid ad revenue data: revenue = " + revenue + ", currency = " + currency);
return;
}
SingularAdData data = new SingularAdData(
"Admob",
currency,
revenue
);
// Send Ad Revenue data to Singular
Singular.adRevenue(data);
// Log the data for debugging
Log.d("AdManager", "Ad Revenue reported to Singular: " + data);
}
});
}
@Override
public void onAdFailedToLoad(LoadAdError loadAdError) {
Log.d("AdManager", "Rewarded ad failed to load with error: " + loadAdError.getMessage());
}
});
}
}
どのように動作するか
- Google AdMob Mobile Ads SDK(Flutter)を実装します: 入門ガイドを参照。
- AdMobインテグレーション:AdMobから広告を読み込み、広告収益イベントを処理するためにonPaidEventコールバックを設定します。
- 収益の検証:収益が0より大きいことを確認するチェックを追加します。これにより、ゼロまたはマイナスの収益値を送信することを防ぎます。
- 通貨の検証:Singularにデータを送信する前に、通貨がゼロまたは空でないことを確認する。
- 無効なデータのログ:データがバリデーションに失敗した場合、デバッグ用にログメッセージを表示し、Singularにデータを送信しません。
import 'package:singular_flutter_sdk/singular_flutter_sdk.dart';
const String adUnitId = 'YOUR_AD_UNIT_ID';
class AdManager {
RewardedAd? _rewardedAd;
void loadRewardedAd() {
RewardedAd.load(
adUnitId: adUnitId,
request: AdRequest(),
rewardedAdLoadCallback: RewardedAdLoadCallback(
onAdLoaded: (RewardedAd ad) {
_rewardedAd = ad;
_rewardedAd?.fullScreenContentCallback = FullScreenContentCallback(
onAdShowedFullScreenContent: () {
print('Rewarded ad displayed.');
},
onAdFailedToShowFullScreenContent: (AdError adError) {
print('Rewarded ad failed to show with error: ${adError.message}');
},
onAdDismissedFullScreenContent: () {
print('Rewarded ad dismissed.');
_rewardedAd = null; // Clear the ad when it is dismissed
},
);
_rewardedAd?.onPaidEvent = (AdValue adValue) {
double revenue = adValue.valueMicros / 1_000_000.0; // Convert from micros to dollars
String? currency = adValue.currencyCode;
// Validate the revenue and currency before sending to Singular
if (revenue > 0 && currency != null && currency.isNotEmpty) {
final data = {
'adPlatform': 'Admob',
'currency': currency,
'revenue': revenue,
};
// Send Ad Revenue data to Singular
Singular.adRevenue(data);
// Log the data for debugging
print('Ad Revenue reported to Singular: $data');
} else {
print('Invalid ad revenue data: revenue = $revenue, currency = $currency');
}
};
},
onAdFailedToLoad: (LoadAdError loadAdError) {
print('Rewarded ad failed to load with error: ${loadAdError.message}');
},
),
);
}
}
どのように動作するか
- CordovaはGoogleによって公式にサポートされていないため、サードパーティのCordovaプラグインを使用する必要があります。AdMob Plus Cordovaはcordova-plugin-admob-freeの後継で、よりクリーンなAPIと最新のツールで構築されています。このプラグインはSingularではサポートされていません。 入門ガイドを参照してください。
- AdMob の初期化:広告ユニットIDで広告フォーマットのインスタンスを作成します。ca-app-pub-xxx/yyy' は必ず実際の広告ユニットIDに置き換えてください。
- イベント処理: 有料イベントコールバックをトリガーします:このイベントは収益と通貨コードを提供します。これらの値を検証し、収益をマイクロからドルに変換します。このデータをSingularに送信します。load"、"show"、"dismiss"、"error "のライフサイクルイベントを必要に応じてロギングしながら処理する。
- データの検証:データをSingularに送信する前に、収益がゼロより大きく、通貨コードが存在することを確認する。
- Singularとの統合:SingularAdDataオブジェクトを使ってデータを準備し、adRevenueを呼び出してデータをSingularに送信します。
document.addEventListener('deviceready', async () => {
const admob = window.cordova.plugins.AdMobPlus;
// Initialize RewardedAd
const rewarded = admob.RewardedAd.create({
adUnitId: 'ca-app-pub-xxx/yyy', // Replace with your ad unit ID
// Optional configurations
isTesting: true, // Set to false when going live
});
// Handle the 'paid' event to get revenue details
rewarded.on('paid', (event) => {
const { value, currencyCode } = event;
// Validate the revenue and currency data
if (value > 0 && currencyCode) {
const revenueAmount = value / 1_000_000.0; // Convert from micros to dollars
// Prepare data for Singular
const adData = new cordova.plugins.SingularCordovaSdk.SingularAdData(
'Admob', // Mediation platform
currencyCode, // Currency code
revenueAmount // Revenue amount
);
// Send Ad Revenue data to Singular
cordova.plugins.SingularCordovaSdk.adRevenue(adData);
// Log the data for debugging
console.log('Ad Revenue reported to Singular:', {
adPlatform: 'Admob',
currency: currencyCode,
revenue: revenueAmount
});
} else {
console.error('Invalid ad revenue data:', { value, currencyCode });
}
});
// Handle ad load and show events
rewarded.on('load', async () => {
console.log('Rewarded ad loaded.');
// Load the next ad as soon as the current one is dismissed
await rewarded.load();
});
rewarded.on('show', () => {
console.log('Rewarded ad shown.');
});
rewarded.on('dismiss', async () => {
console.log('Rewarded ad dismissed.');
// Load a new ad for future use
await rewarded.load();
});
rewarded.on('error', (error) => {
console.error('Error with rewarded ad:', error);
});
// Load and show the rewarded ad
await rewarded.load();
await rewarded.show();
}, false);
仕組み
- React Native Google Mobile Adsパッケージを実装します: 入門ガイドを参照してください。
- AdMob との統合:AdMobから広告をロードし、広告収益イベントを処理するためにonAdEventを設定します。
- 収益の検証:収益が0より大きいことを確認するチェックを追加します。これにより、ゼロまたはマイナスの収益値を送信することを防ぎます。
- 通貨の検証:Singularにデータを送信する前に、通貨がゼロまたは空でないことを確認する。
- 無効なデータのログ:データがバリデーションに失敗した場合、デバッグ用にログメッセージを表示し、Singularにデータを送信しません。
import { Singular } from 'singular-react-native';
const adUnitID = 'AD_UNIT_ID';
const loadRewardedAd = () => {
// Create a RewardedAd instance with the provided adUnitID
const rewardedAd = RewardedAd.createForAdRequest(adUnitID);
// Set up event listener for ad events
rewardedAd.onAdEvent((type, error, data) => {
if (type === AdEventType.LOADED) {
console.log('Rewarded ad loaded');
} else if (type === AdEventType.ERROR) {
console.error('Rewarded ad failed to load', error);
} else if (type === AdEventType.PAID_EVENT) {
// Extract value and currencyCode from event data
const { value, currencyCode } = data;
// Validate the revenue and currency before sending to Singular
if (value > 0 && currencyCode) {
const revenue = value / 1_000_000.0; // Convert from micros to dollars
const adRevenueData = {
'Admob',
currency: currencyCode,
revenue,
};
// Send Ad Revenue data to Singular
Singular.adRevenue(adRevenueData);
// Log the data for debugging
console.log('Ad Revenue reported to Singular:', adRevenueData);
} else {
console.error('Invalid ad revenue data:', { value, currencyCode });
}
}
});
// Load the rewarded ad
rewardedAd.load();
};
useEffect(() => {
// Load the rewarded ad when the component mounts
loadRewardedAd();
}, []);
どのように動作するか
- Google AdMob Mobile Ads SDK(Unity)を実装します: 入門ガイドを参照してください。
- Google AdMobのドキュメントに記載されているリワード広告イベントをリッスンする。
- AdMobとの統合:AdMobから広告をロードし、広告がお金を生成したときのためにOnAdPaidコールバックを設定します。
- 収益の検証:収益が0より大きいことを確認するチェックを追加します。これにより、ゼロまたはマイナスの収益値を送信することを防ぎます。
- 通貨の検証:Singularにデータを送信する前に、通貨がゼロまたは空でないことを確認します。
- 無効なデータのログ:データがバリデーションに失敗した場合、デバッグ用にログメッセージを表示し、データをSingularに送信しないようにする。
using Singular;
private void RegisterEventHandlers(RewardedAd ad)
{
// Raised when the ad is estimated to have earned money.
ad.OnAdPaid += (AdValue adValue) =>
{
// Validate and ensure revenue data is within an expected range
float revenue = adValue.Value / 1_000_000f; // Convert micros to dollars
string currency = adValue.CurrencyCode;
// Check if revenue is positive and currency is valid
if (revenue > 0 && !string.IsNullOrEmpty(currency))
{
// Construct and send the Singular AdMon Event
SingularAdData data = new SingularAdData(
"Admob",
currency,
revenue
);
SingularSDK.AdRevenue(data);
// Log the revenue data for debugging purposes
Debug.Log($"Ad Revenue reported to Singular: {data}");
}
else
{
Debug.LogError($"Invalid ad revenue data: revenue = {revenue}, currency = {currency}");
}
};
}
パートナーノート
- Applovin Impression-Level User Revenue APIを使ってインプレッションレベルの広告収益データを共有しましょう。
SDK実装のコードベースを選択してください:
仕組み
- AppLovin Impression-Level User Revenue API(iOS)を使用します: スタートガイドをご覧ください。
- AppLovinインテグレーション:AppLovin MAXからリワード広告をロードし、広告収益イベントを処理するためにdidReceive関数を使用します。
- 収益検証:収益が0より大きいことを確認するチェックを追加します。これにより、ゼロまたはマイナスの収益値を送信することを防ぎます。
- 通貨の検証:以下のサンプルでは、通貨が "USD "にハードコードされています。データをSingularに送信する前に、通貨が正確で、ゼロや空でないことを確認してください。
- 無効なデータのログ:データの検証に失敗した場合、デバッグ用にログメッセージを表示し、Singularにデータを送信しません。
import Singular
func didReceive(_ message: ALCMessage) {
if "max_revenue_events" == message.topic {
// Safely unwrap values from the message data
guard
let revenueValue = message.data["revenue"] as? Double,
revenueValue > 0
else {
print("Failed to parse valid revenue value from message data or revenue is not greater than 0")
return
}
let data = SingularAdData(
adPlatform: "AppLovin",
currency: "USD", // Update this if a different currency is needed
revenue: revenueValue
)
// Send the revenue data to Singular
Singular.adRevenue(data)
}
}
どのように動作するか
- AppLovin Impression-Level User Revenue API(iOS)を使用します: 入門ガイドをご覧ください。
- AppLovinインテグレーション:AppLovin MAXからリワード広告をロードし、広告収益イベントを処理するためにdidReceive関数を使用します。
- 収益検証:収益が0より大きいことを確認するチェックを追加します。これにより、ゼロまたはマイナスの収益値を送信することを防ぎます。
- 通貨の検証:以下のサンプルでは、通貨が "USD "にハードコードされています。データをSingularに送信する前に、通貨が正確で、ゼロや空でないことを確認してください。
- 無効なデータのログ:データの検証に失敗した場合、デバッグ用にログメッセージを表示し、Singularにデータを送信しません。
#import <Singular/Singular.h>
- (void)didReceive:(ALCMessage *)message {
if ([@"max_revenue_events" isEqualToString:message.topic]) {
NSDictionary *data = message.data;
NSNumber *revenueNumber = data[@"revenue"];
double revenueValue = [revenueNumber doubleValue];
if (revenueValue > 0) {
SingularAdData *adData = [[SingularAdData alloc] initWithAdPlatfrom:@"AppLovin"
currency:@"USD"
revenue:revenueValue];
// Send the revenue data to Singular
[Singular adRevenue:adData];
} else {
NSLog(@"Failed to parse valid revenue value from message data or revenue is not greater than 0");
}
}
}
どのように動作するか
- AppLovin Impression-Level User Revenue API(Android)を使用します: スタートガイドをご覧ください。
- AppLovinインテグレーション:AppLovin MAXからリワード広告をロードし、広告収益イベントを処理するためにonMessageReceived関数を使用します。
- 収益検証:収益が0より大きいことを確認するチェックを追加します。これにより、ゼロまたはマイナスの収益値を送信することを防ぎます。
- 通貨の検証:以下のサンプルでは、通貨が "USD "にハードコードされています。データをSingularに送信する前に、通貨が正確で、ゼロや空でないことを確認してください。
- 無効なデータのログ:データの検証に失敗した場合、デバッグ用にログメッセージを表示し、Singularにデータを送信しません。
import com.singular.sdk.*
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 adData: Bundle? = message.messageData
// Safely access and validate revenue value
val revenueValue = adData?.getDouble("revenue", 0.0) ?: 0.0
if (revenueValue > 0) {
val data = SingularAdData(
adPlatform = "AppLovin",
currency = "USD",
revenue = revenueValue
)
Singular.adRevenue(data)
} else {
Log.e("AppLovinRevenue", "Failed to parse valid revenue value from message data or revenue is not greater than 0")
}
}
}
どのように動作するか
- AppLovin Impression-Level User Revenue API(Android)を使用します: スタートガイドをご覧ください。
- AppLovinインテグレーション:AppLovin MAXからリワード広告をロードし、広告収益イベントを処理するためにonMessageReceived関数を使用します。
- 収益検証:収益が0より大きいことを確認するチェックを追加します。これにより、ゼロまたはマイナスの収益値を送信することを防ぎます。
- 通貨の検証:以下のサンプルでは、通貨が "USD "にハードコードされています。データをSingularに送信する前に、通貨が正確で、ゼロや空でないことを確認してください。
- 無効なデータのログ:データの検証に失敗した場合、デバッグ用にログメッセージを表示し、Singularにデータを送信しません。
import com.singular.sdk.*;
@Override
public void onMessageReceived(AppLovinCommunicatorMessage message) {
// In the case that you are subscribed to multiple topics, check for the desired one
if ("max_revenue_events".equals(message.getTopic())) {
Bundle adData = message.getMessageData();
// Safely access and validate revenue value
double revenueValue = (adData != null) ? adData.getDouble("revenue", 0.0) : 0.0;
if (revenueValue > 0) {
SingularAdData data = new SingularAdData(
"AppLovin",
"USD",
revenueValue
);
Singular.adRevenue(data);
} else {
Log.e("AppLovinRevenue", "Failed to parse valid revenue value from message data or revenue is not greater than 0");
}
}
}
どのように動作するか
- AppLovin Impression-Level User Revenue API(Flutter)を使用します: スタートガイドをご覧ください。
- AppLovinインテグレーション: onAdRevenuePaidCallbackの広告リスナーを設定し、広告データをhandleAdRevenuePaid関数に渡して広告収益イベントを処理します。
- 収益の検証:収益が0より大きいことを確認するチェックを追加します。これにより、ゼロまたはマイナスの収益値が送信されるのを防ぎます。
- 通貨の検証:以下のサンプルでは、通貨が "USD "にハードコードされています。データをSingularに送信する前に、通貨が正確で、ゼロや空でないことを確認してください。
- 無効なデータのログ:データの検証に失敗した場合は、デバッグ用にログメッセージを表示し、Singularにデータを送信しないようにします。
import 'package:singular_flutter_sdk/singular.Flutter';
@override
void initState() {
super.initState();
// Set up ad listeners
AppLovinMAX.setInterstitialListener(InterstitialListener(
onAdRevenuePaidCallback: (ad) {
_handleAdRevenuePaid(ad);
},
));
AppLovinMAX.setRewardedAdListener(RewardedAdListener(
onAdRevenuePaidCallback: (ad) {
_handleAdRevenuePaid(ad);
},
));
AppLovinMAX.setBannerListener(AdViewAdListener(
onAdRevenuePaidCallback: (ad) {
_handleAdRevenuePaid(ad);
},
));
AppLovinMAX.setMRecListener(AdViewAdListener(
onAdRevenuePaidCallback: (ad) {
_handleAdRevenuePaid(ad);
},
));
}
void _handleAdRevenuePaid(Ad ad) {
final double revenueValue = ad.revenue ?? 0.0;
final String currency = ad.currency ?? 'USD'; // Default to 'USD' if currency is not available
if (revenue > 0) {
final SingularAdData adData = SingularAdData(
adPlatform: "AppLovin",
currency: currency,
revenue: revenueValue,
);
Singular.adRevenue(adData);
_logger.i('Sent ad revenue to Singular: $revenueValue $currency');
} else {
_logger.e('Failed to parse valid revenue value from ad revenue data or revenue is not greater than 0');
}
}
サポートされていません:
AppLovinのCordova SDKはadInfoオブジェクトによる広告収入情報の取得をネイティブサポートしていません。Cordova SDKは通常、AndroidやiOSのネイティブSDKに比べて高度な機能が制限されています。
高度な広告収入トラッキングのためには、ネイティブのAppLovin SDKと直接統合するか、カスタムプラグインを使用してCordovaとネイティブSDK間の機能を橋渡しする必要があるかもしれません。広告収入データが必要な場合は、AppLovinのサポートに最新の情報を問い合わせるか、このデータを取得する別の方法を検討してください。
仕組み
- AppLovin Impression-Level User Revenue API (React Native)を使用します: 入門ガイドをご覧ください。
- AppLovinとの統合:AppLovin MAXからリワード広告をロードし、すべての広告ライフサイクルのコールバックで収益額を取得します。
- 収益の検証:収益が0より大きいことを確認するチェックを追加します。これにより、ゼロまたはマイナスの収益値を送信することを防ぎます。
- 通貨の検証:以下のサンプルでは、通貨が "USD "にハードコードされています。データをSingularに送信する前に、通貨が正確で、ゼロや空でないことを確認してください。
- 無効なデータのログ:データの検証に失敗した場合、デバッグ用にログメッセージを表示し、Singularにデータを送信しません。
import Singular from 'singular-react-native';
// Function to handle ad revenue
const handleAdRevenue = (adInfo) => {
const revenue = adInfo.revenue;
if (revenue > 0) {
const adData = {
adPlatform: "AppLovin",
currency: "USD", // AppLovin typically reports revenue in USD
revenue: revenue,
};
// Send ad revenue data to Singular
Singular.adRevenue(adData);
} else {
console.error("Failed to parse valid revenue value from ad info or revenue is not greater than 0");
}
};
// Set up listeners for various ad types
InterstitialAd.addAdRevenuePaidListener(handleAdRevenue);
RewardedAd.addAdRevenuePaidListener(handleAdRevenue);
BannerAd.addAdRevenuePaidListener(handleAdRevenue);
MRecAd.addAdRevenuePaidListener(handleAdRevenue);
AppOpenAd.addAdRevenuePaidListener(handleAdRevenue);
どのように動作するか
- AppLovin Impression-Level User Revenue API(Unity)を使用します: スタートガイドをご覧ください。
- AppLovinインテグレーション:AppLovin MAXからリワード広告をロードし、すべての広告ライフサイクルのコールバックで収益額を取得します。
- 収益検証:収益が0より大きいことを確認するチェックを追加します。これにより、ゼロまたはマイナスの収益値を送信することを防ぎます。
- 通貨の検証:以下のサンプルでは、通貨が "USD "にハードコードされています。データをSingularに送信する前に、通貨が正確で、ゼロや空でないことを確認してください。
- 無効なデータのログ:データの検証に失敗した場合は、デバッグ用にログメッセージを表示し、 Singular にデータを送信しないようにしましょう。
using Singular;
public class AdRevenueHandler : MonoBehaviour
{
void Start()
{
// 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;
if (revenue > 0)
{
// Create a SingularAdData object with relevant information
SingularAdData adData = new SingularAdData(
"Applovin",
"USD",
revenue);
// Send ad revenue data to Singular
SingularSDK.AdRevenue(adData);
}
else
{
Debug.LogError("Failed to parse valid revenue value from ad info or revenue is not greater than 0");
}
}
void OnDestroy()
{
// Detach callbacks to prevent memory leaks
MaxSdkCallbacks.Interstitial.OnAdRevenuePaidEvent -= OnAdRevenuePaidEvent;
MaxSdkCallbacks.Rewarded.OnAdRevenuePaidEvent -= OnAdRevenuePaidEvent;
MaxSdkCallbacks.Banner.OnAdRevenuePaidEvent -= OnAdRevenuePaidEvent;
MaxSdkCallbacks.MRec.OnAdRevenuePaidEvent -= OnAdRevenuePaidEvent;
}
}
パートナーノート
- Impression Level Revenue (ILR) SDK APIは、ironSource SDKを使用して、ironSource Adsおよびその他の媒介ネットワークのインプレッションレベルデータを提供します。詳しくは[developers.is.com]をご覧ください。
- IronSourceのARM SDK Postbacksフラグがオンになっていることを確認してください。
SDK実装のコードベースを選択します:
どのように動作するか
- IronSource SDKを使用して、インプレッションレベルのユーザー収益を取得します(iOS): 入門ガイドを参照してください。
- Ironsourceインテグレーション:Ironsourceからリワード広告をロードし、広告収入イベントを処理するためにimpressionDataDidSucceed関数を使用します。
- 収益検証:収益が0より大きいことを確認するチェックを追加します。これにより、ゼロまたはマイナスの収益値を送信することを防ぎます。
- 通貨の検証:以下のサンプルでは、通貨が "USD "にハードコードされています。データをSingularに送信する前に、通貨が正確で、ゼロや空でないことを確認してください。
- 無効なデータのログ:データの検証に失敗した場合、デバッグ用にログメッセージを表示し、Singularにデータを送信しません。
import Singular
class IronSourceRewardedAdViewController: UIViewController {
func impressionDataDidSucceed(impressionData: ISImpressionData?) {
logCallback(#function)
// Ensure impressionData is not nil
guard let impressionData = impressionData else {
print("No impression data available.")
return
}
// Ensure revenue value is valid
let revenue = impressionData.revenue
guard revenue > 0 else {
print("Invalid revenue value: \(revenue)")
return
}
// Create SingularAdData object with appropriate values
let data = SingularAdData(
adPlatform: "IronSource",
currency: "USD",
revenue: revenue
)
// Send the Ad Revenue data to Singular
Singular.adRevenue(data)
// Log the data for debugging
print("Ad Revenue reported to Singular: AdPlatform: \(data.adPlatform), Currency: \(data.currency), Revenue: \(data.revenue)")
}
private func logCallback(_ functionName: String) {
// Implement logging if needed
print("Function called: \(functionName)")
}
}
どのように動作するか
- IronSource SDKを使用し、Impression-Level User Revenue(iOS)を取得します: 入門ガイドをご覧ください。
- Ironsourceインテグレーション:Ironsourceからリワード広告をロードし、広告収入イベントを処理するためにimpressionDataDidSucceed関数を使用します。
- 収益検証:収益が0より大きいことを確認するチェックを追加します。これにより、ゼロまたはマイナスの収益値を送信することを防ぎます。
- 通貨の検証:以下のサンプルでは、通貨が "USD "にハードコードされています。データをSingularに送信する前に、通貨が正確で、ゼロや空でないことを確認してください。
- 無効なデータのログ:データの検証に失敗した場合、デバッグ用にログメッセージを表示し、Singularにデータを送信しません。
#import <Singular/Singular.h>
@implementation IronSourceRewardedAdViewController
- (void)impressionDataDidSucceed:(ISImpressionData *)impressionData {
[self logCallback:NSStringFromSelector(_cmd)];
// Ensure impressionData is not nil
if (!impressionData) {
NSLog(@"No impression data available.");
return;
}
// Ensure revenue value is valid
double revenue = impressionData.revenue;
if (revenue <= 0) {
NSLog(@"Invalid revenue value: %f", revenue);
return;
}
// Create SingularAdData object with appropriate values
SingularAdData *data = [[SingularAdData alloc] initWithAdPlatfrom:@"IronSource"
currency:@"USD"
revenue:revenue];
// Send the Ad Revenue data to Singular
[Singular adRevenue:data];
// Log the data for debugging
NSLog(@"Ad Revenue reported to Singular: AdPlatform: %@, Currency: %@, Revenue: %f",
data.adPlatform, data.currency, data.revenue);
}
- (void)logCallback:(NSString *)functionName {
// Implement logging if needed
NSLog(@"Function called: %@", functionName);
}
@end
どのように動作するか
- IronSource SDKを使用し、Impression-Level User Revenue(Android)を取得します: スタートガイドをご覧ください。
- Ironsourceインテグレーション:Ironsourceからリワード広告をロードし、広告収入イベントを処理するためにonImpressionDataSuccess関数を使用します。
- 収益検証:収益が0より大きいことを確認するチェックを追加します。これにより、ゼロまたはマイナスの収益値を送信することを防ぎます。
- 通貨の検証:以下のサンプルでは、通貨が "USD "にハードコードされています。データをSingularに送信する前に、通貨が正確で、ゼロや空でないことを確認してください。
- 無効なデータのログ:データの検証に失敗した場合、デバッグ用にログメッセージを表示し、Singularにデータを送信しません。
import com.singular.sdk.Singular
// Method called when impression data is successfully received
fun onImpressionDataSuccess(impressionData: ISImpressionData?) {
// Ensure impressionData is not null
if (impressionData == null) {
Log.d("IronSource", "No impression data available.")
return
}
// Ensure revenue value is valid
val revenue = impressionData.revenue.toDouble()
if (revenue <= 0) {
Log.w("IronSource", "Invalid revenue value: $revenue")
return
}
// Create SingularAdData object with required fields
val data = SingularAdData(
adPlatform = "IronSource",
currency = "USD",
revenue = revenue
)
// Send the Ad Revenue data to Singular
Singular.adRevenue(data)
// Log the data for debugging
Log.i("IronSource", "Ad Revenue reported to Singular: AdPlatform: ${data.adPlatform}, Currency: ${data.currency}, Revenue: ${data.revenue}")
}
どのように動作するか
- IronSource SDKを使用し、Impression-Level User Revenue(Android)を取得します: スタートガイドをご覧ください。
- Ironsourceインテグレーション:Ironsourceからリワード広告をロードし、広告収入イベントを処理するためにonImpressionDataSuccess関数を使用します。
- 収益検証:収益が0より大きいことを確認するチェックを追加します。これにより、ゼロまたはマイナスの収益値を送信することを防ぎます。
- 通貨の検証:以下のサンプルでは、通貨が "USD "にハードコードされています。データをSingularに送信する前に、通貨が正確で、ゼロや空でないことを確認してください。
- 無効なデータのログ:データの検証に失敗した場合、デバッグ用にログメッセージを表示し、Singularにデータを送信しません。
import com.singular.sdk.Singular;
import com.singular.sdk.SingularAdData;
public class IronSourceAdManager {
// Method called when impression data is successfully received
public void onImpressionDataSuccess(ISImpressionData impressionData) {
// Ensure impressionData is not null
if (impressionData == null) {
Log.d("IronSource", "No impression data available.");
return;
}
// Ensure revenue value is valid
double revenue = impressionData.getRevenue().doubleValue();
if (revenue <= 0) {
Log.w("IronSource", "Invalid revenue value: " + revenue);
return;
}
// Create SingularAdData object with required fields
SingularAdData data = new SingularAdData(
"IronSource", // adPlatform
"USD", // currency
revenue // revenue
);
// Send the Ad Revenue data to Singular
Singular.adRevenue(data);
// Log the data for debugging
Log.i("IronSource", "Ad Revenue reported to Singular: AdPlatform: " + data.getAdPlatform() +
", Currency: " + data.getCurrency() +
", Revenue: " + data.getRevenue());
}
}
どのように動作するか
- IronSource Flutter Pluginを使用し、インプレッションレベルのユーザー収入を取得します: 入門ガイドを参照。
- Ironsourceの統合:Ironsourceからリワード広告をロードし、広告収入イベントを処理するためにonImpressionDataSuccess関数を使用します。
- 収益検証:収益が0より大きいことを確認するチェックを追加します。これにより、ゼロまたはマイナスの収益値を送信することを防ぎます。
- 通貨の検証:以下のサンプルでは、通貨が "USD "にハードコードされています。データをSingularに送信する前に、通貨が正確で、ゼロや空でないことを確認してください。
- 無効なデータのログ:データの検証に失敗した場合は、デバッグ用にログメッセージを表示し、Singularにデータを送信しないようにします。
import 'package:singular_flutter_sdk/singular.Flutter';
// Method called when impression data is successfully received
void onImpressionDataSuccess(ISImpressionData? impressionData) {
// Ensure impressionData is not null
if (impressionData == null) {
print("No impression data available.");
return;
}
// Ensure revenue value is valid
final revenue = impressionData.revenue.toDouble();
if (revenue <= 0) {
print("Invalid revenue value: $revenue");
return;
}
// Create SingularAdData object with required fields
final data = SingularAdData(
adPlatform: "IronSource",
currency: "USD",
revenue: revenue,
);
// Send the Ad Revenue data to Singular
Singular.adRevenue(data);
// Log the data for debugging
if (kDebugMode) {
print("Ad Revenue reported to Singular: AdPlatform: ${data.adPlatform}, Currency: ${data.currency}, Revenue: ${data.revenue}");
}
}
サポートされていません:
IronSourceはCordovaフレームワークでの広告収益の取得をネイティブサポートしていません。
高度な広告収入トラッキングを行うには、ironSourceのネイティブSDKと直接統合するか、カスタムプラグインを使用してCordovaとネイティブSDK間の機能を橋渡しする必要があります。広告収益データが必要な場合は、ironSourceのサポートに最新の情報を問い合わせるか、このデータを取得する別の方法を検討してください。
仕組み
- IronSource React Native Pluginを使用して、インプレッションレベルのユーザー収益を取得します: 入門ガイドを参照してください。
- Ironsourceの統合:Ironsourceからリワード広告をロードし、広告収入イベントを処理するためにonImpressionDataSuccessリスナーを使用します。
- 収益の検証:収益が0より大きいことを確認するチェックを追加します。これにより、ゼロまたはマイナスの収益値を送信することを防ぎます。
- 通貨の検証:以下のサンプルでは、通貨が "USD "にハードコードされています。データをSingularに送信する前に、通貨が正確で、ゼロや空でないことを確認してください。
- 無効なデータのログ:データの検証に失敗した場合、デバッグ用にログメッセージを表示し、Singularにデータを送信しません。
import { Singular } from 'singular-react-native';
const { IronSourceModule } = NativeModules;
const ironSourceEventEmitter = new NativeEventEmitter(IronSourceModule);
const AD_PLATFORM = 'IronSource';
const CURRENCY = 'USD'; // Assuming USD, adjust if necessary
ironSourceEventEmitter.addListener('onImpressionDataSuccess', (impressionData) => {
if (!impressionData) {
console.log('No impression data available.');
return;
}
const revenue = impressionData.revenue;
// Validate the revenue to ensure it is within the expected range
if (revenue <= 0) {
console.warn(`Invalid revenue value: ${revenue}`);
return;
}
// Create SingularAdData object with valid values
const data = {
adPlatform: AD_PLATFORM,
currency: CURRENCY,
revenue: revenue,
};
// Send the revenue data to Singular
Singular.adRevenue(data);
// Log the data for debugging purposes
console.log(`Ad Revenue reported to Singular: AdPlatform: ${data.adPlatform}, Currency: ${data.currency}, Revenue: ${data.revenue}`);
});
どのように動作するか
- IronSource Unity Pluginを使用して、インプレッションレベルのユーザー収入を取得します: 入門ガイドを参照してください。
- Ironsourceとの統合:Ironsourceからリワード広告をロードし、広告収入イベントを処理するためにImpressionDataReadyEvent関数を使用します。
- 収益検証:収益が0より大きいことを確認するチェックを追加します。これにより、ゼロまたはマイナスの収益値を送信することを防ぎます。
- 通貨の検証:以下のサンプルでは、通貨が "USD "にハードコードされています。データをSingularに送信する前に、通貨が正確で、ゼロや空でないことを確認してください。
- 無効なデータのログ:データの検証に失敗した場合は、デバッグ用にログメッセージを表示し、 Singular にデータを送信しないようにしましょう。
using Singular;
public class IronSourceRewardedAdViewController : MonoBehaviour
{
void Start()
{
// Ensure the listener is added before initializing the SDK
IronSourceEvents.onImpressionDataReadyEvent += ImpressionDataReadyEvent;
// Initialize the IronSource SDK here if not already done
// IronSource.Agent.init("YOUR_IRONSOURCE_APP_KEY");
}
private void ImpressionDataReadyEvent(IronSourceImpressionData impressionData)
{
if (impressionData != null)
{
// Ensure revenue value is valid
double? revenue = impressionData.revenue;
if (revenue.HasValue && revenue.Value > 0)
{
// Create SingularAdData object with appropriate values
SingularAdData adData = new SingularAdData(
"IronSource",
"USD",
revenue.Value
);
// Send the Ad Revenue data to Singular
SingularSDK.AdRevenue(adData);
// Log the data for debugging
Debug.Log($"Ad Revenue reported to Singular: AdPlatform: {adData.AdPlatform}, Currency: {adData.Currency}, Revenue: {adData.Revenue}");
}
else
{
Debug.LogError($"Invalid revenue value: {revenue}");
}
}
else
{
Debug.LogError("Impression data is null.");
}
}
void OnDestroy()
{
// Detach the callback to prevent memory leaks
IronSourceEvents.onImpressionDataReadyEvent -= ImpressionDataReadyEvent;
}
}
パートナーの注意事項
- impressionDelegateを設定する
- TradPlusAdImpressionコールバックにSingularを追加する。
SDK実装のコードベースを選択します:
どのように動作するか
- TradPlusとの統合:TradPlusからリワード広告をロードし、広告収入イベントを処理するためにtradPlusAdImpression関数を使用します。
- 収益検証:収益が0より大きいことを確認するチェックを追加します。これにより、ゼロまたはマイナスの収益値が送信されるのを防ぎます。adInfoディクショナリには、有効な NSNumber 値を持つ"ecpm" キーが含まれています。この値をDoubleに変換し、スケーリングする(通常、ecpmはミリ単位で指定されるため、1000.0で割るとドルに変換される)。
- 通貨の検証:以下のサンプルでは、通貨は "USD "にハードコードされています。データをSingularに送信する前に、通貨が正確で、ゼロや空でないことを確認してください。
- 無効なデータのログデータの検証に失敗した場合、デバッグ用にログメッセージを表示し、Singularにデータを送信しません。
import Singular
// Set up the delegate
TradPlus.sharedInstance().impressionDelegate = self
// Delegate method for handling ad impressions
func tradPlusAdImpression(_ adInfo: [String: Any]) {
let currency = "USD" // Assuming USD, adjust if necessary
// Ensure adInfo contains the necessary key and its value is valid
if let ecpmValue = adInfo["ecpm"] as? NSNumber {
let revenue = ecpmValue.doubleValue / 1000.0
// Validate the revenue value
guard revenue > 0 else {
print("Ad Revenue value out of expected range: \(revenue)")
return
}
// Create SingularAdData object with required fields
let data = SingularAdData(
adPlatform: "TradPlus",
currency: currency,
revenue: revenue
)
// Send the Ad Revenue data to Singular
Singular.adRevenue(data)
print("Ad Revenue reported to Singular: \(data)")
} else {
// Log the issue for debugging
print("No eCPM data available in adInfo")
}
}
どのように機能するか
- TradPlusとの統合:TradPlusからリワード広告をロードし、tradPlusAdImpression関数を使用して広告収入イベントを処理します。
- 収益の検証:収益が0より大きいことを確認するチェックを追加します。これにより、ゼロまたはマイナスの収益値が送信されるのを防ぎます。adInfoディクショナリには、有効な NSNumber 値を持つ"ecpm" キーが含まれています。この値をDoubleに変換し、スケーリングする(通常、ecpmはミリ単位で指定されるため、1000.0で割るとドルに変換される)。
- 通貨の検証:以下のサンプルでは、通貨は "USD "にハードコードされています。データをSingularに送信する前に、通貨が正確で、ゼロや空でないことを確認してください。
- 無効なデータのログデータの検証に失敗した場合、デバッグ用にログメッセージを表示し、Singularにデータを送信しません。
#import <Singular/Singular.h>
// Set up the delegate
TradPlus.sharedInstance.impressionDelegate = self;
// Delegate method for handling ad impressions
- (void)tradPlusAdImpression:(NSDictionary<NSString *, id> *)adInfo {
NSString *currency = @"USD"; // Assuming USD, adjust if necessary
// Ensure adInfo contains the necessary key and its value is valid
NSNumber *ecpmValue = adInfo[@"ecpm"];
if (ecpmValue) {
double revenue = [ecpmValue doubleValue] / 1000.0;
// Validate the revenue value
if (revenue <= 0) {
NSLog(@"Ad Revenue value out of expected range: %f", revenue);
return;
}
// Create SingularAdData object with required fields
SingularAdData *data = [[SingularAdData alloc] initWithAdPlatfrom:@"TradPlus"
currency:currency
revenue:revenue];
// Send the Ad Revenue data to Singular
[Singular adRevenue:data];
NSLog(@"Ad Revenue reported to Singular: AdPlatform: %@, Currency: %@, Revenue: %f", data.adPlatform, data.currency, data.revenue);
} else {
// Log the issue for debugging
NSLog(@"No eCPM data available in adInfo");
}
}
どのように機能するか
- TradPlusとの統合:TradPlusからリワード広告をロードし、onImpressionSuccess関数を使用して広告収入イベントを処理します。
- 収益の検証:収益が0より大きいことを確認するチェックを追加します。これにより、ゼロまたはマイナスの収益値が送信されるのを防ぎます。adInfoディクショナリには、有効な NSNumber 値を持つ"ecpm" キーが含まれています。この値をDoubleに変換し、スケーリングする(通常、ecpmはミリ単位で指定されるため、1000.0で割るとドルに変換される)。
- 通貨の検証:以下のサンプルでは、通貨は "USD "にハードコードされています。データをSingularに送信する前に、通貨が正確で、ゼロや空でないことを確認してください。
- 無効なデータのログデータの検証に失敗した場合、デバッグ用にログメッセージを表示し、Singularにデータを送信しません。
import com.singular.sdk.Singular
import com.singular.sdk.SingularAdData
// Set the global impression listener for TradPlus
TradPlusSdk.setGlobalImpressionListener(
object : GlobalImpressionManager.GlobalImpressionListener {
override fun onImpressionSuccess(tpAdInfo: TPAdInfo?) {
// Ensure tpAdInfo is not null
if (tpAdInfo == null) {
println("AdInfo is null")
return
}
// Calculate revenue (assuming ecpm is a valid field)
val revenue = tpAdInfo.ecpm.toDouble() / 1000
// Validate the revenue value
if (revenue <= 0) {
println("Ad Revenue value out of expected range: $revenue")
return
}
// Create SingularAdData object with required fields
val data = SingularAdData(
adPlatform = "TradPlus",
currency = "USD", // Assuming USD, adjust if necessary
revenue = revenue
)
// Send the Ad Revenue data to Singular
Singular.adRevenue(data)
// Log for debugging
println("Ad Revenue reported to Singular: AdPlatform: ${data.adPlatform}, Currency: ${data.currency}, Revenue: ${data.revenue}")
}
}
)
どのように機能するか
- TradPlusとの統合:TradPlusからリワード広告をロードし、onImpressionSuccess関数を使用して広告収入イベントを処理します。
- 収益の検証:収益が0より大きいことを確認するチェックを追加します。これにより、ゼロまたはマイナスの収益値が送信されるのを防ぎます。adInfoディクショナリには、有効な NSNumber 値を持つ"ecpm" キーが含まれています。この値をDoubleに変換し、スケーリングする(通常、ecpmはミリ単位で指定されるため、1000.0で割るとドルに変換される)。
- 通貨の検証:以下のサンプルでは、通貨は "USD "にハードコードされています。データをSingularに送信する前に、通貨が正確で、ゼロや空でないことを確認してください。
- 無効なデータのログデータの検証に失敗した場合、デバッグ用にログメッセージを表示し、Singularにデータを送信しません。
import com.singular.sdk.Singular;
import com.singular.sdk.SingularAdData;
public class AdImpressionListener implements GlobalImpressionManager.GlobalImpressionListener {
private static final String TAG = "AdImpressionListener";
@Override
public void onImpressionSuccess(TPAdInfo tpAdInfo) {
// Ensure tpAdInfo is not null
if (tpAdInfo == null) {
Log.e(TAG, "AdInfo is null");
return;
}
// Ensure eCPM is valid and not null
if (tpAdInfo.getEcpm() == null) {
Log.e(TAG, "eCPM value is null");
return;
}
// Calculate revenue (assuming ecpm is in micros)
double revenue = tpAdInfo.getEcpm().doubleValue() / 1000;
// Validate the revenue value
if (revenue <= 0) {
Log.e(TAG, "Ad Revenue value out of expected range: " + revenue);
return;
}
// Create SingularAdData object with required fields
SingularAdData data = new SingularAdData(
"TradPlus",
"USD",
revenue
);
// Send the Ad Revenue data to Singular
Singular.adRevenue(data);
// Log for debugging
Log.d(TAG, "Ad Revenue reported to Singular: AdPlatform: " + data.getAdPlatform() +
", Currency: " + data.getCurrency() + ", Revenue: " + data.getRevenue());
}
}
どのように機能するか
- TradPlusとの統合:TradPlusからリワード広告をロードし、setGlobalImpressionListenerを使用して広告収入イベントを処理します。
- 収益の検証:収益が0より大きいことを確認するチェックを追加します。これにより、ゼロまたはマイナスの収益値が送信されるのを防ぎます。adInfoディクショナリには、有効な NSNumber 値を持つ"ecpm" キーが含まれています。この値をDoubleに変換し、スケーリングする(通常、ecpmはミリ単位で指定されるため、1000.0で割るとドルに変換される)。
- 通貨の検証:以下のサンプルでは、通貨は "USD "にハードコードされています。データをSingularに送信する前に、通貨が正確で、ゼロや空でないことを確認してください。
- 無効なデータのログデータの検証に失敗した場合は、デバッグ用にログメッセージを表示し、Singularにデータを送信しないようにします。
import 'package:singular_flutter_sdk/singular.dart';
void setupTradPlusImpressionListener() {
// Set up the global impression listener
TradPlusSdk.setGlobalImpressionListener((tpAdInfo) {
if (tpAdInfo == null) {
print("AdInfo is null");
return;
}
// Ensure eCPM is not null
if (tpAdInfo.ecpm == null) {
print("eCPM value is null");
return;
}
// Calculate revenue (assuming ecpm is in micros)
double revenue = tpAdInfo.ecpm / 1000.0;
// Validate the revenue value
if (revenue <= 0) {
print("Ad Revenue value out of expected range: $revenue");
return;
}
// Create SingularAdData object
final data = SingularAdData(
adPlatform: "TradPlus", // Ad platform name
currency: "USD", // Currency
revenue: revenue // Revenue
);
// Send the Ad Revenue data to Singular
Singular.adRevenue(data);
// Print log for debugging
print("Ad Revenue reported to Singular: AdPlatform: ${data.adPlatform}, Currency: ${data.currency}, Revenue: ${data.revenue}");
});
}
void main() {
// Initialize TradPlus SDK and other setup
setupTradPlusImpressionListener();
// Run your app
runApp(MyApp());
}
サポートされていません:
TradPlusはネイティブではadInfoオブジェクトによる広告収入情報の取得をサポートしていません。Cordova SDKは一般的に、AndroidやiOSのネイティブSDKに比べて高度な機能が制限されています。
高度な広告収益トラッキングを行うには、TradPlusのネイティブSDKと直接統合するか、カスタムプラグインを使用してCordovaとネイティブSDK間の機能を橋渡しする必要があるかもしれません。広告収入データが必要な場合は、AppLovinのサポートに最新の情報を問い合わせるか、このデータを取得する別の方法を検討することを検討してください。
仕組み
- TradPlusとの統合:TradPlusからリワード広告をロードし、広告収入イベントを処理するためにonImpressionSuccessリスナーを設定します。
- 収益の検証:収益が0より大きいことを確認するチェックを追加します。これにより、ゼロまたはマイナスの収益値を送信することを防ぎます。adInfoディクショナリには、有効な NSNumber 値を持つ"ecpm" キーが含まれています。この値をDoubleに変換し、スケーリングする(通常、ecpmはミリ単位で指定されるため、1000.0で割るとドルに変換される)。
- 通貨の検証:以下のサンプルでは、通貨は "USD "にハードコードされています。データをSingularに送信する前に、通貨が正確で、ゼロや空でないことを確認してください。
- 無効なデータのログデータの検証に失敗した場合、デバッグ用にログメッセージを表示し、Singularにデータを送信しません。
import { NativeModules, NativeEventEmitter } from 'react-native';
import { Singular } from 'singular-react-native';
const { TradPlusModule } = NativeModules;
const tradPlusEventEmitter = new NativeEventEmitter(TradPlusModule);
const AD_PLATFORM = 'TradPlus';
const CURRENCY = 'USD'; // Assuming USD, adjust if necessary
tradPlusEventEmitter.addListener('onImpressionSuccess', (tpAdInfo) => {
if (!tpAdInfo) {
console.log('AdInfo is null');
return;
}
const revenue = tpAdInfo.ecpm / 1000;
// Validate the revenue to ensure it is within the expected range
if (revenue <= 0) {
console.warn(`Ad Revenue value out of expected range: ${revenue}`);
return;
}
// Create the ad revenue data object
const data = {
adPlatform: AD_PLATFORM,
currency: CURRENCY,
revenue: revenue,
};
// Send the revenue data to Singular
Singular.adRevenue(data);
// Log the data for debugging purposes
console.log(`Ad Revenue reported to Singular: AdPlatform: ${data.adPlatform}, Currency: ${data.currency}, Revenue: ${data.revenue}`);
});
どのように機能するか
- TradPlusとの統合:TradPlusからリワード広告をロードし、onImpressionSuccess関数を使用して広告収入イベントを処理します。
- 収益の検証:収益が0より大きいことを確認するチェックを追加します。これにより、ゼロまたはマイナスの収益値が送信されるのを防ぎます。adInfoディクショナリには、有効な NSNumber 値を持つ"ecpm" キーが含まれています。この値をDoubleに変換し、スケーリングする(通常、ecpmはミリ単位で指定されるため、1000.0で割るとドルに変換される)。
- 通貨の検証:以下のサンプルでは、通貨は "USD "にハードコードされています。データをSingularに送信する前に、通貨が正確で、ゼロや空でないことを確認してください。
- 無効なデータのログデータの検証に失敗した場合は、デバッグ用にログメッセージを表示し、Singular にデータを送信しないようにします。
using Singular;
public class AdImpressionListener : MonoBehaviour
{
private const string TAG = "AdImpressionListener";
void Start()
{
// Add Global Ad Impression Listener
TradplusAds.Instance().AddGlobalAdImpression(OnGlobalAdImpression);
}
void OnGlobalAdImpression(Dictionary<string, object> adInfo)
{
// Ensure adInfo is not null
if (adInfo == null)
{
Debug.LogError($"{TAG}: AdInfo is null");
return;
}
// Ensure eCPM is present and valid
if (!adInfo.ContainsKey("ecpm") || adInfo["ecpm"] == null)
{
Debug.LogError($"{TAG}: eCPM value is null or missing");
return;
}
// Parse the eCPM value
if (!double.TryParse(adInfo["ecpm"].ToString(), NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out double revenue))
{
Debug.LogError($"{TAG}: Failed to parse eCPM value");
return;
}
// Convert eCPM to revenue (assuming eCPM is in micros)
revenue = revenue / 1000;
// Validate the revenue value
if (revenue <= 0)
{
Debug.LogError($"{TAG}: Ad Revenue value out of expected range: " + revenue);
return;
}
// Create SingularAdData object with the necessary fields
SingularAdData data = new SingularAdData(
"TradPlus", // Ad platform name
"USD", // Currency
revenue // Revenue value
);
// Send the Ad Revenue data to Singular
SingularSDK.AdRevenue(data);
// Log the data for debugging purposes
Debug.Log($"{TAG}: Ad Revenue reported to Singular: AdPlatform: {data.AdPlatform}, Currency: {data.Currency}, Revenue: {data.Revenue}");
}
}
パートナーの注意事項
- 一般的な統合:SingularAdData オブジェクトを初期化し、必要なデータを渡します。データには、adPlatform(String)、currency(String)、revenue(Double)を含める。
- 収益レポート:収益と通貨データが正しいことを確認してからSingularに送信してください。不正確なデータは後で修正できないので、正確であることを確認することが重要です。
- ヒントデバッグ用のログ情報
SDK実装のコードベースを選択してください:
import Singular
// Function to send Ad Revenue data to Singular
func reportAdRevenue(adPlatform: String, currency: String, revenue: Double) {
// Validate the revenue value
guard revenue > 0 else {
print("Invalid revenue value: \(revenue)")
return
}
// Create a SingularAdData object with the provided fields
let data = SingularAdData(
adPlatform: adPlatform,
currency: currency,
revenue: revenue
)
// Send the Ad Revenue data to Singular
Singular.adRevenue(data)
// Log the data for debugging
print("Ad Revenue reported to Singular: AdPlatform: \(data.adPlatform), Currency: \(data.currency), Revenue: \(data.revenue)")
}
#import <Singular/Singular.h>
// Function to send Ad Revenue data to Singular
- (void)reportAdRevenueWithPlatform:(NSString *)adPlatform currency:(NSString *)currency revenue:(double)revenue {
// Validate the revenue value
if (revenue <= 0) {
NSLog(@"Invalid revenue value: %f", revenue);
return;
}
// Create a SingularAdData object with the provided fields
SingularAdData *data = [[SingularAdData alloc] initWithAdPlatfrom:adPlatform currency:currency revenue:revenue];
// Send the Ad Revenue data to Singular
[Singular adRevenue:data];
// Log the data for debugging
NSLog(@"Ad Revenue reported to Singular: AdPlatform: %@, Currency: %@, Revenue: %f", data.adPlatform, data.currency, data.revenue);
}
import com.singular.sdk.Singular
import com.singular.sdk.SingularAdData
// Function to send Ad Revenue data to Singular
fun reportAdRevenue(adPlatform: String, currency: String, revenue: Double) {
// Validate the revenue value
if (revenue <= 0) {
println("Invalid revenue value: $revenue")
return
}
// Create a SingularAdData object with the provided fields
val data = SingularAdData(
adPlatform = adPlatform,
currency = currency,
revenue = revenue
)
// Send the Ad Revenue data to Singular
Singular.adRevenue(data)
// Log the data for debugging
println("Ad Revenue reported to Singular: AdPlatform: ${data.adPlatform}, Currency: ${data.currency}, Revenue: ${data.revenue}")
}
import com.singular.sdk.Singular;
import com.singular.sdk.SingularAdData;
// Function to send Ad Revenue data to Singular
public void reportAdRevenue(String adPlatform, String currency, double revenue) {
// Validate the revenue value
if (revenue <= 0) {
Log.w("AdRevenue", "Invalid revenue value: " + revenue);
return;
}
// Create a SingularAdData object with the provided fields
SingularAdData data = new SingularAdData(
adPlatform, // adPlatform
currency, // currency
revenue // revenue
);
// Send the Ad Revenue data to Singular
Singular.adRevenue(data);
// Log the data for debugging
Log.d("AdRevenue", "Ad Revenue reported to Singular: AdPlatform: " + data.getAdPlatform() + ", Currency: " + data.getCurrency() + ", Revenue: " + data.getRevenue());
}
import 'package:singular_flutter_sdk/singular.Flutter';
// Function to send Ad Revenue data to Singular
void reportAdRevenue({
required String adPlatform,
required String currency,
required double revenue,
}) {
// Validate the revenue value
if (revenue <= 0) {
print('Invalid revenue value: $revenue');
return;
}
// Create a SingularAdData object with the provided fields
final data = SingularAdData(
adPlatform: adPlatform,
currency: currency,
revenue: revenue,
);
// Send the Ad Revenue data to Singular
Singular.adRevenue(data);
// Log the data for debugging
print('Ad Revenue reported to Singular: AdPlatform: ${data.adPlatform}, Currency: ${data.currency}, Revenue: ${data.revenue}');
}
// Function to report Ad Revenue to Singular
function reportAdRevenue(mediationPlatform, currencyCode, revenueAmount) {
// Validate input values
if (!mediationPlatform || !currencyCode || typeof revenueAmount !== 'number' || revenueAmount <= 0) {
console.error("Invalid input for Ad Revenue reporting: ", {
mediationPlatform,
currencyCode,
revenueAmount
});
return;
}
try {
// Create a SingularAdData object
const adData = new cordova.plugins.SingularCordovaSdk.SingularAdData(
mediationPlatform,
currencyCode, // e.g., "USD"
revenueAmount
);
// Report Ad Revenue to Singular
cordova.plugins.SingularCordovaSdk.adRevenue(adData);
// Log success
console.log("Ad Revenue reported successfully: ", {
mediationPlatform: adData.mediationPlatform,
currencyCode: adData.currencyCode,
revenueAmount: adData.revenueAmount
});
} catch (error) {
// Log any errors that occur during the process
console.error("Failed to report Ad Revenue: ", error);
}
}
import { Singular } from 'singular-react-native';
const reportAdRevenue = (adPlatform, currency, revenue) => {
// Validate the revenue value
if (revenue <= 0) {
console.warn(`Invalid revenue value: ${revenue}`);
return;
}
// Create a SingularAdData object with the provided fields
const data = {
adPlatform: adPlatform,
currency: currency,
revenue: revenue,
};
// Send the Ad Revenue data to Singular
Singular.adRevenue(data);
// Log the data for debugging
console.log(`Ad Revenue reported to Singular: AdPlatform: ${data.adPlatform}, Currency: ${data.currency}, Revenue: ${data.revenue}`);
};
using Singular;
public class AdRevenueReporter : MonoBehaviour
{
// Function to report ad revenue to Singular
public void ReportAdRevenue(string adPlatform, float revenueInMicros, string currency)
{
// Convert revenue from micros to the standard unit (e.g., dollars)
float revenue = revenueInMicros / 1_000_000f;
// Validate the input: ensure revenue is positive and currency is not null or empty
if (revenue > 0 && !string.IsNullOrEmpty(currency))
{
// Create a SingularAdData object with the validated data
SingularAdData data = new SingularAdData(
adPlatform,
currency,
revenue
);
// Send the ad revenue data to Singular
SingularSDK.AdRevenue(data);
// Log the reported data for debugging
Debug.Log($"Ad Revenue reported to Singular: Platform = {adPlatform}, Currency = {currency}, Revenue = {revenue}");
}
else
{
// Log a warning if validation fails
Debug.LogWarning("Invalid ad revenue data: " +
$"Platform = {adPlatform}, Revenue = {revenue}, Currency = {currency}");
}
}
}