广告收入归属
跟踪来自中介平台的广告收入,并将其归因于获取用户的营销活动,从而在营销活动成本、应用内购买和广告货币化方面提供完整的投资回报率可见性。
概述
什么是广告收入归因
广告收入归属将移动应用广告收入与推动应用安装的用户获取营销活动联系起来,使您能够衡量包括广告货币化在内的真实营销活动盈利能力。
主要优势:
- 统一的投资回报率视图:在单一仪表板中查看营销活动成本、应用内收入和广告收入
- 活动优化:将广告收入数据发回广告网络,以改进竞价和定位
- LTV 测量:计算包括广告货币化在内的完整用户生命周期价值
数据来源:广告收入数据通常来自用户级别或印象级别的中介平台(如AdMob、AppLovin MAX、IronSource)。Singular 支持多种集成方法来接收这些数据。
了解更多信息:有关设置、报告和故障排除的全面详情,请参阅广告收入归因常见问题解答。
实施要求
关键准则
数据准确性至关重要:
- 货币代码:使用三个字母的 ISO 4217 货币代码(如美元、欧元、印度卢比)。许多调解平台以美元为单位进行报告--实施前请核实您平台的货币。
-
发送前验证:在调用
SingularSDK.AdRevenue()之前,请务必验证收入和货币数据。不正确的数据在提交后无法更正。 - 平台差异:AdMob 在 Unity 和 Android 上以微米为单位报告收入(除以 1,000,000),但在 iOS 上以标准单位报告收入。请查看平台文档
设置步骤
按照以下步骤实施广告收入归属:
- 更新 SDK:确保使用的是最新版本的 Singular SDK
- 选择集成:在下面选择与您的设置相匹配的调解平台集成
- 实施回调:添加平台特定的付费事件监听器,以获取收入数据
- 验证数据:测试收入报告并验证数据是否出现在 Singular 面板中
平台集成
AdMob 集成
使用付费事件监听器跟踪来自 Google AdMob 的广告收入,以获得印象级收入报告。
要求:
平台收入报告:AdMob 按平台报告不同的收入。在 Unity 和 Android 平台上,0.005 美元的广告收入将以 5000 的形式返回,但在 iOS 平台上,广告收入将以 0.005 的形式返回。对于 iOS,直接向 Singular SDK 发送 0.005。在其他平台上,将 adValue 从微米转换为美元后再发送到 Singular。
执行
在加载广告时注册OnAdPaid 事件处理程序,以获取收入数据并发送到 Singular。
using UnityEngine;
using Singular;
using GoogleMobileAds.Api;
public class AdMobRevenueTracking : MonoBehaviour
{
private const string AD_UNIT_ID = "YOUR_AD_UNIT_ID";
private RewardedAd rewardedAd;
void Start()
{
// Initialize Mobile Ads SDK
MobileAds.Initialize(initStatus =>
{
Debug.Log("AdMob initialized");
LoadRewardedAd();
});
}
private void LoadRewardedAd()
{
// Create ad request
AdRequest adRequest = new AdRequest();
// Load rewarded ad
RewardedAd.Load(AD_UNIT_ID, adRequest, (RewardedAd ad, LoadAdError error) =>
{
if (error != null || ad == null)
{
Debug.LogError($"Rewarded ad failed to load: {error}");
return;
}
Debug.Log("Rewarded ad loaded");
rewardedAd = ad;
// Register event handlers
RegisterEventHandlers(ad);
});
}
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 Ad Revenue 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}");
}
};
// Additional event handlers
ad.OnAdFullScreenContentOpened += () =>
{
Debug.Log("Rewarded ad full screen content opened");
};
ad.OnAdFullScreenContentClosed += () =>
{
Debug.Log("Rewarded ad full screen content closed");
// Load next ad
LoadRewardedAd();
};
ad.OnAdFullScreenContentFailed += (AdError error) =>
{
Debug.LogError($"Rewarded ad failed to show: {error}");
// Load next ad
LoadRewardedAd();
};
}
public void ShowRewardedAd()
{
if (rewardedAd != null && rewardedAd.CanShowAd())
{
rewardedAd.Show((Reward reward) =>
{
Debug.Log($"User earned reward: {reward.Type} - {reward.Amount}");
});
}
else
{
Debug.Log("Rewarded ad is not ready yet");
}
}
}
AppLovin MAX 集成
使用 AppLovin 印象级用户收入 API 跟踪印象级广告收入。
要求:
- 为Unity实施AppLovin MAX SDK(参见入门指南
- 为您使用的所有广告格式附加收入付费回调
实施
注册OnAdRevenuePaidEvent 回调,以捕获并向 Singular 发送收入数据。
using UnityEngine;
using Singular;
public class AppLovinRevenueTracking : 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", // AppLovin typically reports in USD
revenue
);
// Send ad revenue data to Singular
SingularSDK.AdRevenue(adData);
Debug.Log($"Ad Revenue reported to Singular: {revenue} USD from {adUnitId}");
}
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;
}
}
与 Unity LevelPlay (IronSource) 集成
使用 IronSource SDK 跟踪来自 ironSource 和中介网络的印象级收入。
要求:
- 实施 ironSource Unity SDK(请参阅《入门指南
- 在 IronSource 面板中启用 ARM SDK 回传标志
- 设置印象数据监听器以接收收入回调
了解更多信息:有关完整设置的详细信息,请参阅IronSource 广告收入文档。
实施
订阅ImpressionDataReadyEvent 以捕获和发送收入数据。
using UnityEngine;
using Singular;
public class IronSourceRevenueTracking : 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", // IronSource typically reports in 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;
}
}
TradPlus 集成
使用全局印象监听器捕获来自 TradPlus 中介的广告收入。
要求:
-
通过
TradplusAds.Instance().AddGlobalAdImpression()添加全局广告印象监听器 -
处理
OnGlobalAdImpression回调以接收收入数据 - 将 eCPM 从毫位转换为标准货币(除以 1000)
执行
注册全局广告印象监听器,跟踪所有广告印象和收入。
using UnityEngine;
using Singular;
using System.Collections.Generic;
using System.Globalization;
public class TradPlusRevenueTracking : MonoBehaviour
{
private const string TAG = "TradPlusRevenue";
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 (eCPM is in milli-units)
revenue = revenue / 1000.0;
// 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",
"USD",
revenue
);
// 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 接口集成任何中介平台。
要求
- 从您的调解平台访问印象级收入数据
- 以标准货币单位(非微)表示的收入金额
- ISO 4217 货币代码(如美元、欧元、印度卢比)
数据准确性:在发送给 Singular 之前,请验证收入和货币数据。错误数据在提交后无法更正。
执行
使用平台名称、货币和收入创建SingularAdData 对象,然后调用SingularSDK.AdRevenue() 。
using UnityEngine;
using Singular;
public class GenericAdRevenueTracking : MonoBehaviour
{
// Function to report ad revenue to Singular
public void ReportAdRevenue(string adPlatform, string currency, float revenue)
{
// 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}");
}
}
// Example usage
void ExampleUsage()
{
// Report revenue from a custom mediation platform
ReportAdRevenue("MyMediationPlatform", "USD", 0.05f);
}
}
测试和验证
验证收入报告
测试广告收入实施情况,确保数据正确流向 Singular。
- 检查日志:验证收入回调日志是否以正确的值和货币出现在 Unity 控制台中。
- 测试广告:加载并显示测试广告以触发收入事件
- 仪表板验证:确认收入在 24 小时内出现在 Singular 面板中
- 数据准确性:验证收入金额与调解平台报告相符
故障排除:如果收入未出现在 Singular 中,请检查以下几点
- 您的 Singular 账户已启用广告收入归因功能
- 收入值大于 0
- 货币代码是有效的 ISO 4217 代码
- 平台名称符合 Singular 的预期格式
- 广告加载前已正确注册事件处理程序