Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Wyświetlanie reklamy pełnoekranowej w grze H5
.
W tym przykładzie wyświetlana jest reklama pełnoekranowa w grze za pomocą biblioteki tagów wydawcy Google (GPT). Reklamy pełnoekranowe w grze to zarządzane przez tag GPT reklamy na całą stronę, które wyświetlasz użytkownikom gier internetowych na podstawie reguły ręcznej. Więcej informacji o reklamach pełnoekranowych w grze znajdziesz w artykule Wyświetlanie reklamy pełnoekranowej w grze H5.
Aby wyświetlać reklamy pełnoekranowe w grze i umożliwiać interakcję z nimi, użyj tych zdarzeń GPT:
Użytkownik zamknął wcześniej wyświetloną reklamę pełnoekranową w grze.
Użyj tego zdarzenia, aby uruchamiać logikę niestandardową po zamknięciu reklamy pełnoekranowej w grze.
Struktury gry
Reklamy pełnoekranowe w grze mogą wyświetlać się na pełnym ekranie lub w ramce z grą, w zależności od jej struktury. Więcej informacji znajdziesz w artykule Struktury gier H5.
W przykładowej implementacji założono, że gra H5 jest renderowana bezpośrednio w oknie na szczycie, przy użyciu struktury Pełny ekran. W tym scenariuszu reklama pełnoekranowa w grze również wyświetla się w trybie pełnoekranowym.
Ten sam kod działa też wtedy, gdy jest umieszczony w ramce podrzędnej, za pomocą struktury iFrame/WebView. Aby ograniczyć reklamę pełnoekranową w grze do obszaru roboczego gry H5, umieść grę w elemencie iframe, jak pokazano w tym przykładzie:
<!doctype html>
<html>
<head>
<!-- The Google Publisher Tag here, if any, will only be responsible for serving ads outside of the H5 game. -->
<title>Page for this example H5 game</title>
<!-- Your <head> content here. -->
</head>
<body>
<span id="example-text">Example H5 game</span>
<!-- Sample code is served here. The Google Publisher Tag loaded in this frame will only be used within the H5 game. -->
<iframe src="https://www.example.com" title="Example game" allow="autoplay"></iframe>
</body>
</html>
Zastosowanie
Aby zapewnić użytkownikom optymalną wygodę, GPT wysyła żądania reklam pełnoekranowych wyświetlanych w grach tylko na stronach, które prawidłowo obsługują ten format. Z powodu tego ograniczenia funkcja defineOutOfPageSlot() może zwracać wartość null. Sprawdź, czy tak nie jest, aby nie wykonywać niepotrzebnych czynności.
Żądaj reklam pełnoekranowych w grach tylko na stronach lub w środowiskach, w których chcesz wyświetlać takie reklamy. Reklamy pełnoekranowe w grach mogą wyświetlać się na komputerach, tabletach i urządzeniach mobilnych.
Reklamy pełnoekranowe w grach generują własny boks reklamowy. W odróżnieniu od innych typów reklam w przypadku reklam pełnoekranowych w grze nie musisz definiować tagu <div>.
Tego typu reklamy automatycznie tworzą i umieszczają na stronie własny kontener, gdy reklama się wypełni.
Reklamy pełnoekranowe w grze są używane tylko raz. Nie możesz odświeżyć boksu reklamy pełnoekranowej w grze. Zamiast tego musisz zniszczyć slot i utworzyć go ponownie, jak pokazano w implementacji przykładowej.
Reklamy pełnoekranowe w grach mają stały limit wyświetleń na użytkownika. Zapobiega to uruchamianiu zdarzenia gamingInterstitialSlotReady częściej niż raz co 30 sekund.
Jeśli korzystasz z architektury z pojedynczym żądaniem (SRA) na stronie z wieloma boksami, nie wywołuj funkcji display(), dopóki nie zostaną utworzone statyczne elementy div boksów reklamowych. Zgodnie ze sprawdzonymi metodami dotyczącymi reklam pierwsze wywołanie funkcji display() wysyła żądanie do każdego boksu reklamowego zdefiniowanego przed tym punktem. Chociaż boksy ręcznych reklam pełnoekranowych w grach nie wymagają wstępnie zdefiniowanego tagu <div>, statyczne boksy reklamowe go wymagają. Wywołanie tagu display(), zanim te elementy pojawią się na stronie, może spowodować obniżenie jakości sygnałów. Zalecamy opóźnienie wywołania do momentu zdefiniowania statycznych slotów.
[[["Łatwo zrozumieć","easyToUnderstand","thumb-up"],["Rozwiązało to mój problem","solvedMyProblem","thumb-up"],["Inne","otherUp","thumb-up"]],[["Brak potrzebnych mi informacji","missingTheInformationINeed","thumb-down"],["Zbyt skomplikowane / zbyt wiele czynności do wykonania","tooComplicatedTooManySteps","thumb-down"],["Nieaktualne treści","outOfDate","thumb-down"],["Problem z tłumaczeniem","translationIssue","thumb-down"],["Problem z przykładami/kodem","samplesCodeIssue","thumb-down"],["Inne","otherDown","thumb-down"]],[],[],[],null,["# Display an H5 gaming interstitial ad\n====================================\n\n| **Important:** Gaming interstitial ads are a limited-access format. For more information, see [Display an H5 gaming interstitial ad](//support.google.com/admanager/answer/14640119).\n\nThis example displays a gaming interstitial ad using the Google Publisher Tag\n(GPT) library. Gaming interstitials are GPT-managed, full-page ads that you\ndisplay to users playing web-based games based on a manual trigger. For more\ninformation about gaming interstitials, see\n[Display an H5 gaming interstitial ad](//support.google.com/admanager/answer/14640119).\n\nTo display and interact with gaming interstitial ads, use the following GPT\nevents:\n\n| Event | Fired when... |\n|------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [`GamingInterstitialSlotReady`](//developers.google.com/publisher-tag/reference#googletag.events.GameManualInterstitialSlotReadyEvent) | A gaming interstitial ad is ready to display to the user. To display the interstitial, call [`makeGameManualInterstitialVisible()`](//developers.google.com/publisher-tag/reference#googletag.events.GameManualInterstitialSlotReadyEvent.makeGameManualInterstitialVisible) on the provided event object. |\n| [`GamingInterstitialSlotClosed`](//developers.google.com/publisher-tag/reference#googletag.events.GameManualInterstitialSlotClosedEvent) | The user closed a previously displayed gaming interstitial ad. Use this event to run custom logic whenever a gaming interstitial is closed. |\n\nGame structures\n---------------\n\nGaming interstitial ads can display either fullscreen or inside the frame of\nyour game, depending on how your game is structured. For more details, see\n[H5 Game structures](//support.google.com/admanager/answer/14637831#h5-game-structures).\n\nThe sample implementation assumes that the H5 game renders directly into the\ntop-most window, using the **Fullscreen** structure. In this scenario, the\ngaming interstitial ad also renders fullscreen.\n\nHowever, this same code also works when placed inside of a child frame, using\nthe **iFrame/WebView** structure. To constrain the gaming interstitial ad to the\nH5 game canvas, place the game in an iFrame, as shown in the following example: \n\n \u003c!doctype html\u003e\n \u003chtml\u003e\n \u003chead\u003e\n \u003c!-- The Google Publisher Tag here, if any, will only be responsible for serving ads outside of the H5 game. --\u003e\n \u003ctitle\u003ePage for this example H5 game\u003c/title\u003e\n \u003c!-- Your \u003chead\u003e content here. --\u003e\n \u003c/head\u003e\n \u003cbody\u003e\n \u003cspan id=\"example-text\"\u003eExample H5 game\u003c/span\u003e\n\n \u003c!-- Sample code is served here. The Google Publisher Tag loaded in this frame will only be used within the H5 game. --\u003e\n \u003ciframe src=\"https://www.example.com\" title=\"Example game\" allow=\"autoplay\"\u003e\u003c/iframe\u003e\n \u003c/body\u003e\n \u003c/html\u003e\n\nUsage notes\n-----------\n\n- **To ensure an optimal user experience, GPT only requests gaming\n interstitial ads on pages that properly support the format.** Due to this\n restriction, `defineOutOfPageSlot()` may return null. You must check for\n this case to ensure you're not doing any unnecessary work.\n\n- **Only request gaming interstitial ads on pages or environments where you\n want an interstitial to appear.** Gaming interstitial ads are eligible to\n serve to desktop, tablet, and mobile devices.\n\n | **Note:** You can use Chrome DevTools mobile simulation to test gaming interstitial ads on mobile from a desktop environment.\n- **Gaming interstitial ads generate their own ad slot.** Unlike other ad\n types, it's not necessary to define a `\u003cdiv\u003e` for gaming interstitial ads.\n These ads automatically create and insert their own container into the page\n when an ad fills.\n\n- **Gaming interstitial ads are one-time use.** You cannot refresh a gaming\n interstitial ad slot. Instead, you must destroy the slot and re-create it,\n as shown in the sample implementation.\n\n- **Gaming interstitial ads have a fixed frequency cap.** The frequency cap\n prevents the `gamingInterstitialSlotReady` event from firing more than once\n every 30 seconds.\n\n- **If using single-request architecture (SRA) on a page with multiple slots,\n don't call `display()` until static ad slots divs are created.** As\n explained in [Ads Best Practices](//developers.google.com/publisher-tag/guides/ad-best-practices#use_single_request_architecture_correctly), the first call to `display()`\n requests every ad slot defined before that point. Although gaming\n interstitial slots don't require a predefined `\u003cdiv\u003e`, static ad slots do.\n Calling `display()` before these elements are present on the page can result\n in lower quality signals. We recommend delaying the initial call until after\n static slots are defined.\n\nSample implementation\n---------------------\n\n[View demo](https://googleads.github.io/google-publisher-tag-samples/display-gaming-interstitial-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-gaming-interstitial-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-gaming-interstitial-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-gaming-interstitial-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-gaming-interstitial-ad/ts)"]]