Để thảo luận và đưa ra ý kiến phản hồi về các sản phẩm của chúng tôi, hãy tham gia kênh Discord chính thức của Ad Manager trong máy chủ Cộng đồng quảng cáo và đo lường của Google.
Để biết thêm về quảng cáo được phân phát, hãy theo dõi các thay đổi về siêu dữ liệu quảng cáo trên quảng cáo dạng video có tặng thưởng.
onAdMetadataChanged() được gọi ngay sau khi một quảng cáo tải hoặc khi siêu dữ liệu của quảng cáo thay đổi không đồng bộ sau khi quảng cáo tải. Không có gì đảm bảo rằng siêu dữ liệu của quảng cáo sẽ có sẵn tại thời điểm quảng cáo được tải, vì vậy, bạn nên đợi lệnh gọi lại này trước khi truy cập vào siêu dữ liệu của quảng cáo.
Sau đây là ví dụ về mã cho thấy cách truy xuất siêu dữ liệu quảng cáo:
Sau khi truy xuất siêu dữ liệu, bạn có thể kiểm tra Bundle cho các khoá mà bạn quan tâm. Các loại quảng cáo khác nhau có thể có các khoá siêu dữ liệu quảng cáo khác nhau được liên kết với chúng. Quảng cáo dạng video VAST có các khoá sau:
Key
Loại
Mô tả
AdId
Chuỗi
Mã nhận dạng của quảng cáo, để trống nếu không có.
AdTitle
Chuỗi
Tiêu đề, để trống nếu không được chỉ định.
CreativeDurationMs
Số nguyên
Thời lượng của mẫu quảng cáo đã chọn tính bằng mili giây, -1 nếu là mẫu quảng cáo phi tuyến tính.
TraffickingParameters
Chuỗi
Tham số phân phối, trống nếu không có.
DealId
Chuỗi
Mã giao dịch đầu tiên có trong chuỗi trình bao bọc cho quảng cáo hiện tại, bắt đầu từ trên cùng – trống nếu không có.
AdSystem
Chuỗi
Máy chủ quảng cáo nguồn của quảng cáo, trống nếu không có.
CreativeId
Chuỗi
Mã nhận dạng của mẫu quảng cáo đã chọn cho quảng cáo, trống nếu không có.
MediaURL
Chuỗi
URL của nội dung nghe nhìn đã chọn.
Wrappers
Mảng
Mảng này được điền sẵn các phần tử bắt đầu từ quảng cáo có trình bao bọc trong cùng (gần với quảng cáo trong dòng) di chuyển ra ngoài đến quảng cáo có trình bao bọc ngoài cùng. Mỗi phần tử trong mảng là một từ điển chứa các khoá và giá trị sau.
AdId
Chuỗi. Mã quảng cáo dùng cho quảng cáo bao bọc, để trống nếu không có.
AdSystem
Chuỗi. Hệ thống quảng cáo được dùng cho quảng cáo bao bọc, để trống nếu không có.
CreativeId
Chuỗi. Mã mẫu quảng cáo dùng cho quảng cáo bao bọc, trống nếu không có.
[null,null,["Cập nhật lần gần đây nhất: 2025-08-31 UTC."],[[["\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."]]