[null,null,["最后更新时间 (UTC):2025-08-31。"],[[["\u003cp\u003eThis guide explains how to integrate Ad Metadata with the Google Mobile Ads SDK for Android in publisher apps, requiring minimum SDK version 17.0.0 and completed Rewarded Video integration.\u003c/p\u003e\n"],["\u003cp\u003ePublishers can access ad metadata, such as ad ID, title, and duration, by implementing an \u003ccode\u003eAdMetadataListener\u003c/code\u003e and retrieving the metadata bundle via \u003ccode\u003eRewardedVideo.getAdMetadata()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eonAdMetadataChanged()\u003c/code\u003e is triggered when an ad loads or its metadata changes, and it's recommended to wait for this callback before accessing ad metadata as it might not be immediately available.\u003c/p\u003e\n"],["\u003cp\u003eVAST video ads provide specific metadata keys, including AdId, AdTitle, CreativeDurationMs, TraffickingParameters, DealId, AdSystem, CreativeId, MediaURL, and Wrappers, which offer details about the served ad.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eWrappers\u003c/code\u003e key is exclusively present in VAST Wrapper ads and contains information about the ad's wrapper chain, while VAST Inline ads lack this key.\u003c/p\u003e\n"]]],["Publishers using Google Mobile Ads SDK (min. v17.0.0) can access ad metadata for rewarded video ads. Implement `AdMetadataListener` with `RewardedVideoAd.setAdMetadataListener()` to track metadata changes. `onAdMetadataChanged()` triggers when metadata is available, use `RewardedVideo.getAdMetadata()` to access. This returns a Bundle, which for VAST ads contains keys like `AdId`, `AdTitle`, `CreativeDurationMs`, and others. Wrapper ads include a `Wrappers` array with details on each wrapper.\n"],null,["Select platform: [Android](/ad-manager/mobile-ads-sdk/android/ad-metadata \"View this page for the Android platform docs.\") [iOS](/ad-manager/mobile-ads-sdk/ios/ad-metadata \"View this page for the iOS platform docs.\")\n\n\u003cbr /\u003e\n\nThis 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\nJava \n\n```java\nRewardedAd.load(this, \"/21775744923/example/rewarded\", new AdManagerAdRequest.Builder().build(),\n new RewardedAdLoadCallback() {\n @Override\n public void onAdLoaded(@NonNull RewardedAd rewardedAd) {\n mRewardedAd = rewardedAd;\n rewardedAd.setOnAdMetadataChangedListener(new OnAdMetadataChangedListener() {\n @Override\n public void onAdMetadataChanged() {\n Bundle metadata = rewardedAd.getAdMetadata();\n String adId = metadata.getString(\"AdId\");\n }\n });\n }\n });\n```\n\nKotlin \n\n```kotlin\nRewardedAd.load(this, \"/21775744923/example/rewarded\", AdManagerAdRequest.Builder().build(),\n object : RewardedAdLoadCallback() {\n override fun onAdLoaded(rewardedAd: RewardedAd) {\n mRewardedAd = rewardedAd\n rewardedAd.onAdMetadataChangedListener = OnAdMetadataChangedListener {\n val metadata = rewardedAd.adMetadata\n val adId = metadata.getString(\"AdId\")\n }\n }\n })\n```\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."]]