To know more about served ads, listen for ad metadata changes on rewarded video
ads.
onAdMetadataChanged() is called just after an ad loads or when its
metadata changes asynchronously after it loads. It is not guaranteed
that an ad's metadata will be available at the time the ad is
loaded, 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:
Replace AD_UNIT_ID ad unit. For example,
/21775744923/example/rewarded for rewarded ads.
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, empty 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, empty if not available.
DealId
String
The first deal ID present in the wrapper chain for the current ad,
starting from the top--empty if 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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-09 UTC."],[],[],null,["This guide is intended for publishers integrating Ad Metadata with the Google\nMobile Ads SDK for Android.\n\nPrerequisites\n\n- Minimum version 17.0.0 of the Google Mobile Ads SDK.\n- Complete the steps in [Rewarded Video](/ad-manager/mobile-ads-sdk/android/rewarded-video).\n\nFetching ad metadata\n\nTo know more about served ads, listen for ad metadata changes on rewarded video\nads.\n\n`onAdMetadataChanged()` is called just after an ad loads or when its\nmetadata changes asynchronously after it loads. It is not guaranteed\nthat an ad's metadata will be available at the time the ad is\nloaded, so we recommend waiting for this callback before accessing an ad's\nmetadata.\n\nHere is a code example showing how to retrieve the ad metadata: \n\nKotlin \n\n RewardedAd.load(\n AdRequest.Builder(\"\u003cvar class=\"readonly\" translate=\"no\"\u003eAD_UNIT_ID\u003c/var\u003e\").build(),\n object : AdLoadCallback\u003cRewardedAd\u003e {\n override fun onAdLoaded(ad: RewardedAd) {\n ...\n ad.adEventCallback = object : RewardedAdEventCallback {\n override fun onAdMetadataChanged() {\n val metadata = ad.adMetadata\n val adId = metadata.getString(\"AdId\")\n }\n }\n }\n })\n\nJava \n\n RewardedAd.load(\n new AdRequest.Builder(\"\u003cvar class=\"readonly\" translate=\"no\"\u003eAD_UNIT_ID\u003c/var\u003e\").build(),\n new AdLoadCallback\u003cRewardedAd\u003e() {\n @Override\n public void onAdLoaded(@NonNull RewardedAd rewardedAd) {\n Rewarded.this.rewardedAd = rewardedAd;\n ...\n rewardedAd.setAdEventCallback(new RewardedAdEventCallback() {\n @Override\n public void onAdMetadataChanged() {\n Bundle metadata = rewardedAd.getAdMetadata();\n String adId = metadata.getString(\"AdId\");\n }\n });\n };\n };\n );\n\nReplace \u003cvar class=\"readonly\" translate=\"no\"\u003eAD_UNIT_ID\u003c/var\u003e ad unit. For example,\n`/21775744923/example/rewarded` for rewarded ads.\n\nAfter retrieving the metadata, you can check the Bundle for the keys you care\nabout. Different types of ads may have different ad metadata keys associated\nwith them. VAST video ads have the following keys:\n\n| `Key` | Type | Description |\n|-------------------------|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `AdId` | String | The ID of the ad, empty if not available. |\n| `AdTitle` | String | The title, empty if not specified. |\n| `CreativeDurationMs` | Integer | The selected creative duration in milliseconds, -1 if non-linear. |\n| `TraffickingParameters` | String | Trafficking parameters, empty if not available. |\n| `DealId` | String | The first deal ID present in the wrapper chain for the current ad, starting from the top--empty if not available. |\n| `AdSystem` | String | The source ad server of the ad, empty if not available. |\n| `CreativeId` | String | The ID of the selected creative for the ad, empty if not available. |\n| `MediaURL` | String | The URL of the selected media. |\n| `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. |\n\n| **Note:** Only VAST Wrapper ads will have `Wrappers` key in the ad metadata. VAST Inline ads do not contain `Wrappers` metadata."]]