קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
כיווץ של מיקומי מודעות ריקים
כברירת מחדל, מיקומי מודעות שלא מולאו יישארו גלויים, וכתוצאה מכך יכול להיות שיופיע בדף שטח ריק. אם אתם יודעים מראש שסביר להניח שאחד או יותר משטחי הפרסום בדף לא יאוכלסו, תוכלו להורות לספריית Google Publisher Tag (GPT) לכווץ אותם.
ההגדרה האופטימלית של התכונה הזו תלויה בתדירות שבה אתם מצפים שהמודעות יאוכלסו:
אם רוב הזמן יהיו מודעות במודעות, השתמשו ב-PubAdsService.collapseEmptyDivs(). בהגדרה הזו, מיקומי המודעות מורחבים כברירת מחדל ומתכווצים רק אם אי אפשר למלא אותם.
אם רוב הזמן המקומות לא יאוכלסו, השתמשו ב-PubAdsService.collapseEmptyDivs(true). בהגדרה הזו, משבצות המודעות מכווצות כברירת מחדל ומתרחבות רק אם אפשר למלא אותן.
מאחר שקריאות ל-API של googletag לא משפיעות עד ש-GPT מתחיל לפעול, כדי למזער את הצורך בזרימה מחדש, צריך גם להגדיר את ה-CSS בדף כך שלתיבות שמכווצות כברירת מחדל יהיו אפס מאפייני גובה ורוחב.
אפשר גם להגדיר שינויים ספציפיים לכל מיקום מודעה, כפי שמתואר בדוגמה שבהמשך, אם יש סיכוי גבוה יותר או נמוך יותר שמיקומים ספציפיים בדף יאוכלסו.
[null,null,[],[],[],null,["# Collapse empty ad slots\n=======================\n\nBy default, ad slots which are not filled are left visible, which may result in\nblank space on your page. If you know ahead of time that one or more ad slots on\nyour page are unlikely to get filled, you can instruct the Google Publisher Tag\n(GPT) library to collapse them.\n| **Caution:** Incorrect use of this feature can cause additional reflow of the content of your page.\n\nThe optimal configuration of this feature will depend on how often you expect ad\nslots to be filled:\n\n1. If slots will be filled most of the time, use [`collapseDiv: 'ON_NO_FILL'`](//developers.google.com/publisher-tag/reference#googletag.config.PageSettingsConfig.collapseDiv). In this configuration, ad slots are expanded by default and collapse only if they cannot be filled.\n2. If slots will not be filled most of the time, use [`collapseDiv: 'BEFORE_FETCH'`](//developers.google.com/publisher-tag/reference#googletag.config.PageSettingsConfig.collapseDiv). In this configuration, ad slots are collapsed by default and only expand if they can be filled.\n\nBecause `googletag` API calls have no effect until GPT begins to run, to\nminimize reflow you will also need to configure the CSS on your page so that\nslots which are collapsed by default have zero dimensions.\n\nIt's also possible to configure per-slot overrides, as shown in the example\nbelow, if specific slots on your page are more or less likely to be filled.\n\nSample implementation\n---------------------\n\n[View demo](https://googleads.github.io/google-publisher-tag-samples/collapse-empty-ad-slots/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/collapse-empty-ad-slots/js) [Report an issue](https://github.com/googleads/google-publisher-tag-samples/issues/new?labels=documentation&template=sample-feedback.md&title=Sample+feedback%3A+collapse-empty-ad-slots/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/collapse-empty-ad-slots/ts) [Report an issue](https://github.com/googleads/google-publisher-tag-samples/issues/new?labels=documentation&template=sample-feedback.md&title=Sample+feedback%3A+collapse-empty-ad-slots/ts)"]]