Format Iklan Native Kustom jenis Display dan Pengukuran Terbuka

Jika Anda berencana menggunakan pengukuran terbuka dengan format iklan native khusus yang tidak berisi aset video, Anda akan bertanggung jawab untuk memanggil Measurement API sendiri. Pengukuran terbuka untuk iklan native kustom jenis tampilan format ini hanya didukung oleh versi 7.43.0 dan yang lebih baru. Jika Anda menggunakan format iklan native dengan aset video, Anda tidak perlu — Google Mobile Ads SDK melacak visibilitas aset video di untuk Anda.

Prasyarat

Memuat iklan

Pemuatan iklan itu sama, baik Anda menggunakan pengukuran terbuka maupun tidak. Di sini dalam kasus ini, kita akan menggunakan ViewController sederhana untuk menunjukkan pemuatan GADNativeCustomFormatAd:

@interface OpenMeasurementNativeCustomFormatAdViewController ()
    <GADNativeCustomFormatAdLoaderDelegate> {
  IBOutlet UIView *_parentView;
  GADAdLoader *_adLoader;
  GADNativeCustomFormatAd *_customTemplateAd;
  MySimpleNativeAdView *_simpleNativeAdView;
}

@end

@implementation OpenMeasurementNativeCustomFormatAdViewController

- (void) viewDidLoad {
  [super viewDidLoad];

  _adLoader = [[GADAdLoader alloc] initWithAdUnitID:@"your ad unit ID"
                                 rootViewController:self
                                            adTypes:@[ kGADAdLoaderAdTypeNativeCustomFormat ]
                                            options:nil];
  _adLoader.delegate = self;
  [self loadAd];
}

- (void) loadAd {
  GAMRequest *request = [GAMRequest request];
  [_adLoader loadRequest:request];
}
...
@end

Daftarkan tampilan dan mulai mengukur

Saat menampilkan GADNativeCustomFormatAd, Anda harus mendaftarkan iklan kustom Anda tampilan dengan GADNativeTemplateAd menggunakan displayAdMeasurement.view saat ini.

Anda juga harus secara eksplisit memberi tahu SDK untuk mulai mengukur iklan. Untuk melakukannya: panggil metode startWithError: di properti displayAdMeasurement dari GADNativeCustomFormatAd. startWithError: harus dipanggil dari layar utama thread, dan panggilan berikutnya tidak akan berpengaruh.

@implementation OpenMeasurementNativeCustomFormatAdViewController
...
#pragma mark - GADNativeCustomFormatAdLoaderDelegate

- (void) adLoader:(GADAdLoader *) adLoader
    didReceiveNativeCustomFormatAd:(GADNativeCustomFormatAd *)nativeCustomFormatAd {
  NSLog(@"Received custom native ad: %@", nativeCustomFormatAd);

  _customTemplateAd = nativeCustomFormatAd;

  // Put the custom native ad on screen.
  _simpleNativeAdView =
    [[NSBundle mainBundle] loadNibNamed:@"SimpleCustomNativeAdView"
                                  owner:nil
                                options:nil]
    .firstObject;
  [_parentView addSubview:_simpleNativeAdView];
  [_simpleNativeAdView populateWithCustomNativeAd:_customTemplateAd];

  // Set the top-level native ad view on the GADNativeCustomFormatAd so the
  // Google Mobile Ads SDK can track viewability for that view.
  _customTemplateAd.displayAdMeasurement.view = _simpleNativeAdView;
  // Begin measuring your impressions and clicks.
  NSError *error = nil;
  [_customTemplateAd.displayAdMeasurement startWithError:&error];

  if (error) {
    NSLog(@"Failed to start the display measurement.");
  }
}
...
@end

Itu saja, tidak ada lagi yang lain. Setelah Anda merilis aplikasi, Anda akan mulai menerima data pengukuran, namun data Anda tidak akan disertifikasi hingga Anda melalui Sertifikasi IAB {i>checkout<i}.