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 impression revenue callback delegate:
/// Received impression revenue
/// - Parameters:
/// - placementID: Placement ID
/// - extra: Extra information dictionary
- (void)didRevenueForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra
It is recommended to write the AppsFlyer related code in a utility class and call it where reporting is needed.
/// Received impression revenue
/// - Parameters:
/// - placementID: Placement ID
/// - extra: Extra information dictionary
- (void)didRevenueForPlacementID:(NSString *)placementID extra:(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
}];
}
It is recommended to write the Adjust related code in a utility class and call it where reporting is needed.
/// Received impression revenue
/// - Parameters:
/// - placementID: Placement ID
/// - extra: Extra information dictionary
- (void)didRevenueForPlacementID:(NSString *)placementID extra:(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];
}
It is recommended to write the Firebase related code in a utility class and call it where reporting is needed.
/// Received impression revenue
/// - Parameters:
/// - placementID: Placement ID
/// - extra: Extra information dictionary
- (void)didRevenueForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
//#import <FirebaseAnalytics/FirebaseAnalytics.h>
// 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"];
// Create parameters
NSDictionary *params = @{
// Other key-value pairs can be added
kFIRParameterValue: @(price),
kFIRParameterCurrency: currency,
kFIRParameterAdPlatform: @"TopOn",
kFIRParameterAdFormat: [extra valueForKey:@"adunit_format"],
kFIRParameterAdUnitName : [extra valueForKey:@"adunit_id"],
kFIRParameterAdSource : [extra valueForKey:@"network_name"],// Custom Adapters are not supported
};
// Report revenue data
[FIRAnalytics logEventWithName:kFIREventAdImpression parameters:params];
}