Tenjin SDK có thể thu thập dữ liệu doanh thu ở cấp độ hiển thị quảng cáo từ TopOn và gửi các sự kiện này đến Tenjin. Tích hợp này sẽ gửi thông tin doanh thu cho mỗi lần hiển thị quảng cáo được phân phối từ TopOn. Dưới đây là các bước để thực hiện tích hợp:
- Cài đặt bộ công cụ phát triển phần mềm (SDK) TopOn iOS: https://docs.toponad.com/#/en-us/ios/GetStarted/TopOn_Get_Started
Vui lòng đảm bảo rằng bạn đã cài đặt phiên bản mới nhất của AnyThinkiOS iOS SDK (> 5.7.99). - Sau khi nhận được từ điển Ad extra, hãy chuyển nó sang Tenjin SDK:
Objective-C
[TenjinSDK initialize:@"<SDK_KEY>"];
[TenjinSDK connect];
[[ATAdManager sharedManager] loadADWithPlacementID:@"<INTERSTITIAL_AD_ID>" extra:@{} delegate:self];
-(void) didShowNativeBannerAdInView:(ATNativeBannerView*)bannerView placementID:(NSString*)placementID extra:(NSDictionary *)extra{
[TenjinSDK topOnImpressionFromDict:extra];
}Dưới đây là một ví dụ về việc tích hợp TopOn Banner và đăng ký nhận thông báo về các sự kiện hiển thị.
Objective-C
@implementation TJNTopOnViewController
- (void)viewDidLoad {
[super viewDidLoad];
_bannerPlacementID = @"<BANNER_AD_ID>";
_interstitialPlacementID = @"<INTERSTITIAL_AD_ID>";
[[ATAdManager sharedManager] loadADWithPlacementID:_interstitialPlacementID extra:@{} delegate:self];
if ([ATNativeBannerWrapper nativeBannerAdReadyForPlacementID:_bannerPlacementID]) {
[self showAd];
} else {
[ATNativeBannerWrapper loadNativeBannerAdWithPlacementID:_bannerPlacementID extra:@{kATExtraInfoNativeAdSizeKey:[NSValue valueWithCGSize:CGSizeMake(CGRectGetWidth(self.view.bounds), 120.0f)]} customData:nil delegate:self];
}
}
-(void) showAd {
ATNativeBannerView *bannerView = [ATNativeBannerWrapper retrieveNativeBannerAdViewWithPlacementID:_bannerPlacementID extra:@{kATNativeBannerAdShowingExtraAdSizeKey:[NSValue valueWithCGSize:CGSizeMake(CGRectGetWidth([UIScreen mainScreen].bounds), 120.0f)], kATNativeBannerAdShowingExtraAutorefreshIntervalKey:@10.0f, kATNativeBannerAdShowingExtraHideCloseButtonFlagKey:@NO, kATNativeBannerAdShowingExtraCTAButtonBackgroundColorKey:[UIColor redColor], kATNativeBannerAdShowingExtraCTAButtonTitleColorKey:[UIColor whiteColor], kATNativeBannerAdShowingExtraCTAButtonTitleFontKey:[UIFont systemFontOfSize:12.0f], kATNativeBannerAdShowingExtraTitleColorKey:[UIColor grayColor], kATNativeBannerAdShowingExtraTitleFontKey:[UIFont systemFontOfSize:12.0f], kATNativeBannerAdShowingExtraTextColorKey:[UIColor lightGrayColor], kATNativeBannerAdShowingExtraTextFontKey:[UIFont systemFontOfSize:10.0f], kATNativeBannerAdShowingExtraBackgroundColorKey:[UIColor whiteColor], kATNativeBannerAdShowingExtraAdvertiserTextFontKey:[UIFont systemFontOfSize:12.0f], kATNativeBannerAdShowingExtraAdvertiserTextColorKey:[UIColor lightGrayColor]} delegate:self];
bannerView.frame = CGRectMake(.0f, 100.0f, CGRectGetWidth(bannerView.bounds), CGRectGetHeight(bannerView.bounds));
bannerView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[self.view addSubview:bannerView];
}
- (IBAction)showInterstitialAd {
[[ATAdManager sharedManager] showInterstitialWithPlacementID:_interstitialPlacementID inViewController:self delegate:self];
}
#pragma mark - native banner delegate(s)
-(void) didFinishLoadingNativeBannerAdWithPlacementID:(NSString *)placementID {
NSLog(@"TJNTopOnViewController::didFinishLoadingNativeBannerAdWithPlacementID:%@", placementID);
[self showAd];
}
-(void) didFailToLoadNativeBannerAdWithPlacementID:(NSString*)placementID error:(NSError*)error {
NSLog(@"TJNTopOnViewController::didFailToLoadNativeBannerAdWithPlacementID:%@ error:%@", placementID, error);
}
-(void) didShowNativeBannerAdInView:(ATNativeBannerView*)bannerView placementID:(NSString*)placementID extra:(NSDictionary *)extra{
NSLog(@"TJNTopOnViewController::didShowNativeBannerAdInView:%@ placementID:%@ with extra: %@",bannerView, placementID,extra);
[TenjinSDK topOnImpressionFromDict:extra];
}
-(void) didClickNativeBannerAdInView:(ATNativeBannerView*)bannerView placementID:(NSString*)placementID extra:(NSDictionary *)extra{
NSLog(@"TJNTopOnViewController::didClickNativeBannerAdInView:%@ placementID:%@ with extra: %@",bannerView, placementID,extra);
}
-(void) didClickCloseButtonInNativeBannerAdView:(ATNativeBannerView*)bannerView placementID:(NSString*)placementID extra:(NSDictionary *)extra{
NSLog(@"TJNTopOnViewController::didClickCloseButtonInNativeBannerAdView:%@ placementID:%@", bannerView, placementID);
}
-(void) didAutorefreshNativeBannerAdInView:(ATNativeBannerView*)bannerView placementID:(NSString*)placementID extra:(NSDictionary *)extra{
NSLog(@"TJNTopOnViewController::didAutorefreshNativeBannerAdInView:%@ placementID:%@ with extra: %@",bannerView, placementID,extra);
}
-(void) didFailToAutorefreshNativeBannerAdInView:(ATNativeBannerView*)bannerView placementID:(NSString*)placementID extra:(NSDictionary *)extra error:(NSError*)error {
NSLog(@"TJNTopOnViewController::didFailToAutorefreshNativeBannerAdInView:%@ placementID:%@ error:%@", bannerView, placementID, error);
}
- (void)didNativeBannerDeeplinkOrJumpInView:(ATNativeBannerView *)bannerView placementID:(NSString *)placementID extra:(NSDictionary *)extra result:(BOOL)success {
NSLog(@"TJNTopOnViewController::didNativeBannerDeeplinkOrJumpInView:%@ extra:%@", placementID, extra);
}
- (void)didFinishLoadingSplashADWithPlacementID:(NSString *)placementID isTimeout:(BOOL)isTimeout {
NSLog(@"TJNTopOnViewController::didFinishLoadingSplashADWithPlacementID:%@", placementID);
}
- (void)didTimeoutLoadingSplashADWithPlacementID:(NSString *)placementID {
NSLog(@"TJNTopOnViewController::didTimeoutLoadingSplashADWithPlacementID:%@", placementID);
}
#pragma mark - Interstitial delegate method(s)
-(void) didFinishLoadingADWithPlacementID:(NSString *)placementID {
NSLog(@"TJNTopOnViewController::didFinishLoadingADWithPlacementID:%@", placementID);
}
-(void) didFailToLoadADWithPlacementID:(NSString*)placementID error:(NSError*)error {
NSLog(@"TJNTopOnViewController::didFailToLoadADWithPlacementID:%@ error:%@", placementID, error);
}
-(void) interstitialDidShowForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
NSLog(@"TJNTopOnViewController::interstitialDidShowForPlacementID:%@ extra:%@", placementID, extra);
[TenjinSDK topOnImpressionFromDict:extra];
}
-(void) interstitialFailedToShowForPlacementID:(NSString*)placementID error:(NSError*)error extra:(NSDictionary *)extra {
NSLog(@"TJNTopOnViewController::interstitialFailedToShowForPlacementID:%@ error:%@ extra:%@", placementID, error, extra);
}
-(void) interstitialDidFailToPlayVideoForPlacementID:(NSString*)placementID error:(NSError*)error extra:(NSDictionary*)extra {
NSLog(@"TJNTopOnViewController::interstitialDidFailToPlayVideoForPlacementID:%@ error:%@ extra:%@", placementID, error, extra);
}
-(void) interstitialDidStartPlayingVideoForPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {
NSLog(@"TJNTopOnViewController::interstitialDidStartPlayingVideoForPlacementID:%@ extra:%@", placementID, extra);
}
-(void) interstitialDidEndPlayingVideoForPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {
NSLog(@"TJNTopOnViewController::interstitialDidEndPlayingVideoForPlacementID:%@ extra:%@", placementID, extra);
}
-(void) interstitialDidCloseForPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {
NSLog(@"TJNTopOnViewController::interstitialDidCloseForPlacementID:%@ extra:%@", placementID, extra);
}
-(void) interstitialDidClickForPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {
NSLog(@"TJNTopOnViewController::interstitialDidClickForPlacementID:%@ extra:%@", placementID, extra);
}
- (void)interstitialDeepLinkOrJumpForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra result:(BOOL)success {
NSLog(@"TJNTopOnViewController::interstitialDeepLinkOrJumpForPlacementID:%@ extra:%@", placementID, extra);
}
@end- [QUAN TRỌNG] Nếu bạn đang sử dụng các dịch vụ khác (chẳng hạn như Game Analytics) để lấy dữ liệu từ đối tượng đại diện TopOn Impressions, thì đăng ký Tenjin sẽ không còn hoạt động. Trong trường hợp này, bạn phải truyền thủ công dữ liệu hiển thị quảng cáo từ đối tượng đại diện sang TenjinSDK bằng phương thức topOnImpressionFromJSON. Nội dung JSON phải tuân theo định dạng sau:
Dưới đây là một ví dụ về dữ liệu doanh thu theo mức độ hiển thị từ TopOn:
| Tham số | Có bắt buộc không? | Ví dụ |
| adsource_index | Không | 0 |
| loại_mạng_quảng_cáo | Không | Dây |
| is_header_bidding_adsource | Không | Int |
| ecpm_độ_chính_xác | Không | Dây |
| adsource_id | Không | 5656 |
| ecpm | Không | 1 |
| id_kịch_bản | Không | Dây |
| quy tắc tùy chỉnh | Không | Dây |
| kênh con | Không | testSubChannel |
| doanh thu từ nhà xuất bản | Có | 0.001 |
| tên_phần_thưởng_kịch_bản | Không | Dây |
| kênh | Không | testChannel |
| topon_định_dạng_quảng_cáo | Không | Dây |
| segment_id | Không | 0 |
| quốc gia | Không | DE |
| show_id | Không | Dây |
| số_phần_thưởng_kịch_bản | Không | 0 |
| mã_vị_trí_mạng | Không | ca-app-pub-3940256099942544%2F6300978111 |
| topon_mã_vị_trí | Không | Dây |
| ecpm_level | Không | 1 |
| thông_tin_tùy_chỉnh_người_dùng_để_tặng_phần_thưởng | Không | Dây |
| mã_công_ty_mạng | Không | 2 |
| tiền tệ | Không | USD |
| độ chính xác | Không | Dây |