Page Summary
-
Integrate ad metadata with the Google Mobile Ads iOS SDK using version 7.41.0 or higher and complete the rewarded or rewarded interstitial ads guide prerequisites.
-
To fetch ad metadata, set the ad as its own
GADAdMetadataDelegateand implement theadMetadataDidChange:method. -
Ad metadata may not be available immediately upon loading, so wait for the
adMetadataDidChange:callback before accessing theadMetadataproperty. -
VAST video ads have specific metadata keys like
AdId,AdTitle,CreativeDurationMs, andWrappers, withWrappersonly present for VAST wrapper ads.
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 either of the guides below:
Fetching ad metadata
To have an app know more about ads that are served, set the ad to be its own GADAdMetadataDelegate
. Then you can listen for ad metadata changes by
implementing the adMetadataDidChange:
method on GADAdMetadataDelegate
. Once
this delegate is called, check the adMetadata
property on the ad.
adMetadataDidChange:
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 for a rewarded ad:
@interface
ViewController
()
< GADFullScreenContentDelegate
,
GADAdMetadataDelegate
> @end
@implementation
ViewController
-
(
void
)
loadRewardedAd
{
*
request
=
[
request
];
[
GADRewardedAd
loadWithAdUnitID
:
@"ca-app-pub-3940256099942544/4806952744"
request
:
request
completionHandler
:
^
(
GADRewardedAd
*
ad
,
NSError
*
error
)
{
if
(
error
)
{
NSLog
(
@"Rewarded ad failed to load with error: %@"
,
[
error
localizedDescription
]);
return
;
}
self
.
rewardedAd
=
ad
;
self
.
rewardedAd
.
fullScreenContentDelegate
=
self
;
/// Set the ad to be the delegate of its ad metadata.
self
.
rewardedAd
.
adMetadataDelegate
=
self
;
NSLog
(
@"Rewarded ad loaded."
);
}];
}
/
#
pragma
mark
GADAdMetadataDelegate
implementation
-
(
void
)
adMetadataDidChange
:
(
id<GADAdMetadataProvider>
)
ad
{
NSDictionary<NSString
*
,
id
>
*
adMetadata
=
_rewardedAd
.
adMetadata
;
NSString
*
adId
=
adMetadata
[
@"AdId"
];
}
After retrieving the metadata, you can check the Bundle for the keys you care about. Different types of ads might have different ad metadata keys associated with them. VAST video ads have the following keys:
AdId
AdTitle
CreativeDurationMs
-1
if non-linear.TraffickingParameters
DealId
AdSystem
CreativeId
MediaURL
Wrappers
-
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.

