קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
הצגת מודעה מתגמלת
בדוגמה הזו מוצג שימוש בספריית Google Publisher Tag (GPT) כדי לבקש ולעבד מודעה מתגמלת. פורמטים של מודעות מתגמלות מאפשרים למשתמשים באפליקציות ובאתרים לקבל תגמולים על צפייה במודעות. מידע נוסף על מודעות עם תגמול זמין במרכז העזרה של Google Ad Manager.
אפשר להשתמש באירועי ה-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)"]]