تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
عرض إعلان مقابل مكافأة
يوضّح هذا المثال استخدام مكتبة "علامة ناشر Google" (GPT) ل
طلب إعلان يضم مكافأة وعرضه. تتيح أشكال الإعلانات التي تضم مكافآت لمستخدمي التطبيقات وصفحات الويب
تلقّي مكافآت مقابل مشاهدة الإعلانات. اطّلِع على مزيد من المعلومات عن الإعلانات التي تضم مكافآت في
مركز مساعدة "مدير إعلانات Google".
يمكنك استخدام أحداث GPT التالية لعرض الإعلانات التي تضم مكافآت والتفاعل معها:
لأغراض هذا المثال، يتم استخدام مربّع حوار مشروط بسيط لطلب
من المستخدم مشاهدة الإعلان الذي يضم مكافأة وعرض المكافأة عند اكتمال العرض. في الواقع، يتحمّل الناشر مسؤولية تنفيذ واجهته الخاصة لتنفيذ هذه المهام.
ملاحظات الاستخدام
لضمان تقديم تجربة مثالية للمستخدم، لا يتم طلب الإعلانات التي تضم مكافآت إلا على
الصفحات التي تتيح استخدام هذا التنسيق بشكلٍ سليم. ولهذا السبب،
قد يعرض defineOutOfPageSlot()
القيمة null
، لذا عليك التحقّق من هذه الحالة لمحاولة
تجنُّب إجراء أي عمل غير ضروري. لا تتوفّر الإعلانات التي تضم مكافأة حاليًا إلا على الصفحات المحسّنة للأجهزة الجوّالة التي تكون فيها ميزة التكبير/التصغير محايدة. ويعني ذلك عادةً أنّ الناشر لديه <meta name="viewport"
content="width=device-width, initial-scale=1">
أو ما شابه ذلك في <head>
الصفحة.
تُنشئ "الإعلانات مقابل مكافأة" خانة إعلان خاصة بها. وعلى عكس أنواع الإعلانات الأخرى، ليس
من الضروري تحديد <div>
للإعلانات التي تضم مكافآت. تنشئ الإعلانات التي تضم مكافآت تلقائيًا
حاوية خاصة بها وتُدرجها في الصفحة عند ملء مساحة إعلان.
مثال على التنفيذ
عرض العرض التوضيحي
[null,null,[],[],[],null,["# Display a rewarded ad\n=====================\n\nThis example demonstrates using the Google Publisher Tag (GPT) library to\nrequest and render a rewarded ad. Rewarded ad formats let app and web users\nreceive rewards for viewing ads. Learn more about rewarded ads in the\n[Google Ad Manager help center](//support.google.com/admanager/answer/9116812).\n\nYou can use the following GPT events to display and interact with rewarded ads:\n\n| Event | Fired when... |\n|-------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------|\n| [RewardedSlotClosedEvent](//developers.google.com/publisher-tag/reference#googletag.events.rewardedslotclosedevent) | A rewarded ad slot has been closed. |\n| [RewardedSlotGrantedEvent](//developers.google.com/publisher-tag/reference#googletag.events.rewardedslotgrantedevent) | A reward has been granted for viewing an ad. |\n| [RewardedSlotReadyEvent](//developers.google.com/publisher-tag/reference#googletag.events.rewardedslotreadyevent) | A rewarded ad slot is ready to be displayed. |\n| [RewardedSlotVideoCompletedEvent](//developers.google.com/publisher-tag/reference#googletag.events.rewardedslotvideocompletedevent) | A rewarded ad slot has finsihed playing a video. |\n\nFor the purpose of this example, a simple modal dialog is used to both prompt\nthe user to view the rewarded ad and to display the reward upon completion. In\npractice, it is the responsibility of the publisher to implement their own\ninterface to accomplish these tasks.\n| **Important:** Before you display a rewarded ad, you must comply with the [policies for ad units that offer rewards](//support.google.com/admanager/answer/7496282) and obtain user consent.\n\nUsage notes\n-----------\n\n- **To ensure an optimal user experience, rewarded ads are only requested on\n pages that properly support the format.** Because of this,\n `defineOutOfPageSlot()` may return `null`; you should check for this case to\n ensure you're not doing any unnecessary work. Currently, rewarded ads are\n only supported on mobile optimized pages where zoom is neutral. Typically\n this means the publisher has `\u003cmeta name=\"viewport\"\n content=\"width=device-width, initial-scale=1\"\u003e` or similar in the `\u003chead\u003e`\n of the page.\n\n- **Rewarded ads generate their own ad slot.** Unlike other ad types, it's not\n necessary to define a `\u003cdiv\u003e` for rewarded ads. Rewarded ads automatically\n create and insert their own container into the page when an ad fills.\n\nSample implementation\n---------------------\n\n[View demo](https://googleads.github.io/google-publisher-tag-samples/display-rewarded-ad/js/demo.html) \n\n### JavaScript\n\nLoading...\n----------\n\nLoading...\n----------\n\n[Improve this sample](https://github.com/googleads/google-publisher-tag-samples/tree/main/dist/display-rewarded-ad/js) [Report an issue](https://github.com/googleads/google-publisher-tag-samples/issues/new?labels=documentation&template=sample-feedback.md&title=Sample+feedback%3A+display-rewarded-ad/js)\n\n### TypeScript\n\nLoading...\n----------\n\nLoading...\n----------\n\n[Improve this sample](https://github.com/googleads/google-publisher-tag-samples/tree/main/dist/display-rewarded-ad/ts) [Report an issue](https://github.com/googleads/google-publisher-tag-samples/issues/new?labels=documentation&template=sample-feedback.md&title=Sample+feedback%3A+display-rewarded-ad/ts)"]]