透過集合功能整理內容
你可以依據偏好儲存及分類內容。
顯示獎勵廣告
這個範例示範如何使用 Google 發布商廣告代碼 (GPT) 程式庫要求及顯示獎勵廣告。獎勵廣告格式可讓應用程式和網站使用者透過觀看廣告獲得獎勵。如要進一步瞭解獎勵廣告,請前往 Google Ad Manager 說明中心。
您可以使用下列 GPT 事件,顯示獎勵廣告並與其互動:
為了說明這個範例,我們使用簡單的對話方塊,同時提示使用者觀看獎勵廣告,並在使用者觀看完畢後顯示獎勵。實際上,發布商有責任實作自己的介面,以完成這些工作。
使用須知
為確保提供最佳的使用者體驗,系統只會在妥善支援這類格式的網頁中,請求獎勵廣告。因此,defineOutOfPageSlot()
可能會傳回 null
;您應檢查是否發生這種情況,確保不會執行不必要的作業。目前,只有在縮放比例為中性的行動版最佳化網頁中,才支援獎勵廣告。通常表示發布商在網頁的 <head>
中使用 <meta name="viewport"
content="width=device-width, initial-scale=1">
或類似內容。
獎勵廣告會產生專屬的廣告版位。與其他廣告類型不同,您不必為獎勵廣告定義 <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)"]]