Share your feedback about the Google Mobile Ads SDK! Take the annual survey.

Ad Metadata

This guide is intended for publishers integrating ad metadata with the Google Mobile Ads iOS SDK.

Prerequisites

  • Google Mobile Ads SDK minimum version 7.41.0.
  • Complete the steps in Rewarded Video.

Fetching Ad Metadata

Some apps may want to know more about ads that are served. You can listen for ad metadata changes on rewarded video ads by implementing the rewardBasedVideoAdMetadataDidChange: method on GADRewardBasedVideoAdDelegate. Once this delegate is called, check the adMetadata property on GADRewardBasedVideoAd for an ad's metadata.

rewardBasedVideoAdMetadataDidChange: is called just after an ad loads or when an ad's metadata changes asynchronously after it loads. It is not guaranteed that ad metadata is available at load time, so we recommend waiting for this callback before accessing an ad's metadata.

Here is a code example showing how to retrieve the ad metadata:

- (void)viewDidLoad {
  [super viewDidLoad];

  [GADRewardBasedVideoAd sharedInstance].delegate = self;
}

- (void)rewardBasedVideoAdMetadataDidChange:(GADRewardBasedVideoAd *)rewardBasedVideoAd {
  NSDictionary<NSString*, id> *adMetadata = rewardBasedVideoAd.adMetadata;
  NSString *adId = adMetadata[@"AdId"];
}

After retrieving the metadata, you can check the Bundle for the keys you care about. Different types of ads may have different ad metadata keys associated with them. VAST video ads have the following keys:

Key Type Description
AdId String The ID of the ad, or the empty string if not available.
AdTitle String The title, empty if not specified.
CreativeDurationMs Integer The selected creative duration in milliseconds, -1 if non-linear.
TraffickingParameters String Trafficking parameters, or the empty string if not available.
DealId String The first deal ID present in the wrapper chain for the current ad, starting from the top, or the empty string if this information is not available.
AdSystem String The source ad server of the ad, empty if not available.
CreativeId String The ID of the selected creative for the ad, empty if not available.
MediaURL String The URL of the selected media.
Wrappers Array The array is populated with elements beginning at the innermost wrapper ad (close to the inline ad) moving outwards to the outermost wrapper ad. Each element in the array is a dictionary that contains the following keys and values.
AdId
String. Ad ID used for wrapper ad, empty if not available.
AdSystem
String. Ad system used for wrapper ad, empty if not available.
CreativeId
String. Creative ID used for wrapper ad, empty if not available.