קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
הצגת מודעת עוגן
בדוגמה הזו מוצגת מודעה עוגן באמצעות ספריית Google Publisher Tag (GPT).
מידע נוסף על מודעות עוגן זמין במרכז העזרה של Google Ad Manager.
תצוגה מקדימה של מודעות עוגן
כדי להציג מודעה מוצגת לדוגמה בכל דף שבו מוצגות מודעות עם GPT, אפשר להוסיף את הערך #gamTopAnchorDemo או #gamBottomAnchorDemo לכתובת ה-URL. לדוגמה: https://www.example.com/#gamTopAnchorDemo.
אפשר להשתמש בפונקציונליות הזו כדי להציג תצוגה מקדימה של מודעות עוגן באתר בלי לשנות את הקוד. האפשרות הזו מועילה במיוחד כדי לאמת במהירות איך יהיו נראים הווידאו והתמונה של הווידאו וההתנהגות שלהם במכשירים שונים ובסביבות הפעלה שונות.
הערות לגבי שימוש
כדי להבטיח חוויית משתמש אופטימלית, אנחנו מבקשים להציג מודעות עוגן רק בדפים שתומכים בפורמט בצורה תקינה. לכן, יכול להיות שהפונקציה defineOutOfPageSlot() תחזיר null. צריך לבדוק את המקרה הזה כדי לוודא שלא מבצעים עבודה מיותרת. בשלב זה, אפשר להשתמש במודעות עוגן אם מתקיימים התנאים הבאים:
GPT פועל בחלון העליון.
בדף מותאם לנייד שבו התצוגה מוגדרת ל'רגיל'. בדרך כלל, המשמעות היא שבעלי האתר הגדירו את הערך <meta name="viewport" content="width=device-width,
initial-scale=1"> או ערך דומה ב-<head> של הדף.
אזור התצוגה בכיוון לאורך, ברוחב שבין 320px ל-1000px.
צריך לבקש מודעות עוגן רק בדפים או בסביבות שבהם רוצים שהן יופיעו. אפשר להציג מודעות עוגן במחשבים, בטאבלטים ובמכשירים ניידים.
מודעות עוגן יוצרות מאגר מודעות משלהם. בניגוד לסוגים אחרים של מודעות, לא צריך להגדיר <div> למודעות עוגן. מודעות עוגן יוצרות ומוסיפות באופן אוטומטי מאגר משלהם לדף כשמודעה מתמלאת. יכול להיות שהקונטיינרים האלה יחולו חפיפה על רכיבים אחרים או יחסמו אותם באמצעות מיקום מוחלט או קבוע, לכן מומלץ להימנע מהצבת רכיבים כאלה באזורים שבהם אמורים להופיע עוגנים.
אם משתמשים בארכיטקטורה של בקשה יחידה (SRA) בדף עם כמה משבצות, לא צריך לבצע קריאה ל-display() עד שייווצרו divs של מיקומי מודעות סטטיים. כפי שמוסבר בקטע שיטות מומלצות למודעות, הקריאה הראשונה ל-display() מבקשת את כל מיקומי המודעות שהוגדרו לפני הנקודה הזו. למרות שמיקומי מודעות עוגן לא דורשים <div> מוגדר מראש, מיקומי מודעות סטטיות כן דורשים זאת. קריאה ל-display() לפני שהרכיבים האלה מופיעים בדף עלולה לגרום לאותות באיכות נמוכה יותר, וכתוצאה מכך להקטין את ההכנסות מפרסום. לכן מומלץ לדחות את הקריאה הראשונית עד לאחר הגדרת המשבצות הסטטיות.
רק מודעות עוגן שגלומות במסך יכולות להתעדכן. כשהתצוגה של מיקום מודעה מובילת מכוונת למטה או שעדיין לא גוללו אליה, המערכת מתעלמת מכל הקריאות ל-refresh(). עם זאת, אם משתמשים ב-disableInitialLoad() כדי לשלוט באופן ידני בחיוב וברענון של המודעות, הקריאה הראשונה ל-refresh() תגרום ליצירת בקשה להצגת מודעה, ללא קשר לחשיפה של מיקום המודעה.
[null,null,[],[],[],null,["# Display an anchor ad\n====================\n\nThis example displays an anchor ad using the Google Publisher Tag (GPT) library.\nLearn more about anchor ads in the\n[Google Ad Manager help center](//support.google.com/admanager/answer/10452255).\n\nPreview anchor ads\n------------------\n\nYou can display a demo anchor ad on any page that shows ads with GPT by adding\n`#gamTopAnchorDemo` or `#gamBottomAnchorDemo` to the URL. For example,\n`https://www.example.com/#gamTopAnchorDemo`.\n\nThis functionality can be used to preview anchor ads on your site with no code\nchanges required. This is especially useful to quickly validate how anchors will\nlook and behave on different devices and in different operating environments.\n\nUsage notes\n-----------\n\n- **To ensure an optimal user experience, anchor 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, anchor ads are\n supported if the following conditions are met:\n\n - GPT is running in the top window.\n - On a mobile optimized page where zoom is neutral; typically this means the publisher has `\u003cmeta name=\"viewport\" content=\"width=device-width,\n initial-scale=1\"\u003e` or similar in the `\u003chead\u003e` of the page.\n - Viewport is in a portrait orientation with a width between `320px` and `1000px`.\n- **Only request anchor ads on pages/environments where you want an anchor to\n appear.** Anchor ads are eligible to serve to desktop, tablet, and mobile\n devices.\n\n | **Note:** You can use Chrome DevTools [mobile simulation](//developers.google.com/web/tools/chrome-devtools/device-mode#viewport) to test anchor ads on mobile from a desktop environment.\n- **Anchor ads generate their own ad container.** Unlike other ad types, it's\n not necessary to define a `\u003cdiv\u003e` for anchor ads. Anchor ads automatically\n create and insert their own container into the page when an ad fills. These\n containers may overlap or occlude other elements using absolute or fixed\n positioning, so it's recommended to avoid placing such elements in areas\n where anchors are meant to appear.\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 [Ad 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 prior to that point. Although anchor ad slots\n do not require a predefined `\u003cdiv\u003e`, static ad slots do. Calling `display()`\n before these elements are present on the page can result in lower quality\n signals, reducing monetization. Because of this, we recommend delaying the\n initial call until after the static slots are defined.\n\n- **Only visible anchor ads may be refreshed.** When an anchor ad slot is\n collapsed or not yet scrolled into view, all calls to `refresh()` are\n ignored. If you're using `googletag.setConfig({ disableInitialLoad: true })`\n to manually [control ad loading and refresh](//developers.google.com/publisher-tag/guides/control-ad-loading), however, the\n first call to `refresh()` will trigger an ad request regardless of the slot\n visibility.\n\nSample implementation\n---------------------\n\n[View demo](https://googleads.github.io/google-publisher-tag-samples/display-anchor-ad/js/demo.html) This sample makes use of library features that are not fully supported when running in an iframe. To view a demo of this sample in a new window, click the **View demo** button above. \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-anchor-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-anchor-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-anchor-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-anchor-ad/ts)"]]