You can obtain ad-related data through the delegate callbacks of the TopOn SDK and report it to third-party data platforms.
Obtain the corresponding values through the extra field in the delegate callbacks of each ad type. For details, see Callback Information Description.
| Property | Description |
|---|---|
| extra@"network\_firm\_id" | The ID corresponding to the third-party ad network. Refer to the Network Firm ID Table. |
| extra@"publisher\_revenue" | Obtain the revenue generated by this impression. The unit can be obtained via currency, and the precision can be obtained via precision. |
| extra@"country" | Obtain the country code, e.g., "CN". |
| extra@"currency" | Obtain the currency unit, e.g., "USD". |
| extra@"network\_placement\_id" | The ad ID of the third-party ad network. |
| extra@"adunit\_id" | Obtain the TopOn placement ID. |
If you have already authorized the monetization revenue data of other ad networks in the reporting dashboard, and the data now being reported also includes that ad network, you must first disable the authorization of these platforms in the reporting dashboard, and then connect using the reported revenue data; otherwise, duplicate data will be generated.
We recommend reporting revenue data in the ad display callback delegate:
| Ad Type | API | Description |
|---|---|---|
| Splash Ad | splashDidShowForPlacementID: extra: | Splash ad display successful |
| Rewarded Video | rewardedVideoDidStartPlayingForPlacementID: extra: | Rewarded Video ad playback started, i.e., Rewarded Video impression callback |
| Interstitial Ad | interstitialDidShowForPlacementID: extra: | Interstitial ad display successful |
| Banner Ad | bannerView: didShowAdWithPlacementID: extra: | BannerView display successful |
| Banner Ad | bannerView: didAutoRefreshWithPlacement: extra: | BannerView auto-refreshed |
| Native Ad | didShowNativeAdInAdView: placementID: extra: | Native ad display successful |
Note: Banner ads can be manually refreshed (implemented by the developer) or auto-refreshed (enabled by default in the TopOn dashboard), so revenue data reporting needs to be differentiated:
It is recommended to write the AppsFlyer related code in a utility class and call it where reporting is needed.
- (void)handleAppsFlyerRevenueReport:(NSDictionary *)extra {
NSString *unitId = extra[@"network_placement_id"];
// Developers who require higher precision should perform the conversion themselves
double price = [extra[@"publisher_revenue"] doubleValue];
NSString *currency = extra[@"currency"];
NSString *country = extra[@"country"];
// AppsFlyer provides multiple keys for developers to choose from. Developers should use them according to their own needs. This serves as an example.
[[AppsFlyerLib shared] logEvent: AFEventPurchase
withValues:@{
AFEventParamContentId:unitId,
AFEventParamRevenue: @(price),
AFEventParamCurrency:currency,
AFEventParamCountry:country
}];
}
We use the AppsFlyer delegate callback in the splash ad display callback to report revenue data:
- (void)splashDidShowForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
NSLog(@"ATSplashViewController::splashDidShowForPlacementID:%@", extra);
[self handleAppsFlyerRevenueReport:extra];
}
-(void) rewardedVideoDidStartPlayingForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
NSLog(@"ATRewardedVideoViewController::rewardedVideoDidStartPlayingForPlacementID:%@ extra:%@", placementID, extra);
[self handleAppsFlyerRevenueReport:extra];
}
-(void) interstitialDidShowForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
NSLog(@"ATInterstitialViewController::interstitialDidShowForPlacementID:%@ extra:%@", placementID, extra);
[self handleAppsFlyerRevenueReport:extra];
}
- (void)bannerView:(ATBannerView*)bannerView didShowAdWithPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {
NSLog(@"ATBannerViewController::bannerView:didShowAdWithPlacementID:%@ with extra: %@", placementID,extra);
[self handleAppsFlyerRevenueReport:extra];
}
If the auto-refresh feature is enabled, it also needs to be reported in the auto-refresh callback.
- (void)bannerView:(ATBannerView*)bannerView didAutoRefreshWithPlacement:(NSString*)placementID extra:(NSDictionary *)extra {
NSLog(@"ATBannerViewController::bannerView:didAutoRefreshWithPlacement:%@ with extra: %@", placementID,extra);
[self handleAppsFlyerRevenueReport:extra];
}
-(void) didShowNativeAdInAdView:(ATNativeADView*)adView placementID:(NSString*)placementID extra:(NSDictionary *)extra{
NSLog(@"ATNativeViewController:: didShowNativeAdInAdView:placementID:%@ with extra: %@", placementID,extra);
[self handleAppsFlyerRevenueReport:extra];
}
It is recommended to write the Adjust related code in a utility class and call it where reporting is needed.
- (void)handleAdjustRevenueReport:(NSDictionary *)extra {
// Developers who require higher precision should perform the conversion themselves
double price = [extra[@"publisher_revenue"] doubleValue];
NSString *currency = extra[@"currency"];
// Source: Revenue source (ADJAdRevenueSourceTaku is only available in Adjust v4.37.1 and above)
ADJAdRevenue *adRevenue = [[ADJAdRevenue alloc] initWithSource:ADJAdRevenueSourceTaku];
// pass revenue and currency values
[adRevenue setRevenue:price currency:currency];
// track ad revenue
[Adjust trackAdRevenue:adRevenue];
}
- (void)splashDidShowForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
NSLog(@"ATSplashViewController::splashDidShowForPlacementID:%@", extra);
[self handleAdjustRevenueReport:extra];
}
If the auto-refresh feature is enabled, it also needs to be reported in the auto-refresh callback.
- (void)bannerView:(ATBannerView*)bannerView didAutoRefreshWithPlacement:(NSString*)placementID extra:(NSDictionary *)extra {
NSLog(@"ATBannerViewController::bannerView:didAutoRefreshWithPlacement:%@ with extra: %@", placementID,extra);
[self handleAdjustRevenueReport:extra];
}
-(void) didShowNativeAdInAdView:(ATNativeADView*)adView placementID:(NSString*)placementID extra:(NSDictionary *)extra{
NSLog(@"ATNativeViewController:: didShowNativeAdInAdView:placementID:%@ with extra: %@", placementID,extra);
[self handleAppsFlyerRevenueReport:extra];
}
It is recommended to write the Firebase related code in a utility class and call it where reporting is needed.
- (void)handleFirebaseRevenueReport:(NSDictionary *)extra {
// Ad network ID
NSInteger network_firm_id = [[extra valueForKey:@"network_firm_id"] integerValue];
// Whether it is a bidding ad source
BOOL adsource_isheaderbidding = [[extra valueForKey:@"adsource_isheaderbidding"] boolValue];
// When using Firebase integrated with AdMob, non-bidding sources of AdMob do not need to be reported
if (network_firm_id == 2 && adsource_isheaderbidding == 0) return;
// Developers who require higher precision should perform the conversion themselves
double price = [extra[@"publisher_revenue"] doubleValue];
NSString *currency = extra[@"currency"];
NSString *country = extra[@"country"];
// Add relevant event parameters as needed according to platform requirements
[FIRAnalytics logEventWithName:kFIREventAdImpression
parameters: @{
kFIRParameterCurrency: currency,
kFIRParameterValue: @(price)
}];
}
- (void)splashDidShowForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
NSLog(@"ATSplashViewController::splashDidShowForPlacementID:%@", extra);
[self handleFirebaseRevenueReport:extra];
}
-(void) rewardedVideoDidStartPlayingForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
NSLog(@"ATRewardedVideoViewController::rewardedVideoDidStartPlayingForPlacementID:%@ extra:%@", placementID, extra);
[self handleFirebaseRevenueReport:extra];
}
-(void) interstitialDidShowForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
NSLog(@"ATInterstitialViewController::interstitialDidShowForPlacementID:%@ extra:%@", placementID, extra);
[self handleFirebaseRevenueReport:extra];
}
We use Firebase to report revenue data in the Banner ad display delegate callback:
- (void)bannerView:(ATBannerView*)bannerView didShowAdWithPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {
NSLog(@"ATBannerViewController::bannerView:didShowAdWithPlacementID:%@ with extra: %@", placementID,extra);
[self handleFirebaseRevenueReport:extra];
}
If the auto-refresh feature is enabled, it also needs to be reported in the auto-refresh callback.
- (void)bannerView:(ATBannerView*)bannerView didAutoRefreshWithPlacement:(NSString*)placementID extra:(NSDictionary *)extra {
NSLog(@"ATBannerViewController::bannerView:didAutoRefreshWithPlacement:%@ with extra: %@", placementID,extra);
[self handleFirebaseRevenueReport:extra];
}
-(void) didShowNativeAdInAdView:(ATNativeADView*)adView placementID:(NSString*)placementID extra:(NSDictionary *)extra{
NSLog(@"ATNativeViewController:: didShowNativeAdInAdView:placementID:%@ with extra: %@", placementID,extra);
[self handleAppsFlyerRevenueReport:extra];
}
-(void) rewardedVideoDidStartPlayingForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
NSLog(@"ATRewardedVideoViewController::rewardedVideoDidStartPlayingForPlacementID:%@ extra:%@", placementID, extra);
[self handleAdjustRevenueReport:extra];
}
-(void) interstitialDidShowForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
NSLog(@"ATInterstitialViewController::interstitialDidShowForPlacementID:%@ extra:%@", placementID, extra);
[self handleAdjustRevenueReport:extra];
}
- (void)bannerView:(ATBannerView*)bannerView didShowAdWithPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {
NSLog(@"ATBannerViewController::bannerView:didShowAdWithPlacementID:%@ with extra: %@", placementID,extra);
[self handleAdjustRevenueReport:extra];
}