2. 上报时机
如果您已经在上报后台授权过其他广告平台的变现收入数据,并且现在上报的数据又包括该广告平台,请务必先关停这些平台在上报后台授权,然后使用上报收入数据对接,否则会产生重复数据。
我们推荐在
广告展示回调
的代理中上报收入数据:
说明:横幅广告有手动刷新(开发者自行实现)和自动刷新(Taku后台默认开启)的方式,所以上报收入数据需要进行区分:
◦
手动刷新:只需要在
展示成功
的代理上报即可
◦
自动刷新:除了在
展示成功
的代理商上报,还需要在横幅
自动刷新
的代理中进行上报,也就是两个代理都要上报
3. 平台对接
3.1 Appsflyer
建议使用一个工具类将
Appsflyer
相关的代码进行编写,然后在需要上报的地方调用。
- (void)handleAppsFlyerRevenueReport:(NSDictionary *)extra {
NSString *unitId = extra[@"network_placement_id"];
// 对精度要求较高的开发者需自行进行转换
double price = [extra[@"publisher_revenue"] doubleValue];
NSString *currency = extra[@"currency"];
NSString *country = extra[@"country"];
// Appsflyer提供多个key给开发者选用,开发者按自己需求使用,这里作为一个例子。
[[AppsFlyerLib shared] logEvent: AFEventPurchase
withValues:@{
AFEventParamContentId:unitId,
AFEventParamRevenue: @(price),
AFEventParamCurrency:currency,
AFEventParamCountry:country
3.1.1 开屏广告
我们在开屏广告展示代理回调中使用Appsflyer上报收入数据:
- (void)splashDidShowForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
NSLog(@"ATSplashViewController::splashDidShowForPlacementID:%@", extra);
[self handleAppsFlyerRevenueReport:extra];
3.1.2 激励视频
-(void) rewardedVideoDidStartPlayingForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
NSLog(@"ATRewardedVideoViewController::rewardedVideoDidStartPlayingForPlacementID:%@ extra:%@", placementID, extra);
[self handleAppsFlyerRevenueReport:extra];
3.1.3 插屏广告
-(void) interstitialDidShowForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
NSLog(@"ATInterstitialViewController::interstitialDidShowForPlacementID:%@ extra:%@", placementID, extra);
[self handleAppsFlyerRevenueReport:extra];
3.1.4 横幅广告
- (void)bannerView:(ATBannerView*)bannerView didShowAdWithPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {
NSLog(@"ATBannerViewController::bannerView:didShowAdWithPlacementID:%@ with extra: %@", placementID,extra);
[self handleAppsFlyerRevenueReport:extra];
如果是开启了自动刷新功能,还需要在自动刷新回调中进行上报
- (void)bannerView:(ATBannerView*)bannerView didAutoRefreshWithPlacement:(NSString*)placementID extra:(NSDictionary *)extra {
NSLog(@"ATBannerViewController::bannerView:didAutoRefreshWithPlacement:%@ with extra: %@", placementID,extra);
[self handleAppsFlyerRevenueReport:extra];
3.1.5 原生广告
-(void) didShowNativeAdInAdView:(ATNativeADView*)adView placementID:(NSString*)placementID extra:(NSDictionary *)extra{
NSLog(@"ATNativeViewController:: didShowNativeAdInAdView:placementID:%@ with extra: %@", placementID,extra);
[self handleAppsFlyerRevenueReport:extra];
3.2 Adjust
建议使用一个工具类将 Adjust 相关的代码进行编写,然后在需要上报的地方调用。
- (void)handleAdjustRevenueReport:(NSDictionary *)extra {
// 对精度要求较高的开发者需自行进行转换
double price = [extra[@"publisher_revenue"] doubleValue];
NSString *currency = extra[@"currency"];
// Source:收入来源(ADJAdRevenueSourceTaku在Adjust v4.37.1版本以上才有)
ADJAdRevenue *adRevenue = [[ADJAdRevenue alloc] initWithSource:ADJAdRevenueSourceTaku];
// pass revenue and currency values
[adRevenue setRevenue:price currency:currency];
// track ad revenue
[Adjust trackAdRevenue:adRevenue];
3.2.1 开屏广告
- (void)splashDidShowForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
NSLog(@"ATSplashViewController::splashDidShowForPlacementID:%@", extra);
[self handleAdjustRevenueReport:extra];
3.2.2 激励视频
-(void) rewardedVideoDidStartPlayingForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
NSLog(@"ATRewardedVideoViewController::rewardedVideoDidStartPlayingForPlacementID:%@ extra:%@", placementID, extra);
[self handleAdjustRevenueReport:extra];
3.2.3 插屏广告
-(void) interstitialDidShowForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
NSLog(@"ATInterstitialViewController::interstitialDidShowForPlacementID:%@ extra:%@", placementID, extra);
[self handleAdjustRevenueReport:extra];
3.2.4 横幅广告
- (void)bannerView:(ATBannerView*)bannerView didShowAdWithPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {
NSLog(@"ATBannerViewController::bannerView:didShowAdWithPlacementID:%@ with extra: %@", placementID,extra);
[self handleAdjustRevenueReport:extra];
如果是开启了自动刷新功能,还需要在自动刷新回调中进行上报
- (void)bannerView:(ATBannerView*)bannerView didAutoRefreshWithPlacement:(NSString*)placementID extra:(NSDictionary *)extra {
NSLog(@"ATBannerViewController::bannerView:didAutoRefreshWithPlacement:%@ with extra: %@", placementID,extra);
[self handleAdjustRevenueReport:extra];
3.2.5 原生广告
-(void) didShowNativeAdInAdView:(ATNativeADView*)adView placementID:(NSString*)placementID extra:(NSDictionary *)extra{
NSLog(@"ATNativeViewController:: didShowNativeAdInAdView:placementID:%@ with extra: %@", placementID,extra);
[self handleAppsFlyerRevenueReport:extra];
3.3 Firebase
建议使用一个工具类将 Firebase 相关的代码进行编写,然后在需要上报的地方调用。
- (void)handleFirebaseRevenueReport:(NSDictionary *)extra {
// 对精度要求较高的开发者需自行进行转换
double price = [extra[@"publisher_revenue"] doubleValue];
NSString *currency = extra[@"currency"];
NSString *country = extra[@"country"];
// 相关事件参数根据需求按平台要求自行添加
[FIRAnalytics logEventWithName:kFIREventAdImpression
parameters: @{
kFIRParameterCurrency: currency,
kFIRParameterValue: @(price)
3.3.1 开屏广告
- (void)splashDidShowForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
NSLog(@"ATSplashViewController::splashDidShowForPlacementID:%@", extra);
[self handleFirebaseRevenueReport:extra];
3.3.2 激励视频
-(void) rewardedVideoDidStartPlayingForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
NSLog(@"ATRewardedVideoViewController::rewardedVideoDidStartPlayingForPlacementID:%@ extra:%@", placementID, extra);
[self handleFirebaseRevenueReport:extra];
3.3.3 插屏广告
-(void) interstitialDidShowForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
NSLog(@"ATInterstitialViewController::interstitialDidShowForPlacementID:%@ extra:%@", placementID, extra);
[self handleFirebaseRevenueReport:extra];
3.3.4 横幅广告
我们在横幅广告展示代理回调中使用Firebase上报收入数据:
- (void)bannerView:(ATBannerView*)bannerView didShowAdWithPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {
NSLog(@"ATBannerViewController::bannerView:didShowAdWithPlacementID:%@ with extra: %@", placementID,extra);
[self handleFirebaseRevenueReport:extra];
如果是开启了自动刷新功能,还需要在自动刷新回调中进行上报
- (void)bannerView:(ATBannerView*)bannerView didAutoRefreshWithPlacement:(NSString*)placementID extra:(NSDictionary *)extra {
NSLog(@"ATBannerViewController::bannerView:didAutoRefreshWithPlacement:%@ with extra: %@", placementID,extra);
[self handleFirebaseRevenueReport:extra];
3.3.5 原生广告
-(void) didShowNativeAdInAdView:(ATNativeADView*)adView placementID:(NSString*)placementID extra:(NSDictionary *)extra{
NSLog(@"ATNativeViewController:: didShowNativeAdInAdView:placementID:%@ with extra: %@", placementID,extra);