برای اطلاعات بیشتر در مورد تبلیغات ارائه شده، به تغییرات فراداده آگهی در تبلیغات ویدیویی پاداش گوش دهید.
onAdMetadataChanged() درست پس از بارگیری آگهی یا زمانی که ابرداده آن به صورت ناهمزمان پس از بارگیری تغییر می کند فراخوانی می شود. تضمینی وجود ندارد که ابرداده یک آگهی در زمان بارگیری آگهی در دسترس باشد، بنابراین توصیه میکنیم قبل از دسترسی به فراداده آگهی منتظر این تماس باشید.
در اینجا یک نمونه کد نشان می دهد که چگونه می توان ابرداده تبلیغات را بازیابی کرد:
پس از بازیابی متادیتا، میتوانید Bundle را برای یافتن کلیدهایی که برایتان مهم هستند بررسی کنید. انواع مختلف تبلیغات ممکن است دارای کلیدهای فراداده تبلیغات متفاوتی باشند. تبلیغات ویدیویی VAST دارای کلیدهای زیر هستند:
Key
تایپ کنید
توضیحات
AdId
رشته
شناسه آگهی در صورت موجود نبودن خالی است.
AdTitle
رشته
عنوان، اگر مشخص نشده باشد خالی است.
CreativeDurationMs
عدد صحیح
مدت زمان خلاقیت انتخاب شده بر حسب میلی ثانیه، -1 اگر غیرخطی باشد.
TraffickingParameters
رشته
پارامترهای قاچاق، اگر در دسترس نباشد خالی است.
DealId
رشته
اولین شناسه معامله موجود در زنجیره بسته بندی آگهی فعلی، از بالا شروع می شود - اگر در دسترس نباشد خالی است.
AdSystem
رشته
سرور آگهی منبع آگهی، در صورت موجود نبودن خالی است.
CreativeId
رشته
شناسه خلاقیت انتخاب شده برای تبلیغ، در صورت موجود نبودن خالی است.
MediaURL
رشته
URL رسانه انتخاب شده.
Wrappers
آرایه
آرایه با عناصری پر شده است که از درونیترین آگهی بستهبندی شروع میشوند (نزدیک به آگهی درون خطی) و به سمت بیرونیترین آگهی بستهبندی حرکت میکنند. هر عنصر در آرایه یک فرهنگ لغت است که حاوی کلیدها و مقادیر زیر است.
AdId
رشته . شناسه آگهی استفاده شده برای آگهی بسته بندی، اگر در دسترس نباشد خالی است.
AdSystem
رشته . سیستم تبلیغاتی مورد استفاده برای تبلیغات لفاف دار، اگر در دسترس نباشد خالی است.
CreativeId
رشته . شناسه خلاق مورد استفاده برای تبلیغات بسته بندی، اگر در دسترس نباشد خالی است.
تاریخ آخرین بهروزرسانی 2025-08-30 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-08-30 بهوقت ساعت هماهنگ جهانی."],[[["\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."]]