این مرجع از نماد TypeScript برای توصیف انواع استفاده می کند. جدول زیر با مثال توضیح مختصری ارائه می دهد.
عبارت را تایپ کنید | |
---|---|
string | نوع رشته ابتدایی. |
string[] | یک نوع آرایه، که در آن مقادیر فقط ممکن است رشته باشند. |
number | string | یک نوع اتحادیه، که در آن مقدار ممکن است یک عدد یا یک رشته باشد. |
Array<number | string> | یک نوع آرایه، که در آن مقادیر یک نوع پیچیده (اتحادیه) هستند. |
[number, string] | یک نوع تاپل، که در آن مقدار یک آرایه دو عنصری است که باید یک عدد و یک رشته به ترتیب داشته باشد. |
Slot | یک نوع شی، که در آن مقدار یک نمونه از googletag.Slot است. |
() => void | یک نوع تابع بدون آرگومان تعریف شده و بدون مقدار بازگشتی. |
برای اطلاعات بیشتر در مورد انواع پشتیبانی شده و عبارات نوع، به راهنمای TypeScript مراجعه کنید.
حاشیه نویسی را تایپ کنید
دو نقطه بعد از یک متغیر، نام پارامتر، نام ویژگی یا امضای تابع نشان دهنده یک نوع حاشیه نویسی است. حاشیه نویسی نوع، انواعی را که عنصر در سمت چپ کولون می تواند بپذیرد یا برگرداند، توصیف می کند. جدول زیر نمونه هایی از حاشیه نویسی نوع را نشان می دهد که ممکن است در این مرجع مشاهده کنید.
حاشیه نویسی را تایپ کنید | |
---|---|
param: string | نشان می دهد که param یک مقدار رشته را می پذیرد یا برمی گرداند. این نحو برای متغیرها، پارامترها، خصوصیات و انواع برگشتی استفاده می شود. |
param?: number | string | نشان می دهد که param اختیاری است، اما در صورت مشخص شدن یک عدد یا یک رشته را می پذیرد. این نحو برای پارامترها و خصوصیات استفاده می شود. |
...params: Array<() => void> | نشان می دهد که params یک پارامتر استراحت است که توابع را می پذیرد. پارامترهای Rest تعداد نامحدودی از مقادیر از نوع مشخص شده را می پذیرند. |
googletag
فضاهای نام | |
---|---|
config | رابط پیکربندی اصلی برای تنظیمات سطح صفحه. |
enums | این فضای نامی است که GPT برای انواع enum استفاده می کند. |
events | این فضای نامی است که GPT برای رویدادها استفاده می کند. |
secure Signals | این فضای نامی است که GPT برای مدیریت سیگنال های امن استفاده می کند. |
رابط ها | |
---|---|
Command Array | آرایه فرمان دنباله ای از توابع را می پذیرد و آنها را به ترتیب فراخوانی می کند. |
Companion Ads Service | سرویس تبلیغات همراه. |
Privacy Settings Config | شی پیکربندی برای تنظیمات حریم خصوصی. |
Pub Ads Service | سرویس تبلیغات ناشر. |
Response Information | شیئی که نشان دهنده یک پاسخ آگهی واحد است. |
Rewarded Payload | یک شی که نشان دهنده پاداش مرتبط با یک تبلیغ پاداش است. |
Service | کلاس سرویس پایه که شامل متدهای مشترک برای همه سرویس ها است. |
Size Mapping Builder | سازنده برای اشیاء مشخصات نقشه برداری اندازه. |
Slot | Slot یک شی است که نشان دهنده یک جایگاه آگهی در یک صفحه است. |
نام مستعار را تایپ کنید | |
---|---|
General Size | یک پیکربندی اندازه معتبر برای یک اسلات، که می تواند یک یا چند اندازه باشد. |
Multi Size | لیستی از اندازه های معتبر تکی. |
Named Size | اندازه های نامگذاری شده ای که یک اسلات می تواند داشته باشد. |
Single Size | یک اندازه معتبر برای یک اسلات. |
Single Size Array | آرایه ای از دو عدد که نشان دهنده [عرض، ارتفاع] است. |
Size Mapping | نگاشت اندازه نمایش به اندازه تبلیغات. |
Size Mapping Array | لیستی از نگاشت اندازه |
متغیرها | |
---|---|
api Ready | پرچمی که نشان می دهد GPT API بارگیری شده و آماده فراخوانی است. |
cmd | ارجاع به صف فرمان جهانی برای اجرای ناهمزمان تماس های مربوط به GPT. |
pubads Ready | پرچمی که نشان می دهد PubAdsService فعال، بارگیری شده و کاملاً عملیاتی است. |
secure Signal Providers | ارجاع به آرایه ارائه دهندگان سیگنال امن. |
توابع | |
---|---|
companion Ads | مرجعی را به CompanionAdsService برمی گرداند. |
define Out Of Page Slot | با مسیر واحد آگهی داده شده، یک جایگاه تبلیغاتی خارج از صفحه ایجاد می کند. |
define Slot | یک جایگاه تبلیغاتی با یک مسیر و اندازه واحد تبلیغاتی معین می سازد و آن را با شناسه یک عنصر div در صفحه ای که حاوی آگهی است مرتبط می کند. |
destroy Slots | اسلات های داده شده را از بین می برد و تمام اشیاء مرتبط و مراجع آن اسلات ها را از GPT حذف می کند. |
disable Publisher Console | کنسول Google Publisher را غیرفعال می کند. |
display | به خدمات اسلات دستور می دهد تا اسلات را ارائه دهند. |
enable Services | همه سرویسهای GPT را که برای اسلات تبلیغاتی در صفحه تعریف شدهاند، فعال میکند. |
get Config | گزینه های پیکربندی کلی را برای صفحه تنظیم شده توسط setConfig دریافت می کند. |
get Version | نسخه فعلی GPT را برمیگرداند. |
open Console | Google Publisher Console را باز می کند. |
pubads | مرجعی را به PubAdsService برمی گرداند. |
set Ad Iframe Title | عنوان را برای همه iframe های کانتینر آگهی ایجاد شده توسط PubAdsService از این مرحله به بعد تنظیم می کند. |
set Config | گزینه های پیکربندی کلی صفحه را تنظیم می کند. |
size Mapping | یک SizeMappingBuilder جدید ایجاد می کند. |
نام مستعار را تایپ کنید
جنرال سایز
GeneralSize : SingleSize | MultiSize
چند سایز
MultiSize : SingleSize []
NamedSize
NamedSize : "fluid" | [ "fluid" ]
- مایع : ظرف تبلیغات 100% عرض div والد را می گیرد و سپس ارتفاع آن را تغییر می دهد تا متناسب با محتوای خلاقانه باشد. مشابه رفتار عناصر بلوک معمولی در یک صفحه. برای تبلیغات بومی استفاده می شود ( مقاله مرتبط را ببینید). توجه داشته باشید که هم
fluid
و هم['fluid']
اشکال قابل قبولی برای اعلام اندازه شکاف به عنوان سیال هستند.
تک سایز
SingleSize : SingleSizeArray | NamedSize
SingleSizeArray
SingleSizeArray : [ number , number ]
SizeMapping
SizeMapping : [ SingleSizeArray , GeneralSize ]
SizeMappingArray
SizeMappingArray : SizeMapping []
متغیرها
Const
apiReady
apiReady : boolean | undefined
undefined
است.توجه داشته باشید که روش توصیه شده برای مدیریت async این است که از googletag.cmd برای قرار دادن تماسها در صف برای زمانی که GPT آماده است استفاده کنید. این تماسهای برگشتی نیازی به بررسی googletag.apiReady ندارند، زیرا اجرای آنها پس از راهاندازی API تضمین میشود.
cmd Const
cmd : ( ( this : typeof globalThis ) => void ) [] | CommandArray
متغیر
googletag.cmd
به یک آرایه خالی جاوا اسکریپت توسط نحو تگ GPT در صفحه مقداردهی اولیه می شود و cmd.push
روش استاندارد Array.push
است که یک عنصر را به انتهای آرایه اضافه می کند. هنگامی که جاوا اسکریپت GPT بارگذاری می شود، از طریق آرایه نگاه می کند و همه توابع را به ترتیب اجرا می کند. سپس اسکریپت cmd
با یک شی CommandArray جایگزین می کند که متد فشار آن برای اجرای آرگومان تابع ارسال شده به آن تعریف شده است. این مکانیسم به GPT اجازه میدهد تا تأخیر درک شده را با واکشی ناهمزمان جاوا اسکریپت کاهش دهد و در عین حال به مرورگر اجازه میدهد به رندر صفحه ادامه دهد.- مثال
جاوا اسکریپت
googletag.cmd.push(() => { googletag.defineSlot("/1234567/sports", [160, 600]).addService(googletag.pubads()); });
جاوا اسکریپت (میراث)
googletag.cmd.push(function () { googletag.defineSlot("/1234567/sports", [160, 600]).addService(googletag.pubads()); });
TypeScript
googletag.cmd.push(() => { googletag.defineSlot("/1234567/sports", [160, 600])!.addService(googletag.pubads()); });
Const
pubadsReady
pubadsReady : boolean | undefined
undefined
است. SecuritySignalProviders
secureSignalProviders : SecureSignalProvider [] | SecureSignalProvidersArray | undefined
آرایه ارائه دهندگان سیگنال امن، دنباله ای از توابع تولید کننده سیگنال را می پذیرد و آنها را به ترتیب فراخوانی می کند. در نظر گرفته شده است که جایگزین آرایه استانداردی شود که برای قرار دادن توابع مولد سیگنال برای فراخوانی پس از بارگیری GPT استفاده می شود.
- مثال
جاوا اسکریپت
window.googletag = window.googletag || { cmd: [] }; googletag.secureSignalProviders = googletag.secureSignalProviders || []; googletag.secureSignalProviders.push({ id: "collector123", collectorFunction: () => { return Promise.resolve("signal"); }, });
جاوا اسکریپت (میراث)
window.googletag = window.googletag || { cmd: [] }; googletag.secureSignalProviders = googletag.secureSignalProviders || []; googletag.secureSignalProviders.push({ id: "collector123", collectorFunction: function () { return Promise.resolve("signal"); }, });
TypeScript
window.googletag = window.googletag || { cmd: [] }; googletag.secureSignalProviders = googletag.secureSignalProviders || []; googletag.secureSignalProviders.push({ id: "collector123", collectorFunction: () => { return Promise.resolve("signal"); }, });
- همچنین ببینید
توابع
companionAds
companionAds ( ) : CompanionAdsService
برمی گرداند | |
---|---|
CompanionAdsService | سرویس تبلیغات همراه. |
تعریف OutOfPageSlot
defineOutOfPageSlot ( adUnitPath : string , div ?: string | OutOfPageFormat ) : Slot | null
برای تبلیغات سفارشی خارج از صفحه،
div
شناسه عنصر div است که حاوی آگهی است. برای جزئیات بیشتر به مقاله در مورد خلاقیت های خارج از صفحه مراجعه کنید.برای تبلیغات خارج از صفحه مدیریت شده GPT،
div
یک OutOfPageFormat پشتیبانی شده است.- مثال
جاوا اسکریپت
// Define a custom out-of-page ad slot. googletag.defineOutOfPageSlot("/1234567/sports", "div-1"); // Define a GPT managed web interstitial ad slot. googletag.defineOutOfPageSlot("/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL);
جاوا اسکریپت (میراث)
// Define a custom out-of-page ad slot. googletag.defineOutOfPageSlot("/1234567/sports", "div-1"); // Define a GPT managed web interstitial ad slot. googletag.defineOutOfPageSlot("/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL);
TypeScript
// Define a custom out-of-page ad slot. googletag.defineOutOfPageSlot("/1234567/sports", "div-1"); // Define a GPT managed web interstitial ad slot. googletag.defineOutOfPageSlot("/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL);
- همچنین ببینید
پارامترها | |
---|---|
adUnitPath : string | مسیر کامل واحد تبلیغات با کد شبکه و کد واحد تبلیغات. |
| شناسه div که حاوی این واحد تبلیغات یا OutOfPageFormat است. |
برمی گرداند | |
---|---|
Slot | null | اسلات تازه ایجاد شده، یا اگر شکافی ایجاد نشود، null . |
تعریف اسلات
defineSlot ( adUnitPath : string , size : GeneralSize , div ?: string ) : Slot | null
- مثال
جاوا اسکریپت
googletag.defineSlot("/1234567/sports", [728, 90], "div-1");
جاوا اسکریپت (میراث)
googletag.defineSlot("/1234567/sports", [728, 90], "div-1");
TypeScript
googletag.defineSlot("/1234567/sports", [728, 90], "div-1");
- همچنین ببینید
پارامترها | |
---|---|
adUnitPath : string | مسیر کامل واحد تبلیغات با کد شبکه و کد واحد. |
size : GeneralSize | عرض و ارتفاع شکاف اضافه شده. این اندازه ای است که در درخواست تبلیغ استفاده می شود اگر نگاشت اندازه واکنشگرا ارائه نشده باشد یا اندازه نمای درگاه کوچکتر از کوچکترین اندازه ارائه شده در نقشه باشد. |
| شناسه div که حاوی این واحد تبلیغاتی است. |
برمی گرداند | |
---|---|
Slot | null | اسلات تازه ایجاد شده، یا اگر شکافی ایجاد نشود، null . |
اسلات ها را نابود می کند
destroySlots ( slots ?: Slot [] ) : boolean
فراخوانی این API در یک اسلات، آگهی را پاک می کند و شی شکاف را از حالت داخلی که توسط GPT حفظ می شود، حذف می کند. فراخوانی هر تابع دیگری در شیء شکاف منجر به رفتار نامشخص می شود. توجه داشته باشید که اگر صفحه ناشر به آن اشاره ای داشته باشد، ممکن است مرورگر همچنان حافظه مرتبط با آن اسلات را آزاد نکند. فراخوانی این API باعث می شود که div مرتبط با آن اسلات برای استفاده مجدد در دسترس باشد.
به ویژه، از بین بردن یک اسلات، آگهی را از نمای صفحه طولانی مدت GPT حذف میکند، بنابراین درخواستهای آینده تحت تأثیر موانع یا استثناهای رقابتی مربوط به این آگهی قرار نمیگیرند. عدم فراخوانی این تابع قبل از حذف div شکاف از صفحه منجر به رفتار نامشخص می شود.
- مثال
جاوا اسکریپت
// The calls to construct an ad and display contents. const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1"); googletag.display("div-1"); const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2"); googletag.display("div-2"); // This call to destroy only slot1. googletag.destroySlots([slot1]); // This call to destroy both slot1 and slot2. googletag.destroySlots([slot1, slot2]); // This call to destroy all slots. googletag.destroySlots();
جاوا اسکریپت (میراث)
// The calls to construct an ad and display contents. var slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1"); googletag.display("div-1"); var slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2"); googletag.display("div-2"); // This call to destroy only slot1. googletag.destroySlots([slot1]); // This call to destroy both slot1 and slot2. googletag.destroySlots([slot1, slot2]); // This call to destroy all slots. googletag.destroySlots();
TypeScript
// The calls to construct an ad and display contents. const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1")!; googletag.display("div-1"); const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2")!; googletag.display("div-2"); // This call to destroy only slot1. googletag.destroySlots([slot1]); // This call to destroy both slot1 and slot2. googletag.destroySlots([slot1, slot2]); // This call to destroy all slots. googletag.destroySlots();
پارامترها | |
---|---|
| آرایه ای از اسلات برای از بین بردن. آرایه اختیاری است. تمام اسلات ها در صورت نامشخص بودن از بین می روند. |
برمی گرداند | |
---|---|
boolean | true اگر شکاف ها از بین رفته باشند، در غیر این صورت false . |
disablePublisherConsole
disablePublisherConsole ( ) : void
- همچنین ببینید
نمایش داده شود
display ( divOrSlot : string | Element | Slot ) : void
اگر از معماری تک درخواست (SRA) استفاده شود، تمام اسلات های تبلیغاتی واکشی نشده در زمانی که این روش فراخوانی می شود، به یکباره واکشی می شوند. برای اینکه یک شکاف آگهی نمایش داده نشود، کل div باید حذف شود.
- همچنین ببینید
پارامترها | |
---|---|
divOrSlot : string | Element | Slot | شناسه عنصر div حاوی شکاف آگهی یا عنصر div یا شی شکاف. اگر یک عنصر div ارائه شده باشد، باید یک ویژگی 'id' داشته باشد که با شناسه ارسال شده به defineSlot مطابقت داشته باشد. |
enableServices
enableServices ( ) : void
getConfig
getConfig ( keys : string | string [] ) : Pick < PageSettingsConfig , "adsenseAttributes" | "disableInitialLoad" | "targeting" >
همه ویژگی های
setConfig()
توسط این روش پشتیبانی نمی شوند. ویژگی های پشتیبانی شده عبارتند از:- مثال
جاوا اسکریپت
// Get the value of the `targeting` setting. const targetingConfig = googletag.getConfig("targeting"); // Get the value of the `adsenseAttributes` and `disableInitialLoad` settings. const config = googletag.getConfig(["adsenseAttributes", "disableInitialLoad"]);
جاوا اسکریپت (میراث)
// Get the value of the `targeting` setting. var targetingConfig = googletag.getConfig("targeting"); // Get the value of the `adsenseAttributes` and `disableInitialLoad` settings. var config = googletag.getConfig(["adsenseAttributes", "disableInitialLoad"]);
TypeScript
// Get the value of the `targeting` setting. const targetingConfig = googletag.getConfig("targeting"); // Get the value of the `adsenseAttributes` and `disableInitialLoad` settings. const config = googletag.getConfig(["adsenseAttributes", "disableInitialLoad"]);
پارامترها | |
---|---|
keys : string | string [] | کلیدهای تنظیمات پیکربندی را دریافت کنید. |
برمی گرداند | |
---|---|
Pick < PageSettingsConfig , "adsenseAttributes" | "disableInitialLoad" | "targeting" > | گزینه های پیکربندی برای اسلات. |
getVersion
getVersion ( ) : string
- همچنین ببینید
برمی گرداند | |
---|---|
string | رشته نسخه GPT در حال اجرا. |
openConsole
openConsole ( div ?: string ) : void
- مثال
جاوا اسکریپت
// Calling with div ID. googletag.openConsole("div-1"); // Calling without div ID. googletag.openConsole();
جاوا اسکریپت (میراث)
// Calling with div ID. googletag.openConsole("div-1"); // Calling without div ID. googletag.openConsole();
TypeScript
// Calling with div ID. googletag.openConsole("div-1"); // Calling without div ID. googletag.openConsole();
- همچنین ببینید
پارامترها | |
---|---|
| شناسه div اسلات آگهی. این مقدار اختیاری است. هنگامی که ارائه شد، کنسول ناشر تلاش می کند تا با جزئیات فضای تبلیغاتی مشخص شده باز شود. |
pubads
pubads ( ) : PubAdsService
برمی گرداند | |
---|---|
PubAdsService | سرویس تبلیغات ناشر. |
setAdIframeTitle
setAdIframeTitle ( title : string ) : void
- مثال
جاوا اسکریپت
googletag.setAdIframeTitle("title");
جاوا اسکریپت (میراث)
googletag.setAdIframeTitle("title");
TypeScript
googletag.setAdIframeTitle("title");
پارامترها | |
---|---|
title : string | عنوان جدید برای همه iframe های کانتینر تبلیغاتی. |
setConfig
setConfig ( config : PageSettingsConfig ) : void
پارامترها | |
---|---|
config : PageSettingsConfig |
اندازه نقشه برداری
sizeMapping ( ) : SizeMappingBuilder
- همچنین ببینید
برمی گرداند | |
---|---|
SizeMappingBuilder | یک سازنده جدید |
googletag.CommandArray
روش ها | |
---|---|
push | دنباله ای از توابع مشخص شده در آرگومان ها را به ترتیب اجرا می کند. |
روش ها
فشار دهید
push ( ... f : ( ( this : typeof globalThis ) => void ) [] ) : number
- مثال
جاوا اسکریپت
googletag.cmd.push(() => { googletag.defineSlot("/1234567/sports", [160, 600]).addService(googletag.pubads()); });
جاوا اسکریپت (میراث)
googletag.cmd.push(function () { googletag.defineSlot("/1234567/sports", [160, 600]).addService(googletag.pubads()); });
TypeScript
googletag.cmd.push(() => { googletag.defineSlot("/1234567/sports", [160, 600])!.addService(googletag.pubads()); });
پارامترها | |
---|---|
| یک تابع جاوا اسکریپت که باید اجرا شود. اتصال زمان اجرا همیشه globalThis خواهد بود. در نظر بگیرید که یک تابع فلش را برای حفظ this مقدار از بافت واژگانی محصور در نظر بگیرید. |
برمی گرداند | |
---|---|
number | تعداد دستورات پردازش شده تاکنون این با مقدار برگشتی Array.push (طول فعلی آرایه) سازگار است. |
googletag.CompanionAdsService
Service
را گسترش می دهدروش ها | |
---|---|
add Event Listener | شنوندهای را ثبت میکند که به شما امکان میدهد یک تابع جاوا اسکریپت را هنگامی که یک رویداد GPT خاص در صفحه اتفاق میافتد تنظیم و فراخوانی کنید. از |
get Slots | لیست اسلات های مرتبط با این سرویس را دریافت کنید. از |
remove Event Listener | شنونده قبلا ثبت نام شده را حذف می کند. از |
set Refresh Unfilled Slots | تعیین می کند که آیا اسلات های همراهی که پر نشده اند به طور خودکار پر شوند یا خیر. |
- همچنین ببینید
روش ها
setRefreshUnfilledSlots
setRefreshUnfilledSlots ( value : boolean ) : void
این روش را می توان چندین بار در طول عمر صفحه فراخوانی کرد تا Backfill را روشن و خاموش کند. فقط اسلات هایی که در PubAdsService نیز ثبت شده باشند پر می شوند. به دلیل محدودیتهای خطمشی، این روش برای پر کردن جایگاههای خالی همراه هنگام ارائه یک ویدیوی Ad Exchange طراحی نشده است.
- مثال
جاوا اسکریپت
googletag.companionAds().setRefreshUnfilledSlots(true);
جاوا اسکریپت (میراث)
googletag.companionAds().setRefreshUnfilledSlots(true);
TypeScript
googletag.companionAds().setRefreshUnfilledSlots(true);
پارامترها | |
---|---|
value : boolean | true برای پر کردن خودکار اسلات های پر نشده، false تا بدون تغییر باقی بماند. |
googletag.PrivacySettingsConfig
خواص | |
---|---|
child Directed Treatment ? | نشان میدهد که آیا این صفحه باید بهعنوان کارگردانی کودک در نظر گرفته شود . |
limited Ads ? | برای کمک به نیازهای انطباق با مقررات ناشر، سرویس را در حالت تبلیغات محدود اجرا می کند. |
non Personalized Ads ? | برای کمک به نیازهای انطباق با مقررات ناشر، سرویس را در حالت تبلیغات غیرشخصی اجرا می کند. |
restrict Data Processing ? | برای کمک به نیازهای انطباق با مقررات ناشر، سرویس را برای اجرا در حالت پردازش محدود فعال میکند. |
traffic Source ? | نشان می دهد که آیا درخواست ها ترافیک خریداری شده یا ارگانیک را نشان می دهند. |
under Age Of Consent ? | نشان میدهد که آیا باید درخواستهای تبلیغات را بهعنوان کاربران زیر سن رضایت علامتگذاری کرد. |
- همچنین ببینید
خواص
Optional
childDirectedTreatment
childDirectedTreatment ?: boolean
null
تنظیم کنید. تبلیغات محدود Optional
limitedAds ?: boolean
میتوانید به GPT دستور دهید تا تبلیغات محدود را به دو روش درخواست کند:
- به طور خودکار، با استفاده از یک سیگنال از یک پلت فرم مدیریت رضایت IAB TCF v2.0 .
- به صورت دستی، با تنظیم مقدار این فیلد روی
true
.
توجه داشته باشید که هنگام استفاده از CMP، نیازی به فعال کردن تبلیغات محدود به صورت دستی نیست.
- مثال
جاوا اسکریپت
// Manually enable limited ads serving. // GPT must be loaded from the limited ads URL to configure this setting. googletag.pubads().setPrivacySettings({ limitedAds: true, });
جاوا اسکریپت (میراث)
// Manually enable limited ads serving. // GPT must be loaded from the limited ads URL to configure this setting. googletag.pubads().setPrivacySettings({ limitedAds: true, });
TypeScript
// Manually enable limited ads serving. // GPT must be loaded from the limited ads URL to configure this setting. googletag.pubads().setPrivacySettings({ limitedAds: true, });
- همچنین ببینید
تبلیغات غیرشخصی Optional
nonPersonalizedAds ?: boolean
محدودیت Optional
پردازش داده
restrictDataProcessing ?: boolean
منبع ترافیک Optional
trafficSource ?: TrafficSource
undefined
.- مثال
جاوا اسکریپت
// Indicate requests represent organic traffic. googletag.pubads().setPrivacySettings({ trafficSource: googletag.enums.TrafficSource.ORGANIC, }); // Indicate requests represent purchased traffic. googletag.pubads().setPrivacySettings({ trafficSource: googletag.enums.TrafficSource.PURCHASED, });
جاوا اسکریپت (میراث)
// Indicate requests represent organic traffic. googletag.pubads().setPrivacySettings({ trafficSource: googletag.enums.TrafficSource.ORGANIC, }); // Indicate requests represent purchased traffic. googletag.pubads().setPrivacySettings({ trafficSource: googletag.enums.TrafficSource.PURCHASED, });
TypeScript
// Indicate requests represent organic traffic. googletag.pubads().setPrivacySettings({ trafficSource: googletag.enums.TrafficSource.ORGANIC, }); // Indicate requests represent purchased traffic. googletag.pubads().setPrivacySettings({ trafficSource: googletag.enums.TrafficSource.PURCHASED, });
Optional
underAgeOfConsent
underAgeOfConsent ?: boolean
null
تنظیم کنید. googletag.PubAdsService
Service
را گسترش می دهدروش ها | |
---|---|
add Event Listener | شنوندهای را ثبت میکند که به شما امکان میدهد یک تابع جاوا اسکریپت را هنگامی که یک رویداد GPT خاص در صفحه اتفاق میافتد تنظیم و فراخوانی کنید. از |
clear | تبلیغات را از اسلات های داده شده حذف می کند و آنها را با محتوای خالی جایگزین می کند. |
clear Category Exclusions | منسوخ شده است. همه برچسبهای حذف دسته تبلیغات در سطح صفحه را پاک میکند. |
clear Targeting | منسوخ شده است. پارامترهای هدف گیری سفارشی را برای یک کلید خاص یا برای همه کلیدها پاک می کند. |
collapse Empty Divs | منسوخ شده است. جمع کردن div های اسلات را فعال می کند تا زمانی که محتوای تبلیغاتی برای نمایش وجود ندارد، فضایی را در صفحه اشغال نکنند. |
disable Initial Load | منسوخ شده است. درخواستهای تبلیغات را هنگام بارگیری صفحه غیرفعال میکند، اما اجازه میدهد تا تبلیغات با تماس PubAdsService.refresh درخواست شود. |
display | یک جایگاه تبلیغاتی با مسیر و اندازه واحد تبلیغاتی داده شده می سازد و نمایش می دهد. |
enable Lazy Load | منسوخ شده است. بارگیری تنبل را در GPT همانطور که توسط شی پیکربندی تعریف شده است فعال می کند. |
enable Single Request | منسوخ شده است. حالت درخواست تک را برای واکشی چند آگهی به طور همزمان فعال می کند. |
enable Video Ads | منسوخ شده است. به GPT سیگنال می دهد که تبلیغات ویدیویی در صفحه وجود خواهد داشت. |
get | منسوخ شده است. مقدار مشخصه AdSense مرتبط با کلید داده شده را برمی گرداند. |
get Attribute Keys | منسوخ شده است. کلیدهای ویژگی تنظیم شده در این سرویس را برمی گرداند. |
get Slots | لیست اسلات های مرتبط با این سرویس را دریافت کنید. از |
get Targeting | منسوخ شده است. یک پارامتر هدفیابی در سطح خدمات سفارشی را که تنظیم شده است، برمیگرداند. |
get Targeting Keys | منسوخ شده است. فهرستی از تمام کلیدهای هدف گذاری در سطح سرویس سفارشی که تنظیم شده اند را برمی گرداند. |
is Initial Load Disabled | منسوخ شده است. نشان میدهد که آیا درخواستهای اولیه برای تبلیغات با موفقیت در تماس قبلی PubAdsService.disableInitialLoad غیرفعال شده است یا خیر. |
refresh | تبلیغات جدید را برای خاص یا همه اسلات های موجود در صفحه واکشی و نمایش می دهد. |
remove Event Listener | شنونده قبلا ثبت نام شده را حذف می کند. از |
set | منسوخ شده است. مقادیری را برای ویژگیهای AdSense تنظیم میکند که برای همه جایگاههای تبلیغاتی تحت سرویس Publisher Ads اعمال میشود. |
set Category Exclusion | منسوخ شده است. یک استثناء طبقه بندی آگهی در سطح صفحه برای نام برچسب داده شده تنظیم می کند. |
set Centering | منسوخ شده است. مرکز افقی تبلیغات را فعال و غیرفعال می کند. |
set Force Safe Frame | منسوخ شده است. پیکربندی میکند که آیا همه آگهیهای موجود در صفحه باید با استفاده از ظرف SafeFrame ارائه شوند یا خیر. |
set Location | منسوخ شده است. اطلاعات مکان را از وبسایتها ارسال میکند تا بتوانید موارد خط را به مکانهای خاص هدفگیری جغرافیایی کنید. |
set Privacy Settings | به پیکربندی تمام تنظیمات حریم خصوصی از یک API با استفاده از یک شیء پیکربندی اجازه میدهد. |
set Publisher Provided Id | مقدار شناسه ارائه شده توسط ناشر را تنظیم می کند. |
set Safe Frame Config | منسوخ شده است. تنظیمات برگزیده سطح صفحه را برای پیکربندی SafeFrame تنظیم می کند. |
set Targeting | منسوخ شده است. پارامترهای هدفیابی سفارشی را برای یک کلید مشخص تنظیم میکند که برای همه جایگاههای تبلیغاتی سرویس آگهیهای ناشر اعمال میشود. |
set Video Content | منسوخ شده است. اطلاعات محتوای ویدیویی را برای ارسال به همراه درخواستهای آگهی برای اهداف هدفیابی و حذف محتوا تنظیم میکند. |
update Correlator | همبستگی که با درخواست های تبلیغاتی ارسال می شود را تغییر می دهد و عملاً یک نمای صفحه جدید را شروع می کند. |
روش ها
روشن
clear ( slots ?: Slot [] ) : boolean
به طور خاص، پاک کردن یک شکاف، آگهی را از نمای صفحه طولانی مدت GPT حذف میکند، بنابراین درخواستهای آینده تحت تأثیر موانع یا محرومیتهای رقابتی مربوط به این آگهی قرار نمیگیرند.
- مثال
جاوا اسکریپت
const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1"); googletag.display("div-1"); const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2"); googletag.display("div-2"); // This call to clear only slot1. googletag.pubads().clear([slot1]); // This call to clear both slot1 and slot2. googletag.pubads().clear([slot1, slot2]); // This call to clear all slots. googletag.pubads().clear();
جاوا اسکریپت (میراث)
var slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1"); googletag.display("div-1"); var slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2"); googletag.display("div-2"); // This call to clear only slot1. googletag.pubads().clear([slot1]); // This call to clear both slot1 and slot2. googletag.pubads().clear([slot1, slot2]); // This call to clear all slots. googletag.pubads().clear();
TypeScript
const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1")!; googletag.display("div-1"); const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2")!; googletag.display("div-2"); // This call to clear only slot1. googletag.pubads().clear([slot1]); // This call to clear both slot1 and slot2. googletag.pubads().clear([slot1, slot2]); // This call to clear all slots. googletag.pubads().clear();
پارامترها | |
---|---|
| آرایه ای از اسلات برای پاک کردن. آرایه اختیاری است. اگر نامشخص باشد تمام اسلات ها پاک خواهند شد. |
برمی گرداند | |
---|---|
boolean | اگر شکافها پاک شده باشند، true برمیگرداند، در غیر این صورت false برمیگرداند. |
clearCategoryExclusions
clearCategoryExclusions ( ) : PubAdsService
- مثال
جاوا اسکریپت
// Set category exclusion to exclude ads with 'AirlineAd' labels. googletag.pubads().setCategoryExclusion("AirlineAd"); // Make ad requests. No ad with 'AirlineAd' label will be returned. // Clear category exclusions so all ads can be returned. googletag.pubads().clearCategoryExclusions(); // Make ad requests. Any ad can be returned.
جاوا اسکریپت (میراث)
// Set category exclusion to exclude ads with 'AirlineAd' labels. googletag.pubads().setCategoryExclusion("AirlineAd"); // Make ad requests. No ad with 'AirlineAd' label will be returned. // Clear category exclusions so all ads can be returned. googletag.pubads().clearCategoryExclusions(); // Make ad requests. Any ad can be returned.
TypeScript
// Set category exclusion to exclude ads with 'AirlineAd' labels. googletag.pubads().setCategoryExclusion("AirlineAd"); // Make ad requests. No ad with 'AirlineAd' label will be returned. // Clear category exclusions so all ads can be returned. googletag.pubads().clearCategoryExclusions(); // Make ad requests. Any ad can be returned.
- همچنین ببینید
برمی گرداند | |
---|---|
PubAdsService | شیء سرویسی که متد بر روی آن فراخوانی شده است. |
هدف گذاری روشن
clearTargeting ( key ?: string ) : PubAdsService
- مثال
جاوا اسکریپت
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().setTargeting("colors", "blue"); googletag.pubads().setTargeting("fruits", "apple"); googletag.pubads().clearTargeting("interests"); // Targeting 'colors' and 'fruits' are still present, while 'interests' // was cleared. googletag.pubads().clearTargeting(); // All targeting has been cleared.
جاوا اسکریپت (میراث)
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().setTargeting("colors", "blue"); googletag.pubads().setTargeting("fruits", "apple"); googletag.pubads().clearTargeting("interests"); // Targeting 'colors' and 'fruits' are still present, while 'interests' // was cleared. googletag.pubads().clearTargeting(); // All targeting has been cleared.
TypeScript
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().setTargeting("colors", "blue"); googletag.pubads().setTargeting("fruits", "apple"); googletag.pubads().clearTargeting("interests"); // Targeting 'colors' and 'fruits' are still present, while 'interests' // was cleared. googletag.pubads().clearTargeting(); // All targeting has been cleared.
- همچنین ببینید
پارامترها | |
---|---|
| کلید پارامتر هدف. کلید اختیاری است. تمام پارامترهای هدف گیری در صورت نامشخص بودن پاک خواهند شد. |
برمی گرداند | |
---|---|
PubAdsService | شیء سرویسی که متد بر روی آن فراخوانی شده است. |
collapseEmptyDivs
collapseEmptyDivs ( collapseBeforeAdFetch ?: boolean ) : boolean
- همچنین ببینید
پارامترها | |
---|---|
| حتی قبل از واکشی تبلیغات، شکافها جمع شوند یا خیر. این پارامتر اختیاری است. اگر ارائه نشود، false به عنوان مقدار پیش فرض استفاده می شود. |
برمی گرداند | |
---|---|
boolean | اگر حالت جمعکردن div فعال باشد، true برمیگرداند و اگر فعال کردن حالت جمعکردن غیرممکن باشد، false برمیگرداند زیرا متد پس از فعال شدن سرویس فراخوانی شده است. |
disableInitialLoad
disableInitialLoad ( ) : void
refresh
غیرممکن خواهد بود.نمایش داده شود
display ( adUnitPath : string , size : GeneralSize , div ?: string | Element , clickUrl ?: string ) : void
توجه: هنگامی که این روش فراخوانی می شود، یک عکس فوری از وضعیت اسلات و صفحه ایجاد می شود تا هنگام ارسال درخواست تبلیغ و ارائه پاسخ از یکنواختی اطمینان حاصل شود. هر تغییری که پس از فراخوانی این روش در وضعیت اسلات یا صفحه ایجاد میشود (از جمله هدفگیری، تنظیمات حریم خصوصی، اجباری SafeFrame و غیره) فقط برای درخواستهای
display()
یا refresh()
بعدی اعمال میشود.- مثال
جاوا اسکریپت
googletag.pubads().display("/1234567/sports", [728, 90], "div-1");
جاوا اسکریپت (میراث)
googletag.pubads().display("/1234567/sports", [728, 90], "div-1");
TypeScript
googletag.pubads().display("/1234567/sports", [728, 90], "div-1");
- همچنین ببینید
پارامترها | |
---|---|
adUnitPath : string | مسیر واحد تبلیغاتی اسلات که باید ارائه شود. |
size : GeneralSize | عرض و ارتفاع شکاف. |
| یا شناسه div حاوی اسلات یا خود عنصر div. |
| نشانی وب کلیک کنید تا در این اسلات استفاده کنید. |
فعال کردن LazyLoad
enableLazyLoad ( config ?: {
fetchMarginPercent ?: number ;
mobileScaling ?: number ;
renderMarginPercent ?: number ;
} ) : void
توجه: واکشی تنبل در SRA فقط در صورتی کار میکند که همه اسلاتها خارج از حاشیه واکشی باشند.
- مثال
جاوا اسکریپت
googletag.pubads().enableLazyLoad({ // Fetch slots within 5 viewports. fetchMarginPercent: 500, // Render slots within 2 viewports. renderMarginPercent: 200, // Double the above values on mobile. mobileScaling: 2.0, });
جاوا اسکریپت (میراث)
googletag.pubads().enableLazyLoad({ // Fetch slots within 5 viewports. fetchMarginPercent: 500, // Render slots within 2 viewports. renderMarginPercent: 200, // Double the above values on mobile. mobileScaling: 2.0, });
TypeScript
googletag.pubads().enableLazyLoad({ // Fetch slots within 5 viewports. fetchMarginPercent: 500, // Render slots within 2 viewports. renderMarginPercent: 200, // Double the above values on mobile. mobileScaling: 2.0, });
پارامترها | |
---|---|
| شیء پیکربندی امکان سفارشی سازی رفتار تنبل را فراهم می کند. هر پیکربندی حذف شده از یک مجموعه پیشفرض توسط Google استفاده میکند که به مرور زمان تنظیم میشود. برای غیرفعال کردن یک تنظیم خاص، مانند حاشیه واکشی، مقدار را روی -1 تنظیم کنید.
|
فعال کردن SingleRequest
enableSingleRequest ( ) : boolean
- همچنین ببینید
برمی گرداند | |
---|---|
boolean | در صورت فعال بودن حالت درخواست تکی، true و در صورتی که فعال کردن حالت درخواست تک غیرممکن باشد، false ، زیرا متد پس از فعال شدن سرویس فراخوانی شده است. |
فعال کردن VideoAds
enableVideoAds ( ) : void
دریافت کنید
get ( key : string ) : string
- مثال
جاوا اسکریپت
googletag.pubads().set("adsense_background_color", "#FFFFFF"); googletag.pubads().get("adsense_background_color"); // Returns '#FFFFFF'.
جاوا اسکریپت (میراث)
googletag.pubads().set("adsense_background_color", "#FFFFFF"); googletag.pubads().get("adsense_background_color"); // Returns '#FFFFFF'.
TypeScript
googletag.pubads().set("adsense_background_color", "#FFFFFF"); googletag.pubads().get("adsense_background_color"); // Returns '#FFFFFF'.
- همچنین ببینید
پارامترها | |
---|---|
key : string | نام ویژگی مورد نظر برای جستجو |
برمی گرداند | |
---|---|
string | مقدار فعلی برای کلید مشخصه، یا اگر کلید موجود نباشد، null . |
getAttributeKeys
getAttributeKeys ( ) : string []
- مثال
جاوا اسکریپت
googletag.pubads().set("adsense_background_color", "#FFFFFF"); googletag.pubads().set("adsense_border_color", "#AABBCC"); googletag.pubads().getAttributeKeys(); // Returns ['adsense_background_color', 'adsense_border_color'].
جاوا اسکریپت (میراث)
googletag.pubads().set("adsense_background_color", "#FFFFFF"); googletag.pubads().set("adsense_border_color", "#AABBCC"); googletag.pubads().getAttributeKeys(); // Returns ['adsense_background_color', 'adsense_border_color'].
TypeScript
googletag.pubads().set("adsense_background_color", "#FFFFFF"); googletag.pubads().set("adsense_border_color", "#AABBCC"); googletag.pubads().getAttributeKeys(); // Returns ['adsense_background_color', 'adsense_border_color'].
برمی گرداند | |
---|---|
string [] | مجموعه ای از کلیدهای ویژگی روی این سرویس تنظیم شده است. سفارش تعریف نشده است. |
getTargeting
getTargeting ( key : string ) : string []
- مثال
جاوا اسکریپت
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().getTargeting("interests"); // Returns ['sports']. googletag.pubads().getTargeting("age"); // Returns [] (empty array).
جاوا اسکریپت (میراث)
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().getTargeting("interests"); // Returns ['sports']. googletag.pubads().getTargeting("age"); // Returns [] (empty array).
TypeScript
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().getTargeting("interests"); // Returns ['sports']. googletag.pubads().getTargeting("age"); // Returns [] (empty array).
پارامترها | |
---|---|
key : string | کلید هدف گیری که باید جستجو کنید. |
برمی گرداند | |
---|---|
string [] | مقادیر مرتبط با این کلید، یا یک آرایه خالی اگر چنین کلیدی وجود نداشته باشد. |
getTargetingKeys
getTargetingKeys ( ) : string []
- مثال
جاوا اسکریپت
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().setTargeting("colors", "blue"); googletag.pubads().getTargetingKeys(); // Returns ['interests', 'colors'].
جاوا اسکریپت (میراث)
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().setTargeting("colors", "blue"); googletag.pubads().getTargetingKeys(); // Returns ['interests', 'colors'].
TypeScript
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().setTargeting("colors", "blue"); googletag.pubads().getTargetingKeys(); // Returns ['interests', 'colors'].
برمی گرداند | |
---|---|
string [] | مجموعه ای از کلیدهای هدف گیری سفارش تعریف نشده است. |
isInitialLoadDisabled
isInitialLoadDisabled ( ) : boolean
برمی گرداند | |
---|---|
boolean | اگر تماس قبلی با PubAdsService.disableInitialLoad موفقیت آمیز بود، true است، در غیر این صورت false . |
تازه کردن
refresh ( slots ?: Slot [] , options ?: {
changeCorrelator : boolean ;
} ) : void
برای رفتار مناسب در همه مرورگرها،
refresh
تماس باید قبل از یک تماس برای display
جایگاه آگهی باشد. اگر تماس برای display
حذف شود، ممکن است بازخوانی غیرمنتظره عمل کند. در صورت تمایل، از روش PubAdsService.disableInitialLoad می توان برای جلوگیری از واکشی یک آگهی display
استفاده کرد.بهروزرسانی یک اسلات، آگهی قدیمی را از نمای صفحه طولانی مدت GPT حذف میکند، بنابراین درخواستهای آینده تحت تأثیر موانع یا محرومیتهای رقابتی مربوط به آن آگهی قرار نمیگیرند.
- مثال
جاوا اسکریپت
const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1"); googletag.display("div-1"); const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2"); googletag.display("div-2"); // This call to refresh fetches a new ad for slot1 only. googletag.pubads().refresh([slot1]); // This call to refresh fetches a new ad for both slot1 and slot2. googletag.pubads().refresh([slot1, slot2]); // This call to refresh fetches a new ad for each slot. googletag.pubads().refresh(); // This call to refresh fetches a new ad for slot1, without changing // the correlator. googletag.pubads().refresh([slot1], { changeCorrelator: false }); // This call to refresh fetches a new ad for each slot, without // changing the correlator. googletag.pubads().refresh(null, { changeCorrelator: false });
جاوا اسکریپت (میراث)
var slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1"); googletag.display("div-1"); var slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2"); googletag.display("div-2"); // This call to refresh fetches a new ad for slot1 only. googletag.pubads().refresh([slot1]); // This call to refresh fetches a new ad for both slot1 and slot2. googletag.pubads().refresh([slot1, slot2]); // This call to refresh fetches a new ad for each slot. googletag.pubads().refresh(); // This call to refresh fetches a new ad for slot1, without changing // the correlator. googletag.pubads().refresh([slot1], { changeCorrelator: false }); // This call to refresh fetches a new ad for each slot, without // changing the correlator. googletag.pubads().refresh(null, { changeCorrelator: false });
TypeScript
const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1")!; googletag.display("div-1"); const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2")!; googletag.display("div-2"); // This call to refresh fetches a new ad for slot1 only. googletag.pubads().refresh([slot1]); // This call to refresh fetches a new ad for both slot1 and slot2. googletag.pubads().refresh([slot1, slot2]); // This call to refresh fetches a new ad for each slot. googletag.pubads().refresh(); // This call to refresh fetches a new ad for slot1, without changing // the correlator. googletag.pubads().refresh([slot1], { changeCorrelator: false }); // This call to refresh fetches a new ad for each slot, without // changing the correlator. googletag.pubads().refresh(null, { changeCorrelator: false });
پارامترها | |
---|---|
| شکاف ها برای تازه کردن. آرایه اختیاری است. اگر نامشخص باشد، تمام اسلات ها به روز می شوند. |
| گزینه های پیکربندی مرتبط با این تماس تازه.
|
مجموعه
set ( key : string , value : string ) : PubAdsService
بیش از یک بار فراخوانی این کلید برای همان کلید، مقادیر تنظیم شده قبلی را برای آن کلید لغو می کند. همه مقادیر باید قبل از تماس
display
یا refresh
تنظیم شوند.- مثال
جاوا اسکریپت
googletag.pubads().set("adsense_background_color", "#FFFFFF");
جاوا اسکریپت (میراث)
googletag.pubads().set("adsense_background_color", "#FFFFFF");
TypeScript
googletag.pubads().set("adsense_background_color", "#FFFFFF");
- همچنین ببینید
پارامترها | |
---|---|
key : string | نام صفت. |
value : string | ارزش صفت. |
برمی گرداند | |
---|---|
PubAdsService | شیء سرویسی که متد بر روی آن فراخوانی شده است. |
setCategoryExclusion
setCategoryExclusion ( categoryExclusion : string ) : PubAdsService
- مثال
جاوا اسکریپت
// Label = AirlineAd. googletag.pubads().setCategoryExclusion("AirlineAd");
جاوا اسکریپت (میراث)
// Label = AirlineAd. googletag.pubads().setCategoryExclusion("AirlineAd");
TypeScript
// Label = AirlineAd. googletag.pubads().setCategoryExclusion("AirlineAd");
- همچنین ببینید
پارامترها | |
---|---|
categoryExclusion : string | برچسب حذف دسته آگهی برای افزودن. |
برمی گرداند | |
---|---|
PubAdsService | شیء سرویسی که متد بر روی آن فراخوانی شده است. |
setCentering
setCentering ( centerAds : boolean ) : void
این روش باید قبل از فراخوانی
display
یا refresh
فراخوانی شود زیرا فقط تبلیغاتی که پس از فراخوانی این روش درخواست می شوند در مرکز قرار می گیرند.- مثال
جاوا اسکریپت
// Make ads centered. googletag.pubads().setCentering(true);
جاوا اسکریپت (میراث)
// Make ads centered. googletag.pubads().setCentering(true);
TypeScript
// Make ads centered. googletag.pubads().setCentering(true);
پارامترها | |
---|---|
centerAds : boolean | true در مرکز تبلیغات، false برای تراز چپ آنها. |
setForceSafeFrame
setForceSafeFrame ( forceSafeFrame : boolean ) : PubAdsService
لطفاً هنگام استفاده از این API موارد زیر را در نظر داشته باشید:
- این تنظیم فقط برای درخواستهای آگهی بعدی که برای اسلاتهای مربوطه انجام میشود، اعمال میشود.
- تنظیم سطح شکاف، اگر مشخص شود، همیشه تنظیمات سطح صفحه را لغو می کند.
- اگر روی
true
تنظیم شود (در سطح شکاف یا سطح صفحه)، تبلیغ همیشه با استفاده از یک محفظه SafeFrame مستقل از انتخاب انجام شده در رابط کاربری Google Ad Manager ارائه میشود. - با این حال، اگر روی
false
تنظیم شود یا نامشخص باقی بماند، بسته به نوع خلاقیت و انتخاب انجام شده در رابط کاربری Google Ad Manager، آگهی با استفاده از یک محفظه SafeFrame ارائه میشود. - این API باید با احتیاط مورد استفاده قرار گیرد، زیرا میتواند بر رفتار خلاقانی که تلاش میکنند از iFrame خود خارج شوند یا به نمایش مستقیم آنها در صفحه ناشران متکی هستند، تأثیر بگذارد.
- مثال
جاوا اسکریپت
googletag.pubads().setForceSafeFrame(true); // The following slot will be opted-out of the page-level force // SafeFrame instruction. googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setForceSafeFrame(false) .addService(googletag.pubads()); // The following slot will have SafeFrame forced. googletag.defineSlot("/1234567/news", [160, 600], "div-2").addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
جاوا اسکریپت (میراث)
googletag.pubads().setForceSafeFrame(true); // The following slot will be opted-out of the page-level force // SafeFrame instruction. googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setForceSafeFrame(false) .addService(googletag.pubads()); // The following slot will have SafeFrame forced. googletag.defineSlot("/1234567/news", [160, 600], "div-2").addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
TypeScript
googletag.pubads().setForceSafeFrame(true); // The following slot will be opted-out of the page-level force // SafeFrame instruction. googletag .defineSlot("/1234567/sports", [160, 600], "div-1")! .setForceSafeFrame(false) .addService(googletag.pubads()); // The following slot will have SafeFrame forced. googletag.defineSlot("/1234567/news", [160, 600], "div-2")!.addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
- همچنین ببینید
پارامترها | |
---|---|
forceSafeFrame : boolean | true تا همه تبلیغات موجود در صفحه در SafeFrames ارائه شوند و false برای تغییر تنظیمات قبلی به false. تنظیم این روی false زمانی که قبلا مشخص نشده باشد، چیزی را تغییر نخواهد داد. |
برمی گرداند | |
---|---|
PubAdsService | شیء سرویسی که متد بر روی آن فراخوانی شده است. |
setLocation
setLocation ( address : string ) : PubAdsService
- مثال
جاوا اسکریپت
// Postal code: googletag.pubads().setLocation("10001,US");
جاوا اسکریپت (میراث)
// Postal code: googletag.pubads().setLocation("10001,US");
TypeScript
// Postal code: googletag.pubads().setLocation("10001,US");
پارامترها | |
---|---|
address : string | آدرس فرم آزاد. |
برمی گرداند | |
---|---|
PubAdsService | شیء سرویسی که متد بر روی آن فراخوانی شده است. |
setPrivacySettings
setPrivacySettings ( privacySettings : PrivacySettingsConfig ) : PubAdsService
- مثال
جاوا اسکریپت
googletag.pubads().setPrivacySettings({ restrictDataProcessing: true, }); // Set multiple privacy settings at the same time. googletag.pubads().setPrivacySettings({ childDirectedTreatment: true, underAgeOfConsent: true, }); // Clear the configuration for childDirectedTreatment. googletag.pubads().setPrivacySettings({ childDirectedTreatment: null, });
جاوا اسکریپت (میراث)
googletag.pubads().setPrivacySettings({ restrictDataProcessing: true, }); // Set multiple privacy settings at the same time. googletag.pubads().setPrivacySettings({ childDirectedTreatment: true, underAgeOfConsent: true, }); // Clear the configuration for childDirectedTreatment. googletag.pubads().setPrivacySettings({ childDirectedTreatment: null, });
TypeScript
googletag.pubads().setPrivacySettings({ restrictDataProcessing: true, }); // Set multiple privacy settings at the same time. googletag.pubads().setPrivacySettings({ childDirectedTreatment: true, underAgeOfConsent: true, }); // Clear the configuration for childDirectedTreatment. googletag.pubads().setPrivacySettings({ childDirectedTreatment: null, });
- همچنین ببینید
پارامترها | |
---|---|
privacySettings : PrivacySettingsConfig | شیء حاوی تنظیمات حریم خصوصی. |
برمی گرداند | |
---|---|
PubAdsService | شیء سرویسی که تابع روی آن فراخوانی شده است. |
setPublisherProvidedId
setPublisherProvidedId ( ppid : string ) : PubAdsService
- مثال
جاوا اسکریپت
googletag.pubads().setPublisherProvidedId("12JD92JD8078S8J29SDOAKC0EF230337");
جاوا اسکریپت (میراث)
googletag.pubads().setPublisherProvidedId("12JD92JD8078S8J29SDOAKC0EF230337");
TypeScript
googletag.pubads().setPublisherProvidedId("12JD92JD8078S8J29SDOAKC0EF230337");
- همچنین ببینید
پارامترها | |
---|---|
ppid : string | شناسه الفبایی که توسط ناشر ارائه شده است. باید بین 32 تا 150 کاراکتر باشد. |
برمی گرداند | |
---|---|
PubAdsService | شیء سرویسی که متد بر روی آن فراخوانی شده است. |
setSafeFrameConfig
setSafeFrameConfig ( config : SafeFrameConfig ) : PubAdsService
این تنظیمات برگزیده در سطح صفحه، در صورت مشخص شدن، با اولویتهای سطح شکاف لغو میشوند.
- مثال
جاوا اسکریپت
googletag.pubads().setForceSafeFrame(true); const pageConfig = { allowOverlayExpansion: true, allowPushExpansion: true, sandbox: true, }; const slotConfig = { allowOverlayExpansion: false }; googletag.pubads().setSafeFrameConfig(pageConfig); // The following slot will not allow for expansion by overlay. googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setSafeFrameConfig(slotConfig) .addService(googletag.pubads()); // The following slot will inherit the page level settings, and hence // would allow for expansion by overlay. googletag.defineSlot("/1234567/news", [160, 600], "div-2").addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
جاوا اسکریپت (میراث)
googletag.pubads().setForceSafeFrame(true); var pageConfig = { allowOverlayExpansion: true, allowPushExpansion: true, sandbox: true, }; var slotConfig = { allowOverlayExpansion: false }; googletag.pubads().setSafeFrameConfig(pageConfig); // The following slot will not allow for expansion by overlay. googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setSafeFrameConfig(slotConfig) .addService(googletag.pubads()); // The following slot will inherit the page level settings, and hence // would allow for expansion by overlay. googletag.defineSlot("/1234567/news", [160, 600], "div-2").addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
TypeScript
googletag.pubads().setForceSafeFrame(true); const pageConfig = { allowOverlayExpansion: true, allowPushExpansion: true, sandbox: true, }; const slotConfig = { allowOverlayExpansion: false }; googletag.pubads().setSafeFrameConfig(pageConfig); // The following slot will not allow for expansion by overlay. googletag .defineSlot("/1234567/sports", [160, 600], "div-1")! .setSafeFrameConfig(slotConfig) .addService(googletag.pubads()); // The following slot will inherit the page level settings, and hence // would allow for expansion by overlay. googletag.defineSlot("/1234567/news", [160, 600], "div-2")!.addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
- همچنین ببینید
پارامترها | |
---|---|
config : SafeFrameConfig | شی پیکربندی. |
برمی گرداند | |
---|---|
PubAdsService | شیء سرویسی که متد بر روی آن فراخوانی شده است. |
setTargeting
setTargeting ( key : string , value : string | string [] ) : PubAdsService
- مثال
جاوا اسکریپت
// Example with a single value for a key. googletag.pubads().setTargeting("interests", "sports"); // Example with multiple values for a key inside in an array. googletag.pubads().setTargeting("interests", ["sports", "music"]);
جاوا اسکریپت (میراث)
// Example with a single value for a key. googletag.pubads().setTargeting("interests", "sports"); // Example with multiple values for a key inside in an array. googletag.pubads().setTargeting("interests", ["sports", "music"]);
TypeScript
// Example with a single value for a key. googletag.pubads().setTargeting("interests", "sports"); // Example with multiple values for a key inside in an array. googletag.pubads().setTargeting("interests", ["sports", "music"]);
- همچنین ببینید
پارامترها | |
---|---|
key : string | کلید پارامتر هدف. |
value : string | string [] | مقدار پارامتر هدف یا آرایه ای از مقادیر. |
برمی گرداند | |
---|---|
PubAdsService | شیء سرویسی که متد بر روی آن فراخوانی شده است. |
setVideoContent
setVideoContent ( videoContentId : string , videoCmsId : string ) : void
videoContentId
و videoCmsId
، از مقادیری استفاده کنید که به سرویس جذب محتوای Google Ad Manager ارائه شده است.- همچنین ببینید
پارامترها | |
---|---|
videoContentId : string | شناسه محتوای ویدیویی |
videoCmsId : string | شناسه CMS ویدیو. |
updateCorrelator
updateCorrelator ( ) : PubAdsService
توجه: این هیچ تأثیری بر نمای طولانی مدت GPT ندارد، که به طور خودکار تبلیغات را در صفحه منعکس می کند و زمان انقضا ندارد.
- مثال
جاوا اسکریپت
// Assume that the correlator is currently 12345. All ad requests made // by this page will currently use that value. // Replace the current correlator with a new correlator. googletag.pubads().updateCorrelator(); // The correlator will now be a new randomly selected value, different // from 12345. All subsequent ad requests made by this page will use // the new value.
جاوا اسکریپت (میراث)
// Assume that the correlator is currently 12345. All ad requests made // by this page will currently use that value. // Replace the current correlator with a new correlator. googletag.pubads().updateCorrelator(); // The correlator will now be a new randomly selected value, different // from 12345. All subsequent ad requests made by this page will use // the new value.
TypeScript
// Assume that the correlator is currently 12345. All ad requests made // by this page will currently use that value. // Replace the current correlator with a new correlator. googletag.pubads().updateCorrelator(); // The correlator will now be a new randomly selected value, different // from 12345. All subsequent ad requests made by this page will use // the new value.
برمی گرداند | |
---|---|
PubAdsService | شیء سرویسی که تابع روی آن فراخوانی شده است. |
googletag.ResponseInformation
خواص | |
---|---|
advertiser Id | شناسه آگهی دهنده |
campaign Id | شناسه کمپین |
creative Id | شناسه خلاق. |
creative Template Id | شناسه قالب آگهی. |
line Item Id | شناسه مورد خط. |
- همچنین ببینید
خواص
شناسه تبلیغ
advertiserId : number
شناسه کمپین
campaignId : number
شناسه خلاق
creativeId : number
creativeTemplateId
creativeTemplateId : number
lineItemId
lineItemId : number
googletag.RewardedPayload
خواص | |
---|---|
amount | تعداد مواردی که در جایزه گنجانده شده است. |
type | نوع کالایی که در جایزه گنجانده شده است (مثلاً "سکه"). |
- همچنین ببینید
خواص
مقدار
amount : number
نوع
type : string
googletag.Service
روش ها | |
---|---|
add Event Listener | شنوندهای را ثبت میکند که به شما امکان میدهد یک تابع جاوا اسکریپت را هنگامی که یک رویداد GPT خاص در صفحه اتفاق میافتد تنظیم و فراخوانی کنید. |
get Slots | لیست اسلات های مرتبط با این سرویس را دریافت کنید. |
remove Event Listener | شنونده قبلا ثبت نام شده را حذف می کند. |
روش ها
addEventListener
addEventListener < K extends keyof EventTypeMap > ( eventType : K , listener : ( ( arg : EventTypeMap [ K ] ) => void ) ) : Service
- events.GameManualInterstitialSlotClosedEvent
- events.GameManualInterstitialSlotReadyEvent
- events.ImpressionViewableEvent
- رویدادها.RewardedSlotClosedEvent
- رویدادها.RewardedSlotGrantedEvent
- رویدادها.RewardedSlotReadyEvent
- events.SlotOnloadEvent
- events.SlotRenderEndedEvent
- events.SlotRequestedEvent
- رویدادها.SlotResponseReceived
- events.SlotVisibilityChangedEvent
- مثال
جاوا اسکریپت
// 1. Adding an event listener for the PubAdsService. googletag.pubads().addEventListener("slotOnload", (event) => { console.log("Slot has been loaded:"); console.log(event); }); // 2. Adding an event listener with slot specific logic. // Listeners operate at service level, which means that you cannot add // a listener for an event for a specific slot only. You can, however, // programmatically filter a listener to respond only to a certain ad // slot, using this pattern: const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotOnload", (event) => { if (event.slot === targetSlot) { // Slot specific logic. } });
جاوا اسکریپت (میراث)
// 1. Adding an event listener for the PubAdsService. googletag.pubads().addEventListener("slotOnload", function (event) { console.log("Slot has been loaded:"); console.log(event); }); // 2. Adding an event listener with slot specific logic. // Listeners operate at service level, which means that you cannot add // a listener for an event for a specific slot only. You can, however, // programmatically filter a listener to respond only to a certain ad // slot, using this pattern: var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotOnload", function (event) { if (event.slot === targetSlot) { // Slot specific logic. } });
TypeScript
// 1. Adding an event listener for the PubAdsService. googletag.pubads().addEventListener("slotOnload", (event) => { console.log("Slot has been loaded:"); console.log(event); }); // 2. Adding an event listener with slot specific logic. // Listeners operate at service level, which means that you cannot add // a listener for an event for a specific slot only. You can, however, // programmatically filter a listener to respond only to a certain ad // slot, using this pattern: const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotOnload", (event) => { if (event.slot === targetSlot) { // Slot specific logic. } });
- همچنین ببینید
پارامترها | |
---|---|
eventType : K | رشته ای که نشان دهنده نوع رویداد تولید شده توسط GPT است. انواع رویداد به حروف بزرگ و کوچک حساس هستند. |
listener : ( ( arg : EventTypeMap [ K ] ) => void ) | عملکردی که یک آرگومان شیء یک رویداد واحد را می گیرد. |
برمی گرداند | |
---|---|
Service | شیء خدماتی که در آن روش خوانده شده است. |
getlots
remeventlistener
removeEventListener < K extends keyof EventTypeMap > ( eventType : K , listener : ( ( event : EventTypeMap [ K ] ) => void ) ) : void
- مثال
جاوا اسکریپت
googletag.cmd.push(() => { // Define a new ad slot. googletag.defineSlot("/6355419/Travel", [728, 90], "div-for-slot").addService(googletag.pubads()); // Define a new function that removes itself via removeEventListener // after the impressionViewable event fires. const onViewableListener = (event) => { googletag.pubads().removeEventListener("impressionViewable", onViewableListener); setTimeout(() => { googletag.pubads().refresh([event.slot]); }, 30000); }; // Add onViewableListener as a listener for impressionViewable events. googletag.pubads().addEventListener("impressionViewable", onViewableListener); googletag.enableServices(); });
جاوا اسکریپت (میراث)
googletag.cmd.push(function () { // Define a new ad slot. googletag.defineSlot("/6355419/Travel", [728, 90], "div-for-slot").addService(googletag.pubads()); // Define a new function that removes itself via removeEventListener // after the impressionViewable event fires. var onViewableListener = function (event) { googletag.pubads().removeEventListener("impressionViewable", onViewableListener); setTimeout(function () { googletag.pubads().refresh([event.slot]); }, 30000); }; // Add onViewableListener as a listener for impressionViewable events. googletag.pubads().addEventListener("impressionViewable", onViewableListener); googletag.enableServices(); });
TypeScript
googletag.cmd.push(() => { // Define a new ad slot. googletag .defineSlot("/6355419/Travel", [728, 90], "div-for-slot")! .addService(googletag.pubads()); // Define a new function that removes itself via removeEventListener // after the impressionViewable event fires. const onViewableListener = (event: googletag.events.ImpressionViewableEvent) => { googletag.pubads().removeEventListener("impressionViewable", onViewableListener); setTimeout(() => { googletag.pubads().refresh([event.slot]); }, 30000); }; // Add onViewableListener as a listener for impressionViewable events. googletag.pubads().addEventListener("impressionViewable", onViewableListener); googletag.enableServices(); });
پارامترها | |
---|---|
eventType : K | رشته ای که نشان دهنده نوع رویداد ایجاد شده توسط GPT است. انواع رویداد حساس به مورد هستند. |
listener : ( ( event : EventTypeMap [ K ] ) => void ) | عملکردی که یک آرگومان شیء یک رویداد واحد را می گیرد. |
googletag.sizemappingBuilder
روش ها | |
---|---|
add Size | یک نقشه برداری از یک آرایه تک اندازه (نمایانگر نمای) به یک آرایه تک یا چند اندازه که نمایانگر شکاف است ، اضافه می کند. |
build | مشخصات نقشه اندازه را از نقشه های اضافه شده به این سازنده ایجاد می کند. |
- همچنین ببینید
روش ها
اضافه کردن
addSize ( viewportSize : SingleSizeArray , slotSize : GeneralSize ) : SizeMappingBuilder
- مثال
جاوا اسکریپت
// Mapping 1 googletag .sizeMapping() .addSize([1024, 768], [970, 250]) .addSize([980, 690], [728, 90]) .addSize([640, 480], "fluid") .addSize([0, 0], [88, 31]) // All viewports < 640x480 .build(); // Mapping 2 googletag .sizeMapping() .addSize([1024, 768], [970, 250]) .addSize([980, 690], []) .addSize([640, 480], [120, 60]) .addSize([0, 0], []) .build(); // Mapping 2 will not show any ads for the following viewport sizes: // [1024, 768] > size >= [980, 690] and // [640, 480] > size >= [0, 0]
جاوا اسکریپت (میراث)
// Mapping 1 googletag .sizeMapping() .addSize([1024, 768], [970, 250]) .addSize([980, 690], [728, 90]) .addSize([640, 480], "fluid") .addSize([0, 0], [88, 31]) // All viewports < 640x480 .build(); // Mapping 2 googletag .sizeMapping() .addSize([1024, 768], [970, 250]) .addSize([980, 690], []) .addSize([640, 480], [120, 60]) .addSize([0, 0], []) .build(); // Mapping 2 will not show any ads for the following viewport sizes: // [1024, 768] > size >= [980, 690] and // [640, 480] > size >= [0, 0]
TypeScript
// Mapping 1 googletag .sizeMapping() .addSize([1024, 768], [970, 250]) .addSize([980, 690], [728, 90]) .addSize([640, 480], "fluid") .addSize([0, 0], [88, 31]) // All viewports < 640x480 .build(); // Mapping 2 googletag .sizeMapping() .addSize([1024, 768], [970, 250]) .addSize([980, 690], []) .addSize([640, 480], [120, 60]) .addSize([0, 0], []) .build(); // Mapping 2 will not show any ads for the following viewport sizes: // [1024, 768] > size >= [980, 690] and // [640, 480] > size >= [0, 0]
پارامترها | |
---|---|
viewportSize : SingleSizeArray | اندازه نمای این ورودی نقشه برداری. |
slotSize : GeneralSize | اندازه شکاف برای این ورودی نقشه برداری. |
برمی گرداند | |
---|---|
SizeMappingBuilder | اشاره ای به این سازنده. |
ساختن
build ( ) : SizeMappingArray
در صورت تهیه هرگونه نقشه های نامعتبر ، این روش
null
باز می گردد. در غیر این صورت مشخصات خود را در قالب صحیح باز می گرداند تا به Slot.DefinesizEmapping منتقل شود.توجه: رفتار سازنده پس از فراخوانی این روش تعریف نشده است.
برمی گرداند | |
---|---|
SizeMappingArray | نتیجه ساخته شده توسط این سازنده. در صورت تهیه نقشه های اندازه نامعتبر ، می تواند تهی باشد. |
googletag.slot
روش ها | |
---|---|
add Service | خدماتی را به این شکاف اضافه می کند. |
clear Category Exclusions | منسوخ شده است. تمام برچسب های محرومیت دسته AD در سطح اسلات را برای این شکاف پاک می کند. |
clear Targeting | منسوخ شده است. پارامترهای هدفمند هدف خاص یا همه سطح سفارشی را برای این شکاف پاک می کند. |
define Size Mapping | مجموعه ای از نگاشتها را از حداقل اندازه منظره به اندازه شکاف برای این شکاف تنظیم می کند. |
get | منسوخ شده است. مقدار را برای ویژگی AdSense مرتبط با کلید داده شده برای این شکاف برمی گرداند. |
get Ad Unit Path | مسیر کامل واحد AD را با کد شبکه و مسیر واحد AD برمی گرداند. |
get Attribute Keys | منسوخ شده است. لیست کلیدهای ویژگی تنظیم شده در این شکاف را برمی گرداند. |
get Category Exclusions | منسوخ شده است. برچسب های محرومیت دسته AD را برای این شکاف برمی گرداند. |
get Config | گزینه های پیکربندی کلی برای شکاف تنظیم شده توسط SetConfig می شود. |
get Response Information | اطلاعات پاسخ آگهی را برمی گرداند. |
get Slot Element Id | شناسه div شکاف ارائه شده هنگام تعریف شکاف را برمی گرداند. |
get Targeting | منسوخ شده است. یک پارامتر هدفمند سفارشی خاص را که در این شکاف تنظیم شده است ، برمی گرداند. |
get Targeting Keys | منسوخ شده است. لیست کلیه کلیدهای هدفمند سفارشی را که روی این شکاف تنظیم شده است ، برمی گرداند. |
set | منسوخ شده است. مقداری را برای یک ویژگی AdSense در این شکاف AD تعیین می کند. |
set Category Exclusion | منسوخ شده است. برچسب محرومیت دسته AD سطح آگهی را در این شکاف تنظیم می کند. |
set Click Url | منسوخ شده است. URL کلیک را تنظیم می کند که کاربران پس از کلیک بر روی آگهی هدایت می شوند. |
set Collapse Empty Div | منسوخ شده است. تنظیم می کند که آیا div شکاف باید در صورت عدم وجود تبلیغ در شکاف پنهان شود. |
set Config | گزینه های پیکربندی عمومی را برای این شکاف تنظیم می کند. |
set Force Safe Frame | منسوخ شده است. پیکربندی می کند که آیا تبلیغات در این شکاف باید با استفاده از یک ظرف SafeFrame مجبور به ارائه شود. |
set Safe Frame Config | منسوخ شده است. تنظیمات سطح شکاف را برای پیکربندی SafeFrame تنظیم می کند. |
set Targeting | منسوخ شده است. یک پارامتر هدفمند سفارشی را برای این شکاف تنظیم می کند. |
update Targeting From Map | منسوخ شده است. پارامترهای هدفمند سفارشی را برای این شکاف ، از یک کلید: نقشه Value در یک شیء JSON تنظیم می کند. |
روش ها
سرویس اضافه کردن
addService ( service : Service ) : Slot
- مثال
جاوا اسکریپت
googletag.defineSlot("/1234567/sports", [160, 600], "div").addService(googletag.pubads());
جاوا اسکریپت (میراث)
googletag.defineSlot("/1234567/sports", [160, 600], "div").addService(googletag.pubads());
TypeScript
googletag.defineSlot("/1234567/sports", [160, 600], "div")!.addService(googletag.pubads());
- همچنین ببینید
پارامترها | |
---|---|
service : Service | سرویس اضافه شده |
برمی گرداند | |
---|---|
Slot | شیء شکاف که در آن روش خوانده شده است. |
ClearCategorexclusions
clearCategoryExclusions ( ) : Slot
- مثال
جاوا اسکریپت
// Set category exclusion to exclude ads with 'AirlineAd' labels. const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setCategoryExclusion("AirlineAd") .addService(googletag.pubads()); // Make an ad request. No ad with 'AirlineAd' label will be returned // for the slot. // Clear category exclusions so all ads can be returned. slot.clearCategoryExclusions(); // Make an ad request. Any ad can be returned for the slot.
جاوا اسکریپت (میراث)
// Set category exclusion to exclude ads with 'AirlineAd' labels. var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setCategoryExclusion("AirlineAd") .addService(googletag.pubads()); // Make an ad request. No ad with 'AirlineAd' label will be returned // for the slot. // Clear category exclusions so all ads can be returned. slot.clearCategoryExclusions(); // Make an ad request. Any ad can be returned for the slot.
TypeScript
// Set category exclusion to exclude ads with 'AirlineAd' labels. const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setCategoryExclusion("AirlineAd") .addService(googletag.pubads()); // Make an ad request. No ad with 'AirlineAd' label will be returned // for the slot. // Clear category exclusions so all ads can be returned. slot.clearCategoryExclusions(); // Make an ad request. Any ad can be returned for the slot.
برمی گرداند | |
---|---|
Slot | شیء شکاف که در آن روش خوانده شده است. |
تدوین
clearTargeting ( key ?: string ) : Slot
- مثال
جاوا اسکریپت
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setTargeting("allow_expandable", "true") .setTargeting("interests", ["sports", "music"]) .setTargeting("color", "red") .addService(googletag.pubads()); slot.clearTargeting("color"); // Targeting 'allow_expandable' and 'interests' are still present, // while 'color' was cleared. slot.clearTargeting(); // All targeting has been cleared.
جاوا اسکریپت (میراث)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setTargeting("allow_expandable", "true") .setTargeting("interests", ["sports", "music"]) .setTargeting("color", "red") .addService(googletag.pubads()); slot.clearTargeting("color"); // Targeting 'allow_expandable' and 'interests' are still present, // while 'color' was cleared. slot.clearTargeting(); // All targeting has been cleared.
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setTargeting("allow_expandable", "true") .setTargeting("interests", ["sports", "music"]) .setTargeting("color", "red") .addService(googletag.pubads()); slot.clearTargeting("color"); // Targeting 'allow_expandable' and 'interests' are still present, // while 'color' was cleared. slot.clearTargeting(); // All targeting has been cleared.
- همچنین ببینید
پارامترها | |
---|---|
| کلید پارامتر هدفمند. کلید اختیاری است ؛ اگر مشخص نشده باشد ، تمام پارامترهای هدفمند پاک می شوند. |
برمی گرداند | |
---|---|
Slot | شیء شکاف که در آن روش خوانده شده است. |
تعریف کردن
defineSizeMapping ( sizeMapping : SizeMappingArray ) : Slot
- مثال
جاوا اسکریپت
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); const mapping = googletag .sizeMapping() .addSize([100, 100], [88, 31]) .addSize( [320, 400], [ [320, 50], [300, 50], ], ) .build(); slot.defineSizeMapping(mapping);
جاوا اسکریپت (میراث)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); var mapping = googletag .sizeMapping() .addSize([100, 100], [88, 31]) .addSize( [320, 400], [ [320, 50], [300, 50], ], ) .build(); slot.defineSizeMapping(mapping);
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); const mapping = googletag .sizeMapping() .addSize([100, 100], [88, 31]) .addSize( [320, 400], [ [320, 50], [300, 50], ], ) .build(); slot.defineSizeMapping(mapping!);
- همچنین ببینید
پارامترها | |
---|---|
sizeMapping : SizeMappingArray | آرایه ای از نقشه های اندازه. برای ایجاد آن می توانید از SizemappingBuilder استفاده کنید. نقشه برداری هر اندازه مجموعه ای از دو عنصر است: SingleSearray و GeneralSize . |
برمی گرداند | |
---|---|
Slot | شیء شکاف که در آن روش خوانده شده است. |
دریافت کنید
get ( key : string ) : string
- مثال
جاوا اسکریپت
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .set("adsense_background_color", "#FFFFFF") .addService(googletag.pubads()); slot.get("adsense_background_color"); // Returns '#FFFFFF'.
جاوا اسکریپت (میراث)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .set("adsense_background_color", "#FFFFFF") .addService(googletag.pubads()); slot.get("adsense_background_color"); // Returns '#FFFFFF'.
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .set("adsense_background_color", "#FFFFFF") .addService(googletag.pubads()); slot.get("adsense_background_color"); // Returns '#FFFFFF'.
- همچنین ببینید
پارامترها | |
---|---|
key : string | نام این ویژگی برای جستجوی. |
برمی گرداند | |
---|---|
string | مقدار فعلی برای کلید ویژگی ، یا اگر کلید موجود نیست ، null . |
گچ
getAdUnitPath ( ) : string
- مثال
جاوا اسکریپت
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); slot.getAdUnitPath(); // Returns '/1234567/sports'.
جاوا اسکریپت (میراث)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); slot.getAdUnitPath(); // Returns '/1234567/sports'.
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); slot.getAdUnitPath(); // Returns '/1234567/sports'.
برمی گرداند | |
---|---|
string | مسیر واحد تبلیغ. |
GetAttributeKeys
getAttributeKeys ( ) : string []
- مثال
جاوا اسکریپت
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .set("adsense_background_color", "#FFFFFF") .set("adsense_border_color", "#AABBCC") .addService(googletag.pubads()); slot.getAttributeKeys(); // Returns ['adsense_background_color', 'adsense_border_color'].
جاوا اسکریپت (میراث)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .set("adsense_background_color", "#FFFFFF") .set("adsense_border_color", "#AABBCC") .addService(googletag.pubads()); slot.getAttributeKeys(); // Returns ['adsense_background_color', 'adsense_border_color'].
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .set("adsense_background_color", "#FFFFFF") .set("adsense_border_color", "#AABBCC") .addService(googletag.pubads()); slot.getAttributeKeys(); // Returns ['adsense_background_color', 'adsense_border_color'].
برمی گرداند | |
---|---|
string [] | مجموعه کلیدهای ویژگی. سفارش تعریف نشده است. |
getCategorExclusions
getCategoryExclusions ( ) : string []
- مثال
جاوا اسکریپت
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setCategoryExclusion("AirlineAd") .setCategoryExclusion("TrainAd") .addService(googletag.pubads()); slot.getCategoryExclusions(); // Returns ['AirlineAd', 'TrainAd'].
جاوا اسکریپت (میراث)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setCategoryExclusion("AirlineAd") .setCategoryExclusion("TrainAd") .addService(googletag.pubads()); slot.getCategoryExclusions(); // Returns ['AirlineAd', 'TrainAd'].
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setCategoryExclusion("AirlineAd") .setCategoryExclusion("TrainAd") .addService(googletag.pubads()); slot.getCategoryExclusions(); // Returns ['AirlineAd', 'TrainAd'].
برمی گرداند | |
---|---|
string [] | برچسب های محرومیت دسته آگهی برای این شکاف یا یک آرایه خالی در صورت تنظیم هیچ یک از آنها. |
getConfig
getConfig ( keys : string | string [] ) : Pick < SlotSettingsConfig , "adsenseAttributes" | "targeting" | "categoryExclusion" >
همه خصوصیات
setConfig()
با این روش پشتیبانی نمی شوند. خصوصیات پشتیبانی شده عبارتند از:- مثال
جاوا اسکریپت
const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div"); // Get the value of the `targeting` setting. const targetingConfig = slot.getConfig("targeting"); // Get the value of the `adsenseAttributes` and `categoryExclusion` settings. const config = slot.getConfig(["adsenseAttributes", "categoryExclusion"]);
جاوا اسکریپت (میراث)
var slot = googletag.defineSlot("/1234567/sports", [160, 600], "div"); // Get the value of the `targeting` setting. var targetingConfig = slot.getConfig("targeting"); // Get the value of the `adsenseAttributes` and `categoryExclusion` settings. var config = slot.getConfig(["adsenseAttributes", "categoryExclusion"]);
TypeScript
const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div")!; // Get the value of the `targeting` setting. const targetingConfig = slot.getConfig("targeting"); // Get the value of the `adsenseAttributes` and `categoryExclusion` settings. const config = slot.getConfig(["adsenseAttributes", "categoryExclusion"]);
پارامترها | |
---|---|
keys : string | string [] | کلیدهای گزینه های پیکربندی برای بدست آوردن. |
برمی گرداند | |
---|---|
Pick < SlotSettingsConfig , "adsenseAttributes" | "targeting" | "categoryExclusion" > | گزینه های پیکربندی برای شکاف. |
اطلاعات
getResponseInformation ( ) : ResponseInformation
null
بازگردانده می شود. برمی گرداند | |
---|---|
ResponseInformation | آخرین اطلاعات پاسخ تبلیغات یا null در صورتی که شکاف AD نداشته باشد. |
getSlotElementId
getSlotElementId ( ) : string
div
شکاف ارائه شده هنگام تعریف شکاف را برمی گرداند.- مثال
جاوا اسکریپت
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); slot.getSlotElementId(); // Returns 'div'.
جاوا اسکریپت (میراث)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); slot.getSlotElementId(); // Returns 'div'.
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); slot.getSlotElementId(); // Returns 'div'.
برمی گرداند | |
---|---|
string | Slot div ID. |
دستکاری
getTargeting ( key : string ) : string []
- مثال
جاوا اسکریپت
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setTargeting("allow_expandable", "true") .addService(googletag.pubads()); slot.getTargeting("allow_expandable"); // Returns ['true']. slot.getTargeting("age"); // Returns [] (empty array).
جاوا اسکریپت (میراث)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setTargeting("allow_expandable", "true") .addService(googletag.pubads()); slot.getTargeting("allow_expandable"); // Returns ['true']. slot.getTargeting("age"); // Returns [] (empty array).
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setTargeting("allow_expandable", "true") .addService(googletag.pubads()); slot.getTargeting("allow_expandable"); // Returns ['true']. slot.getTargeting("age"); // Returns [] (empty array).
پارامترها | |
---|---|
key : string | کلید هدفمند برای جستجوی. |
برمی گرداند | |
---|---|
string [] | مقادیر مرتبط با این کلید یا یک آرایه خالی در صورت وجود چنین کلید. |
GetTargetingKeys
getTargetingKeys ( ) : string []
- مثال
جاوا اسکریپت
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setTargeting("allow_expandable", "true") .setTargeting("interests", ["sports", "music"]) .addService(googletag.pubads()); slot.getTargetingKeys(); // Returns ['interests', 'allow_expandable'].
جاوا اسکریپت (میراث)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setTargeting("allow_expandable", "true") .setTargeting("interests", ["sports", "music"]) .addService(googletag.pubads()); slot.getTargetingKeys(); // Returns ['interests', 'allow_expandable'].
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setTargeting("allow_expandable", "true") .setTargeting("interests", ["sports", "music"]) .addService(googletag.pubads()); slot.getTargetingKeys(); // Returns ['interests', 'allow_expandable'].
برمی گرداند | |
---|---|
string [] | مجموعه کلیدهای هدفمند. سفارش تعریف نشده است. |
مجموعه
set ( key : string , value : string ) : Slot
فراخوانی این روش بیش از یک بار برای همان کلید ، مقادیر قبلی را برای آن کلید نادیده می گیرد. تمام مقادیر باید قبل از فراخوانی
display
یا refresh
تنظیم شوند.- مثال
جاوا اسکریپت
// Setting an attribute on a single ad slot. googletag .defineSlot("/1234567/sports", [160, 600], "div") .set("adsense_background_color", "#FFFFFF") .addService(googletag.pubads());
جاوا اسکریپت (میراث)
// Setting an attribute on a single ad slot. googletag .defineSlot("/1234567/sports", [160, 600], "div") .set("adsense_background_color", "#FFFFFF") .addService(googletag.pubads());
TypeScript
// Setting an attribute on a single ad slot. googletag .defineSlot("/1234567/sports", [160, 600], "div")! .set("adsense_background_color", "#FFFFFF") .addService(googletag.pubads());
- همچنین ببینید
پارامترها | |
---|---|
key : string | نام ویژگی. |
value : string | مقدار ویژگی |
برمی گرداند | |
---|---|
Slot | شیء شکاف که در آن روش خوانده شده است. |
setCategorexclusion
setCategoryExclusion ( categoryExclusion : string ) : Slot
- مثال
جاوا اسکریپت
// Label = AirlineAd googletag .defineSlot("/1234567/sports", [160, 600], "div") .setCategoryExclusion("AirlineAd") .addService(googletag.pubads());
جاوا اسکریپت (میراث)
// Label = AirlineAd googletag .defineSlot("/1234567/sports", [160, 600], "div") .setCategoryExclusion("AirlineAd") .addService(googletag.pubads());
TypeScript
// Label = AirlineAd googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setCategoryExclusion("AirlineAd") .addService(googletag.pubads());
- همچنین ببینید
پارامترها | |
---|---|
categoryExclusion : string | برچسب محرومیت دسته AD برای افزودن. |
برمی گرداند | |
---|---|
Slot | شیء شکاف که در آن روش خوانده شده است. |
setclickurl
setClickUrl ( value : string ) : Slot
سرورهای Google Ad Manager هنوز هم یک کلیک را ضبط می کنند حتی اگر URL کلیک جایگزین شود. هر URL صفحه فرود در ارتباط با خلاقیتی که ارائه می شود به مقدار ارائه شده اضافه می شود. تماسهای بعدی مقدار را بازنویسی می کنند. این فقط برای درخواست های غیر SRA کار می کند.
- مثال
جاوا اسکریپت
googletag .defineSlot("/1234567/sports", [160, 600], "div") .setClickUrl("http://www.example.com?original_click_url=") .addService(googletag.pubads());
جاوا اسکریپت (میراث)
googletag .defineSlot("/1234567/sports", [160, 600], "div") .setClickUrl("http://www.example.com?original_click_url=") .addService(googletag.pubads());
TypeScript
googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setClickUrl("http://www.example.com?original_click_url=") .addService(googletag.pubads());
پارامترها | |
---|---|
value : string | برای تنظیم URL کلیک کنید. |
برمی گرداند | |
---|---|
Slot | شیء شکاف که در آن روش خوانده شده است. |
setCollapSeemptyDiv
setCollapseEmptyDiv ( collapse : boolean , collapseBeforeAdFetch ?: boolean ) : Slot
div
شکاف باید در صورت عدم وجود تبلیغ در شکاف پنهان شود. این تنظیمات سطح خدمات را نادیده می گیرد.- مثال
جاوا اسکریپت
googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setCollapseEmptyDiv(true, true) .addService(googletag.pubads()); // The above will cause the div for this slot to be collapsed // when the page is loaded, before ads are requested. googletag .defineSlot("/1234567/sports", [160, 600], "div-2") .setCollapseEmptyDiv(true) .addService(googletag.pubads()); // The above will cause the div for this slot to be collapsed // only after GPT detects that no ads are available for the slot.
جاوا اسکریپت (میراث)
googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setCollapseEmptyDiv(true, true) .addService(googletag.pubads()); // The above will cause the div for this slot to be collapsed // when the page is loaded, before ads are requested. googletag .defineSlot("/1234567/sports", [160, 600], "div-2") .setCollapseEmptyDiv(true) .addService(googletag.pubads()); // The above will cause the div for this slot to be collapsed // only after GPT detects that no ads are available for the slot.
TypeScript
googletag .defineSlot("/1234567/sports", [160, 600], "div-1")! .setCollapseEmptyDiv(true, true) .addService(googletag.pubads()); // The above will cause the div for this slot to be collapsed // when the page is loaded, before ads are requested. googletag .defineSlot("/1234567/sports", [160, 600], "div-2")! .setCollapseEmptyDiv(true) .addService(googletag.pubads()); // The above will cause the div for this slot to be collapsed // only after GPT detects that no ads are available for the slot.
- همچنین ببینید
پارامترها | |
---|---|
collapse : boolean | در صورت بازگشت هیچ آگهی ، شکاف را فرو می ریزید. |
| این که آیا حتی قبل از اینکه یک آگهی انجام شود ، شکاف را فرو می ریزد. اگر فروپاشی true نیست ، نادیده گرفته می شود. |
برمی گرداند | |
---|---|
Slot | شیء شکاف که در آن روش خوانده شده است. |
setConfig
setConfig ( slotConfig : SlotSettingsConfig ) : void
پارامترها | |
---|---|
slotConfig : SlotSettingsConfig | شیء پیکربندی. |
setforcesafeframe
setForceSafeFrame ( forceSafeFrame : boolean ) : Slot
لطفاً هنگام استفاده از این API موارد زیر را در ذهن داشته باشید:
- این تنظیم فقط برای درخواست های تبلیغاتی بعدی که برای اسلات های مربوطه انجام می شود ، اعمال می شود.
- تنظیم سطح شکاف ، در صورت مشخص شدن ، همیشه تنظیم سطح صفحه را نادیده می گیرد.
- در صورت تنظیم
true
(در سطح شکاف یا سطح صفحه) ، تبلیغ همیشه با استفاده از یک کانتینر SafeFrame مستقل از انتخاب ساخته شده در UI Google Ad Manager انجام می شود. - با این حال ، اگر روی
false
یا مانده به صورت نامشخص تنظیم شود ، بسته به نوع خلاق و انتخاب انجام شده در UI Google Ad Manager ، با استفاده از یک ظرف SafeFrame انجام می شود. - این API باید با احتیاط مورد استفاده قرار گیرد زیرا می تواند بر رفتار خلاقانی که تلاش می کنند از Iframes خود خارج شوند یا به آنها اعتماد کند که مستقیماً در صفحه ناشران ارائه می شود ، تأثیر بگذارد.
- مثال
جاوا اسکریپت
googletag .defineSlot("/1234567/sports", [160, 600], "div") .setForceSafeFrame(true) .addService(googletag.pubads());
جاوا اسکریپت (میراث)
googletag .defineSlot("/1234567/sports", [160, 600], "div") .setForceSafeFrame(true) .addService(googletag.pubads());
TypeScript
googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setForceSafeFrame(true) .addService(googletag.pubads());
- همچنین ببینید
پارامترها | |
---|---|
forceSafeFrame : boolean | true که تمام تبلیغات موجود در این شکاف را در Safeframes و false برای امتناع از یک تنظیم سطح صفحه (در صورت وجود) انجام دهید. تنظیم این false در هنگام مشخص شدن در سطح صفحه ، چیزی تغییر نخواهد کرد. |
برمی گرداند | |
---|---|
Slot | شیء شکاف که در آن روش خوانده شده است. |
setSafeFrameConfig
setSafeFrameConfig ( config : SafeFrameConfig ) : Slot
این ترجیحات سطح شکاف ، در صورت مشخص شدن ، ترجیحات سطح صفحه را نادیده می گیرد.
- مثال
جاوا اسکریپت
googletag.pubads().setForceSafeFrame(true); // The following slot will have a sandboxed safeframe that only // disallows top-level navigation. googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setSafeFrameConfig({ sandbox: true }) .addService(googletag.pubads()); // The following slot will inherit page-level settings. googletag.defineSlot("/1234567/news", [160, 600], "div-2").addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
جاوا اسکریپت (میراث)
googletag.pubads().setForceSafeFrame(true); // The following slot will have a sandboxed safeframe that only // disallows top-level navigation. googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setSafeFrameConfig({ sandbox: true }) .addService(googletag.pubads()); // The following slot will inherit page-level settings. googletag.defineSlot("/1234567/news", [160, 600], "div-2").addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
TypeScript
googletag.pubads().setForceSafeFrame(true); // The following slot will have a sandboxed safeframe that only // disallows top-level navigation. googletag .defineSlot("/1234567/sports", [160, 600], "div-1")! .setSafeFrameConfig({ sandbox: true }) .addService(googletag.pubads()); // The following slot will inherit page-level settings. googletag.defineSlot("/1234567/news", [160, 600], "div-2")!.addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
- همچنین ببینید
پارامترها | |
---|---|
config : SafeFrameConfig | شیء پیکربندی. |
برمی گرداند | |
---|---|
Slot | شیء شکاف که در آن روش خوانده شده است. |
سرنگونی
setTargeting ( key : string , value : string | string [] ) : Slot
- مثال
جاوا اسکریپت
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Example with a single value for a key. slot.setTargeting("allow_expandable", "true"); // Example with multiple values for a key inside in an array. slot.setTargeting("interests", ["sports", "music"]);
جاوا اسکریپت (میراث)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Example with a single value for a key. slot.setTargeting("allow_expandable", "true"); // Example with multiple values for a key inside in an array. slot.setTargeting("interests", ["sports", "music"]);
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); // Example with a single value for a key. slot.setTargeting("allow_expandable", "true"); // Example with multiple values for a key inside in an array. slot.setTargeting("interests", ["sports", "music"]);
- همچنین ببینید
پارامترها | |
---|---|
key : string | کلید پارامتر هدفمند. |
value : string | string [] | هدف قرار دادن مقدار پارامتر یا آرایه مقادیر. |
برمی گرداند | |
---|---|
Slot | شیء شکاف که در آن روش خوانده شده است. |
به روزرسانی
updateTargetingFromMap ( map : {
[ adUnitPath : string ] : string | string [] ;
} ) : Slot
یادداشت ها:
- در صورت رونویسی ، فقط آخرین مقدار نگهداری می شود.
- اگر مقدار آرایه ای باشد ، هر مقدار قبلی رونویسی می شود ، ادغام نمی شود.
- مقادیر تنظیم شده در اینجا پارامترهای هدفمند تعیین شده در سطح سرویس را بازنویسی می کنند.
- مثال
جاوا اسکریپت
const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div"); slot.updateTargetingFromMap({ color: "red", interests: ["sports", "music", "movies"], });
جاوا اسکریپت (میراث)
var slot = googletag.defineSlot("/1234567/sports", [160, 600], "div"); slot.updateTargetingFromMap({ color: "red", interests: ["sports", "music", "movies"], });
TypeScript
const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div")!; slot.updateTargetingFromMap({ color: "red", interests: ["sports", "music", "movies"], });
پارامترها | |
---|---|
map : { | کلید پارامتر هدفمند: نقشه مقدار. |
برمی گرداند | |
---|---|
Slot | شیء شکاف که در آن روش خوانده شده است. |
googletag.config
رابط ها | |
---|---|
Ad Expansion Config | تنظیمات برای کنترل گسترش تبلیغ. |
Ad Sense Attributes Config | تنظیمات برای کنترل رفتار تبلیغات AdSense. |
Component Auction Config | یک شیء که یک حراج مؤلفه واحد را در یک حراج تبلیغ در دستگاه ارائه می دهد. |
Interstitial Config | شیئی که رفتار یک شکاف تبلیغاتی بینابینی را تعریف می کند. |
Lazy Load Config | تنظیمات برای کنترل استفاده از بارگذاری تنبل در GPT. |
Page Settings Config | رابط اصلی پیکربندی برای تنظیمات سطح صفحه. |
Privacy Treatments Config | تنظیمات برای کنترل درمان های حریم خصوصی ناشر. |
Publisher Provided Signals Config | ناشر شیء سیگنال ها (PPS) را ارائه داد. |
Safe Frame Config | تنظیمات برای کنترل SafeFrame در GPT. |
Slot Settings Config | رابط اصلی پیکربندی برای تنظیمات سطح شکاف. |
Taxonomy Data | یک شیء حاوی مقادیر برای یک طبقه بندی واحد. |
Video Ads Config | تنظیمات برای پیکربندی تنظیمات مربوط به آگهی ویدیویی. |
نام مستعار | |
---|---|
Interstitial Trigger | محرکهای تبلیغاتی بینابینی پشتیبانی می کنند. |
Privacy Treatment | از درمان های حریم خصوصی ناشر پشتیبانی می شود. |
Taxonomy | طبقه بندی های پشتیبانی شده برای ناشر سیگنال ها (PPS) ارائه می دهند . |
نام مستعار
بینابین
InterstitialTrigger : "unhideWindow" | "navBar"
حریم خصوصی
PrivacyTreatment : "disablePersonalization"
طبقه بندی
Taxonomy : "IAB_AUDIENCE_1_1" | "IAB_CONTENT_2_2"
- همچنین ببینید
googletag.config.adexpansionconfig
خواص | |
---|---|
enabled ? | آیا گسترش تبلیغات فعال است یا غیرفعال است. |
- مثال
جاوا اسکریپت
// Enable ad slot expansion across the entire page. googletag.setConfig({ adExpansion: { enabled: true }, });
جاوا اسکریپت (میراث)
// Enable ad slot expansion across the entire page. googletag.setConfig({ adExpansion: { enabled: true }, });
TypeScript
// Enable ad slot expansion across the entire page. googletag.setConfig({ adExpansion: { enabled: true }, });
خواص
Optional
فعال
enabled ?: boolean
تنظیم این مقدار بر پیش فرض پیکربندی شده در Google Ad Manager غلبه می کند.
googletag.config.adsenseattributeSconfig
از این ویژگی ها می توان برای غلبه بر تنظیمات سمت سرور بر اساس هرگونه درخواست استفاده کرد.
خواص | |
---|---|
adsense _ad _format ? | قالب تبلیغ AdSense. |
adsense _channel _ids ? | شناسه کانال AdSense. |
adsense _test _mode ? | آیا حالت تست فعال است یا خیر. |
document _language ? | زبان صفحه ای که تبلیغات در آن نمایش داده می شود. |
page _url ? | URL صفحه ای که در آن تبلیغات نمایش داده می شود. |
خواص
ADSENSE_AD_FORMAT Optional
adsense_ad_format ?: "120x240_as" | "120x600_as" | "125x125_as" | "160x600_as" | "180x150_as" | "200x200_as" | "234x60_as" | "250x250_as" | "300x250_as" | "336x280_as" | "468x60_as" | "728x90_as"
Optional
adsense_channel_ids
adsense_channel_ids ?: string
مقادیر مجاز شناسه های کانال هستند که توسط '+' از هم جدا شده اند.
مثال:
271828183+314159265
- همچنین ببینید
Optional
adsense_test_mode
adsense_test_mode ?: "on"
هنگامی که
on
قرار گرفت ، تبلیغات به عنوان تست فقط مشخص می شوند و در شمارش یا صورتحساب درج نمی شوند. این تنظیم باید برای تولید ، ترافیک غیر آزمون غیرقانونی باشد. document_language Optional
document_language ?: string
مقادیر مجاز کدهای زبان ISO 639-1 معتبر هستند.
مثال:
en
- همچنین ببینید
page_url Optional
page_url ?: string
مقادیر مجاز URL های معتبر هستند.
مثال:
http://www.example.com
googletag.config.componentauctionconfig
خواص | |
---|---|
auction Config | یک شی پیکربندی حراج برای این حراج مؤلفه. |
config Key | کلید پیکربندی مرتبط با این حراج مؤلفه. |
خواص
حراج
auctionConfig : {
auctionSignals ?: unknown ;
decisionLogicURL : string ;
interestGroupBuyers ?: string [] ;
perBuyerExperimentGroupIds ?: {
[ buyer : string ] : number ;
} ;
perBuyerGroupLimits ?: {
[ buyer : string ] : number ;
} ;
perBuyerSignals ?: {
[ buyer : string ] : unknown ;
} ;
perBuyerTimeouts ?: {
[ buyer : string ] : number ;
} ;
seller : string ;
sellerExperimentGroupId ?: number ;
sellerSignals ?: unknown ;
sellerTimeout ?: number ;
trustedScoringSignalsURL ?: string ;
}
اگر این مقدار روی
null
تنظیم شود ، هر پیکربندی موجود برای configKey
مشخص حذف می شود.- مثال
جاوا اسکریپت
const componentAuctionConfig = { // Seller URL should be https and the same as decisionLogicURL's origin seller: "https://testSeller.com", decisionLogicURL: "https://testSeller.com/ssp/decision-logic.js", interestGroupBuyers: ["https://example-buyer.com"], auctionSignals: { auction_signals: "auction_signals" }, sellerSignals: { seller_signals: "seller_signals" }, perBuyerSignals: { // listed on interestGroupBuyers "https://example-buyer.com": { per_buyer_signals: "per_buyer_signals", }, }, }; const auctionSlot = googletag.defineSlot("/1234567/example", [160, 600]); // To add configKey to the component auction: auctionSlot.setConfig({ componentAuction: [ { configKey: "https://testSeller.com", auctionConfig: componentAuctionConfig, }, ], }); // To remove configKey from the component auction: auctionSlot.setConfig({ componentAuction: [ { configKey: "https://testSeller.com", auctionConfig: null, }, ], });
جاوا اسکریپت (میراث)
var componentAuctionConfig = { // Seller URL should be https and the same as decisionLogicURL's origin seller: "https://testSeller.com", decisionLogicURL: "https://testSeller.com/ssp/decision-logic.js", interestGroupBuyers: ["https://example-buyer.com"], auctionSignals: { auction_signals: "auction_signals" }, sellerSignals: { seller_signals: "seller_signals" }, perBuyerSignals: { // listed on interestGroupBuyers "https://example-buyer.com": { per_buyer_signals: "per_buyer_signals", }, }, }; var auctionSlot = googletag.defineSlot("/1234567/example", [160, 600]); // To add configKey to the component auction: auctionSlot.setConfig({ componentAuction: [ { configKey: "https://testSeller.com", auctionConfig: componentAuctionConfig, }, ], }); // To remove configKey from the component auction: auctionSlot.setConfig({ componentAuction: [ { configKey: "https://testSeller.com", auctionConfig: null, }, ], });
TypeScript
const componentAuctionConfig = { // Seller URL should be https and the same as decisionLogicURL's origin seller: "https://testSeller.com", decisionLogicURL: "https://testSeller.com/ssp/decision-logic.js", interestGroupBuyers: ["https://example-buyer.com"], auctionSignals: { auction_signals: "auction_signals" }, sellerSignals: { seller_signals: "seller_signals" }, perBuyerSignals: { // listed on interestGroupBuyers "https://example-buyer.com": { per_buyer_signals: "per_buyer_signals", }, }, }; const auctionSlot = googletag.defineSlot("/1234567/example", [160, 600])!; // To add configKey to the component auction: auctionSlot.setConfig({ componentAuction: [ { configKey: "https://testSeller.com", auctionConfig: componentAuctionConfig, }, ], }); // To remove configKey from the component auction: auctionSlot.setConfig({ componentAuction: [ { configKey: "https://testSeller.com", auctionConfig: null, }, ], });
- همچنین ببینید
عکسبرداری
configKey : string
این مقدار باید غیر خالی باشد و باید بی نظیر باشد. اگر دو اشیاء
ComponentAuctionConfig
همان مقدار کلید پیکربندی را به اشتراک بگذارند ، آخرین مورد تنظیم شده ، تنظیمات قبلی را بازنویسی می کند. googletag.config.interstititialConfig
خواص | |
---|---|
require Storage Access ? | این که آیا رضایت ذخیره سازی محلی برای نمایش این تبلیغ بینابینی مورد نیاز است. |
triggers ? | پیکربندی ماشه بینابینی برای این تبلیغ بینابینی. |
خواص
نیازهای Optional
requireStorageAccess ?: boolean
GPT از ذخیره محلی برای اجرای کلاه فرکانس برای تبلیغات بینابینی استفاده می کند. با این حال ، کاربرانی که رضایت ذخیره محلی را ارائه نداده اند ، هنوز واجد شرایط دریافت تبلیغات بینابینی هستند. تنظیم این خاصیت برای انتخاب
true
از رفتار پیش فرض ، و تضمین می کند که تبلیغات بین المللی فقط به کاربرانی که رضایت ذخیره محلی ارائه داده اند نشان داده می شود.- مثال
جاوا اسکریپت
// Opt out of showing interstitials to users // without local storage consent. const interstitialSlot = googletag.defineOutOfPageSlot( "/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL, ); interstitialSlot.setConfig({ interstitial: { requireStorageAccess: true, // defaults to false }, });
جاوا اسکریپت (میراث)
// Opt out of showing interstitials to users // without local storage consent. var interstitialSlot = googletag.defineOutOfPageSlot( "/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL, ); interstitialSlot.setConfig({ interstitial: { requireStorageAccess: true, // defaults to false }, });
TypeScript
// Opt out of showing interstitials to users // without local storage consent. const interstitialSlot = googletag.defineOutOfPageSlot( "/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL, )!; interstitialSlot.setConfig({ interstitial: { requireStorageAccess: true, // defaults to false }, });
- همچنین ببینید
محرکهای Optional
triggers ?: Partial < Record < InterstitialTrigger , boolean > >
تنظیم مقدار یک ماشه بینابینی در
true
باعث فعال شدن آن می شود و false
آن را غیرفعال می کند. با این کار مقادیر پیش فرض پیکربندی شده در Google Ad Manager غلبه می کند.- مثال
جاوا اسکریپت
// Define a GPT managed web interstitial ad slot. const interstitialSlot = googletag.defineOutOfPageSlot( "/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL, ); // Enable optional interstitial triggers. // Change this value to false to disable. const enableTriggers = true; interstitialSlot.setConfig({ interstitial: { triggers: { navBar: enableTriggers, unhideWindow: enableTriggers, }, }, });
جاوا اسکریپت (میراث)
// Define a GPT managed web interstitial ad slot. var interstitialSlot = googletag.defineOutOfPageSlot( "/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL, ); // Enable optional interstitial triggers. // Change this value to false to disable. var enableTriggers = true; interstitialSlot.setConfig({ interstitial: { triggers: { navBar: enableTriggers, unhideWindow: enableTriggers, }, }, });
TypeScript
// Define a GPT managed web interstitial ad slot. const interstitialSlot = googletag.defineOutOfPageSlot( "/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL, )!; // Enable optional interstitial triggers. // Change this value to false to disable. const enableTriggers = true; interstitialSlot.setConfig({ interstitial: { triggers: { navBar: enableTriggers, unhideWindow: enableTriggers, }, }, });
- همچنین ببینید
googletag.config.LazyloadConfig
خواص | |
---|---|
fetch Margin Percent ? | حداقل فاصله از Viewport فعلی یک شکاف باید قبل از درخواست AD باشد ، که به عنوان درصدی از اندازه Viewport بیان شده است. |
mobile Scaling ? | چند برابر برای حاشیه دستگاه های تلفن همراه اعمال می شود. |
render Margin Percent ? | حداقل فاصله از نمای فعلی یک شکاف باید قبل از ارائه تبلیغات باشد ، که به عنوان درصدی از اندازه نمای بیان شده است. |
- همچنین ببینید
خواص
Optional
fetchmarginpercent
fetchMarginPercent ?: number
این تنظیم در رابطه با RenderMarginPercent استفاده می شود ، این تنظیم امکان پیشگیری از یک تبلیغ را فراهم می کند ، اما در انتظار ارائه و بارگیری سایر منابع دیگر است. به این ترتیب ، این مقدار همیشه باید بیشتر از یا مساوی با RenderMarginPercent باشد.
مقدار
0
به معنای "هنگامی که شکاف وارد نمای Viewport می شود" ، 100
به معنای "وقتی تبلیغ 1 Viewport از دور است" و غیره. Mobilescaling Optional
mobileScaling ?: number
این امر باعث می شود حاشیه های مختلف در دسک تاپ موبایل در مقابل ، جایی که اندازه نمای و سرعت پیمایش متفاوت است. به عنوان مثال ، یک مقدار 2.0 تمام حاشیه ها را در 2 دستگاه های تلفن همراه ضرب می کند ، افزایش حداقل فاصله یک شکاف می تواند قبل از واکشی و ارائه باشد.
rendermarginpercent Optional
renderMarginPercent ?: number
این تنظیم در رابطه با FetchMarginPercent استفاده می شود ، این تنظیم امکان پیشگیری از یک تبلیغ را فراهم می کند ، اما در انتظار ارائه و بارگیری سایر منابع دیگر است. به همین ترتیب ، این مقدار همیشه باید کمتر از یا مساوی با fetchmarginpercent باشد.
مقدار
0
به معنای "هنگامی که شکاف وارد نمای Viewport می شود" ، 100
به معنای "وقتی تبلیغ 1 Viewport از دور است" و غیره. googletag.config.pagesettingsconfig
اجازه می دهد تا چندین ویژگی را با یک تماس API تنظیم کنید.
کلیه خصوصیات ذکر شده در زیر نمونه هایی هستند و ویژگی های واقعی استفاده از SetConfig را منعکس نمی کنند. برای مجموعه ویژگی ها ، قسمتهای موجود در نوع PagesettingsConfig را در زیر مشاهده کنید.
مثال ها:
- فقط ویژگی های مشخص شده در تماس googletag.setConfig اصلاح شده است.
// Configure feature alpha. googletag.setConfig({ alpha: {...} }); // Configure feature bravo. Feature alpha is unchanged. googletag.setConfig({ bravo: {...} });
- تمام تنظیمات برای یک ویژگی معین با هر تماس به Googletag.setConfig به روز می شود.
// Configure feature charlie to echo = 1, foxtrot = true. googletag.setConfig({ charlie: { echo: 1, foxtrot: true, } }); // Update feature charlie to echo = 2. Since foxtrot was not specified, // the value is cleared. googletag.setConfig({ charlie: { echo: 2 } });
- تمام تنظیمات یک ویژگی را می توان با عبور
null
پاک کرد.// Configure features delta, golf, and hotel. googletag.setConfig({ delta: {...}, golf: {...}, hotel: {...}, }); // Feature delta and hotel are cleared, but feature golf remains set. googletag.setConfig({ delta: null, hotel: null, });
خواص | |
---|---|
ad Expansion ? | تنظیمات برای کنترل گسترش تبلیغ. |
adsense Attributes ? | تنظیم برای پیکربندی ویژگی های AdSense. |
ad Yield ? | منسوخ شده است. |
category Exclusion ? | تنظیم برای پیکربندی استثناء دسته بندی تبلیغات. |
centering ? | تنظیم برای کنترل مرکز افقی تبلیغات. |
collapse Div ? | تنظیم برای کنترل رفتار فروپاشی شکافهای AD. |
disable Initial Load ? | تنظیم برای کنترل هنگام درخواست تبلیغات. |
lazy Load ? | تنظیمات برای کنترل استفاده از بارگذاری تنبل در GPT. |
location ? | تنظیم موارد خط هدف جغرافیایی به مکان های جغرافیایی. |
pps ? | تنظیمات برای کنترل ناشر سیگنال ها (PPS) را ارائه داد. |
privacy Treatments ? | تنظیمات برای کنترل درمان های حریم خصوصی ناشر. |
safe Frame ? | تنظیمات برای کنترل استفاده از SafeFrame در GPT. |
single Request ? | تنظیم برای فعال یا غیرفعال کردن معماری درخواست تک (SRA). |
targeting ? | تنظیم برای کنترل هدف گذاری ارزش کلید. |
thread Yield ? | تنظیم برای کنترل اینکه آیا GPT باید هنگام درخواست و ارائه خلاقیت ، موضوع JS را به دست آورد. |
video Ads ? | تنظیمات برای کنترل تبلیغات ویدیویی. |
خواص
adexpansion Optional
adExpansion ?: AdExpansionConfig
adsenseattributes Optional
adsenseAttributes ?: AdSenseAttributesConfig
ویژگی های AdSense پیکربندی شده از طریق این تنظیم برای کلیه شکافهای تبلیغاتی در صفحه اعمال می شود. این تنظیم ممکن است چندین بار نامیده شود تا مقادیر چند ویژگی را تعریف کند ، یا مقادیر موجود را بازنویسی کند.
تغییرات ویژگی AdSense فقط در مورد تبلیغات درخواست شده پس از فراخوانی این روش اعمال می شود. به همین دلیل ، توصیه می شود قبل از هرگونه تماس با googletag.display یا pubadsservice.refresh ، این روش را فراخوانی کنید.
- مثال
جاوا اسکریپت
// Set the document language and page URL. googletag.setConfig({ adsenseAttributes: { document_language: "en", page_url: "http://www.example.com" }, }); // Clear the page URL only. googletag.setConfig({ adsenseAttributes: { page_url: null } }); // Clear all AdSense attributes. googletag.setConfig({ adsenseAttributes: null });
جاوا اسکریپت (میراث)
// Set the document language and page URL. googletag.setConfig({ adsenseAttributes: { document_language: "en", page_url: "http://www.example.com" }, }); // Clear the page URL only. googletag.setConfig({ adsenseAttributes: { page_url: null } }); // Clear all AdSense attributes. googletag.setConfig({ adsenseAttributes: null });
TypeScript
// Set the document language and page URL. googletag.setConfig({ adsenseAttributes: { document_language: "en", page_url: "http://www.example.com" }, }); // Clear the page URL only. googletag.setConfig({ adsenseAttributes: { page_url: null } }); // Clear all AdSense attributes. googletag.setConfig({ adsenseAttributes: null });
Adyield Optional
adYield ?: "DISABLED" | "ENABLED_ALL_SLOTS"
دسته بندی Optional
xclusion
categoryExclusion ?: string []
- مثال
جاوا اسکریپت
// Label = AirlineAd. googletag.setConfig({ categoryExclusion: ["AirlineAd"] }); // Clearing category exclusion setting. googletag.setConfig({ categoryExclusion: null });
جاوا اسکریپت (میراث)
// Label = AirlineAd. googletag.setConfig({ categoryExclusion: ["AirlineAd"] }); // Clearing category exclusion setting. googletag.setConfig({ categoryExclusion: null });
TypeScript
// Label = AirlineAd. googletag.setConfig({ categoryExclusion: ["AirlineAd"] }); // Clearing category exclusion setting. googletag.setConfig({ categoryExclusion: null });
- همچنین ببینید
مرکز Optional
centering ?: boolean
تغییرات مرکز افقی فقط در مورد تبلیغات درخواست شده پس از فراخوانی این روش اعمال می شود. به همین دلیل ، توصیه می شود قبل از هرگونه تماس با googletag.display یا pubadsservice.refresh ، این روش را فراخوانی کنید.
- مثال
جاوا اسکریپت
// Make ads centered. googletag.setConfig({ centering: true }); // Clear the centering setting. googletag.setConfig({ centering: null });
جاوا اسکریپت (میراث)
// Make ads centered. googletag.setConfig({ centering: true }); // Clear the centering setting. googletag.setConfig({ centering: null });
TypeScript
// Make ads centered. googletag.setConfig({ centering: true }); // Clear the centering setting. googletag.setConfig({ centering: null });
Optional
فروپاشی
collapseDiv ?: "DISABLED" | "BEFORE_FETCH" | "ON_NO_FILL"
یک شکاف تبلیغاتی فروپاشی هیچ فضایی در صفحه نمی گیرد.
مقادیر پشتیبانی شده:
-
null
(پیش فرض): شکاف از بین نمی رود. -
DISABLED
: شکاف فروپاشی نخواهد کرد ، خواه یک تبلیغ بازگردانده شود یا خیر. -
BEFORE_FETCH
: شکاف شروع به فروپاشی می کند و هنگام بازگشت یک تبلیغ گسترش می یابد. -
ON_NO_FILL
: شکاف شروع می شود و در صورت عدم بازگشت تبلیغ ، فروپاشی می شود.
- مثال
جاوا اسکریپت
// Collapse the div for this slot if no ad is returned. googletag.setConfig({ collapseDiv: "ON_NO_FILL" }); // Collapse the div for this slot by default, and expand only // if an ad is returned. googletag.setConfig({ collapseDiv: "BEFORE_FETCH" }); // Do not collapse the div for this slot. googletag.setConfig({ collapseDiv: "DISABLED" }); // Clear the collapse setting. googletag.setConfig({ collapseDiv: null });
جاوا اسکریپت (میراث)
// Collapse the div for this slot if no ad is returned. googletag.setConfig({ collapseDiv: "ON_NO_FILL" }); // Collapse the div for this slot by default, and expand only // if an ad is returned. googletag.setConfig({ collapseDiv: "BEFORE_FETCH" }); // Do not collapse the div for this slot. googletag.setConfig({ collapseDiv: "DISABLED" }); // Clear the collapse setting. googletag.setConfig({ collapseDiv: null });
TypeScript
// Collapse the div for this slot if no ad is returned. googletag.setConfig({ collapseDiv: "ON_NO_FILL" }); // Collapse the div for this slot by default, and expand only // if an ad is returned. googletag.setConfig({ collapseDiv: "BEFORE_FETCH" }); // Do not collapse the div for this slot. googletag.setConfig({ collapseDiv: "DISABLED" }); // Clear the collapse setting. googletag.setConfig({ collapseDiv: null });
- همچنین ببینید
بارگیری Optional
disableInitialLoad ?: boolean
به طور پیش فرض ، روش googletag.display هر دو اسلات تبلیغاتی را ثبت می کند و تبلیغات را برای آنها درخواست می کند. با این حال ، مواقعی وجود دارد که ممکن است ترجیح داده شود این اقدامات را جدا کند ، تا بتوانید هنگام بارگیری محتوای AD دقیق تر کنترل کنید.
با فعال کردن این تنظیم ، هنگام فراخوانی روش
display()
، از تبلیغات برای اسلات های ثبت شده درخواست نمی شود. در عوض ، برای شروع درخواست تبلیغ ، باید یک تماس جداگانه به pubadsservice.refresh انجام شود.این روش باید قبل از فراخوانی Googletag.Enableservice فراخوانی شود.
- مثال
جاوا اسکریپت
// Prevent requesting ads when `display()` is called. googletag.setConfig({ disableInitialLoad: true });
جاوا اسکریپت (میراث)
// Prevent requesting ads when `display()` is called. googletag.setConfig({ disableInitialLoad: true });
TypeScript
// Prevent requesting ads when `display()` is called. googletag.setConfig({ disableInitialLoad: true });
lazyload Optional
lazyLoad ?: LazyLoadConfig
بارگیری تنبل تکنیکی برای تأخیر در درخواست و ارائه تبلیغات تا زمانی که به نمای کاربر نزدیک شود. برای مثال بیشتر ، به نمونه بارگذاری تنبل مراجعه کنید.
توجه: اگر
singleRequest
فعال باشد ، تنبل تنبل فقط هنگامی کار می کند که همه شکاف ها خارج از حاشیه واکشی باشند.هر تنظیمات بار تنبل که هنگام فراخوانی
setConfig()
مشخص نشده است از یک مقدار پیش فرض تعیین شده توسط Google استفاده می کند. این پیش فرض ها ممکن است با گذشت زمان تنظیم شوند. برای غیرفعال کردن یک تنظیم خاص ، مقدار را روی null
تنظیم کنید.- مثال
جاوا اسکریپت
// Enable lazy loading. googletag.setConfig({ lazyLoad: { // Fetch slots within 5 viewports. fetchMarginPercent: 500, // Render slots within 2 viewports. renderMarginPercent: 200, // Double the above values on mobile. mobileScaling: 2.0, }, }); // Clear fetch margin only. googletag.setConfig({ lazyLoad: { fetchMarginPercent: null }, }); // Clear all lazy loading settings. googletag.setConfig({ lazyLoad: null });
جاوا اسکریپت (میراث)
// Enable lazy loading. googletag.setConfig({ lazyLoad: { // Fetch slots within 5 viewports. fetchMarginPercent: 500, // Render slots within 2 viewports. renderMarginPercent: 200, // Double the above values on mobile. mobileScaling: 2.0, }, }); // Clear fetch margin only. googletag.setConfig({ lazyLoad: { fetchMarginPercent: null }, }); // Clear all lazy loading settings. googletag.setConfig({ lazyLoad: null });
TypeScript
// Enable lazy loading. googletag.setConfig({ lazyLoad: { // Fetch slots within 5 viewports. fetchMarginPercent: 500, // Render slots within 2 viewports. renderMarginPercent: 200, // Double the above values on mobile. mobileScaling: 2.0, }, }); // Clear fetch margin only. googletag.setConfig({ lazyLoad: { fetchMarginPercent: null }, }); // Clear all lazy loading settings. googletag.setConfig({ lazyLoad: null });
مکان Optional
location ?: string
- مثال
جاوا اسکریپت
// Geo-target line items to US postal code 10001. googletag.setConfig({ location: "10001,US" }); // Clear the location setting. googletag.setConfig({ location: null });
جاوا اسکریپت (میراث)
// Geo-target line items to US postal code 10001. googletag.setConfig({ location: "10001,US" }); // Clear the location setting. googletag.setConfig({ location: null });
TypeScript
// Geo-target line items to US postal code 10001. googletag.setConfig({ location: "10001,US" }); // Clear the location setting. googletag.setConfig({ location: null });
- همچنین ببینید
PPS Optional
درمان های حریم خصوصی Optional
privacyTreatments ?: PrivacyTreatmentsConfig
SafeFrame Optional
safeFrame ?: SafeFrameConfig
مقادیر پیکربندی شده از طریق این تنظیم برای کلیه شکافهای تبلیغاتی در صفحه اعمال می شود. شکافهای تبلیغاتی فردی ممکن است این مقادیر را از طریق SlotsettingsConfig.SafeFrame غلبه کنند.
- مثال
جاوا اسکریپت
// Force SafeFrame for all ads on the page. googletag.setConfig({ safeFrame: { forceSafeFrame: true }, }); // Configure SafeFrame to allow overlay expansion. googletag.setConfig({ safeFrame: { allowOverlayExpansion: true }, }); // Clear forceSafeFrame setting. googletag.setConfig({ safeFrame: { forceSafeFrame: null }, }); // Clear all SafeFrame settings. googletag.setConfig({ safeFrame: null });
جاوا اسکریپت (میراث)
// Force SafeFrame for all ads on the page. googletag.setConfig({ safeFrame: { forceSafeFrame: true }, }); // Configure SafeFrame to allow overlay expansion. googletag.setConfig({ safeFrame: { allowOverlayExpansion: true }, }); // Clear forceSafeFrame setting. googletag.setConfig({ safeFrame: { forceSafeFrame: null }, }); // Clear all SafeFrame settings. googletag.setConfig({ safeFrame: null });
TypeScript
// Force SafeFrame for all ads on the page. googletag.setConfig({ safeFrame: { forceSafeFrame: true }, }); // Configure SafeFrame to allow overlay expansion. googletag.setConfig({ safeFrame: { allowOverlayExpansion: true }, }); // Clear forceSafeFrame setting. googletag.setConfig({ safeFrame: { forceSafeFrame: null }, }); // Clear all SafeFrame settings. googletag.setConfig({ safeFrame: null });
SingLerequest Optional
singleRequest ?: boolean
هنگامی که SRA فعال شد ، تمام اسلات های تبلیغاتی تعریف شده قبل از یک تماس googletag.display یا pubadsservice.refresh در یک درخواست تبلیغی واحد قرار می گیرند. این مزایای عملکرد را فراهم می کند ، اما همچنین برای اطمینان از مشروبات الکلی و محرومیت های رقابتی نیز لازم است.
هنگامی که SRA غیرفعال است ، از هر شکاف تبلیغاتی به صورت جداگانه درخواست می شود. این رفتار پیش فرض GPT است.
این روش باید قبل از تماس با Googletag.Enableservice فراخوانی شود.
- مثال
جاوا اسکریپت
// Enable Single Request Architecture. googletag.setConfig({ singleRequest: true });
جاوا اسکریپت (میراث)
// Enable Single Request Architecture. googletag.setConfig({ singleRequest: true });
TypeScript
// Enable Single Request Architecture. googletag.setConfig({ singleRequest: true });
هدف گیری Optional
targeting ?: Record < string , string | string [] >
هدف قرار دادن پیکربندی شده از طریق این تنظیم برای کلیه شکافهای تبلیغاتی در صفحه اعمال می شود. این تنظیم ممکن است چندین بار نامیده شود تا چندین ارزش کلید هدفمند را تعریف کند ، یا مقادیر موجود را بازنویسی کند. کلیدهای هدفمند در حساب Google Ad Manager شما تعریف شده اند.
- مثال
جاوا اسکریپت
// Setting a single targeting key-value. googletag.setConfig({ targeting: { interests: "sports" } }); // Setting multiple values for a single targeting key googletag.setConfig({ targeting: { interests: ["sports", "music"] } }); // Setting multiple targeting key-values at once. googletag.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } }); // Clearing a single targeting key. googletag.setConfig({ targeting: { interests: null } });
جاوا اسکریپت (میراث)
// Setting a single targeting key-value. googletag.setConfig({ targeting: { interests: "sports" } }); // Setting multiple values for a single targeting key googletag.setConfig({ targeting: { interests: ["sports", "music"] } }); // Setting multiple targeting key-values at once. googletag.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } }); // Clearing a single targeting key. googletag.setConfig({ targeting: { interests: null } });
TypeScript
// Setting a single targeting key-value. googletag.setConfig({ targeting: { interests: "sports" } }); // Setting multiple values for a single targeting key googletag.setConfig({ targeting: { interests: ["sports", "music"] } }); // Setting multiple targeting key-values at once. googletag.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } }); // Clearing a single targeting key. googletag.setConfig({ targeting: { interests: null } });
- همچنین ببینید
Threadyield Optional
threadYield ?: "DISABLED" | "ENABLED_ALL_SLOTS"
GPT فقط برای مرورگرهایی که از برنامه ریزی Sepost.posttask یا Scheduler.Yield API پشتیبانی می کنند ، ارائه می دهد.
مقادیر پشتیبانی شده:
-
null
(پیش فرض): GPT موضوع JS را برای شکافهای خارج از نمای ارائه می دهد. -
ENABLED_ALL_SLOTS
: GPT بدون در نظر گرفتن اینکه شکاف در نمای است ، موضوع JS را برای همه شکاف ها به دست می آورد. -
DISABLED
: GPT موضوع JS را به همراه نخواهد داشت.
- مثال
جاوا اسکریپت
// Disable yielding. googletag.setConfig({ threadYield: "DISABLED" }); // Enable yielding for all slots. googletag.setConfig({ threadYield: "ENABLED_ALL_SLOTS" }); // Enable yielding only for slots outside of the viewport (default). googletag.setConfig({ threadYield: null });
جاوا اسکریپت (میراث)
// Disable yielding. googletag.setConfig({ threadYield: "DISABLED" }); // Enable yielding for all slots. googletag.setConfig({ threadYield: "ENABLED_ALL_SLOTS" }); // Enable yielding only for slots outside of the viewport (default). googletag.setConfig({ threadYield: null });
TypeScript
// Disable yielding. googletag.setConfig({ threadYield: "DISABLED" }); // Enable yielding for all slots. googletag.setConfig({ threadYield: "ENABLED_ALL_SLOTS" }); // Enable yielding only for slots outside of the viewport (default). googletag.setConfig({ threadYield: null });
- همچنین ببینید
ویدیوهای Optional
videoAds ?: VideoAdsConfig
- مثال
جاوا اسکریپت
// Enable video ads and set video content and content source IDs. googletag.setConfig({ videoAds: { enableVideoAds: true, videoContentId: "e1eGlRL7ju8", videoCmsId: "1234567", }, });
جاوا اسکریپت (میراث)
// Enable video ads and set video content and content source IDs. googletag.setConfig({ videoAds: { enableVideoAds: true, videoContentId: "e1eGlRL7ju8", videoCmsId: "1234567", }, });
TypeScript
// Enable video ads and set video content and content source IDs. googletag.setConfig({ videoAds: { enableVideoAds: true, videoContentId: "e1eGlRL7ju8", videoCmsId: "1234567", }, });
- همچنین ببینید
googletag.config.PrivacyTreatmentsConfig
خواص | |
---|---|
treatments | مجموعه ای از درمان های حریم خصوصی ناشر برای فعال کردن. |
خواص
درمان ها
treatments : "disablePersonalization" []
- مثال
جاوا اسکریپت
// Disable personalization across the entire page. googletag.setConfig({ privacyTreatments: { treatments: ["disablePersonalization"] }, });
جاوا اسکریپت (میراث)
// Disable personalization across the entire page. googletag.setConfig({ privacyTreatments: { treatments: ["disablePersonalization"] }, });
TypeScript
// Disable personalization across the entire page. googletag.setConfig({ privacyTreatments: { treatments: ["disablePersonalization"] }, });
googletag.config.PublisherProvideSignalSconfig
خواص | |
---|---|
taxonomies | یک شیء حاوی نقشه های طبقه بندی یا تهی برای پاک کردن پیکربندی. |
- مثال
جاوا اسکریپت
googletag.setConfig({ pps: { taxonomies: { IAB_AUDIENCE_1_1: { values: ["6", "626"] }, // '6' = 'Demographic | Age Range | 30-34' // '626' = 'Interest | Sports | Darts' IAB_CONTENT_2_2: { values: ["48", "127"] }, // '48' = 'Books and Literature | Fiction' // '127' = 'Careers | Job Search' }, }, });
جاوا اسکریپت (میراث)
googletag.setConfig({ pps: { taxonomies: { IAB_AUDIENCE_1_1: { values: ["6", "626"] }, // '6' = 'Demographic | Age Range | 30-34' // '626' = 'Interest | Sports | Darts' IAB_CONTENT_2_2: { values: ["48", "127"] }, // '48' = 'Books and Literature | Fiction' // '127' = 'Careers | Job Search' }, }, });
TypeScript
googletag.setConfig({ pps: { taxonomies: { IAB_AUDIENCE_1_1: { values: ["6", "626"] }, // '6' = 'Demographic | Age Range | 30-34' // '626' = 'Interest | Sports | Darts' IAB_CONTENT_2_2: { values: ["48", "127"] }, // '48' = 'Books and Literature | Fiction' // '127' = 'Careers | Job Search' }, }, });
خواص
طبقه بندی
taxonomies : Partial < Record < Taxonomy , TaxonomyData > >
googletag.config.safeframeConfig
خواص | |
---|---|
allow Overlay Expansion ? | این که آیا SafeFrame باید با پوشش محتوای صفحه ، محتوای تبلیغ را گسترش دهد. |
allow Push Expansion ? | این که آیا SafeFrame باید با فشار دادن محتوای صفحه ، محتوای تبلیغ را گسترش دهد. |
force Safe Frame ? | این که آیا AD (ها) باید با استفاده از یک ظرف Safeframe مجبور به ارائه شوند. |
sandbox ? | این که آیا SafeFrame باید از ویژگی HTML5 Sandbox برای جلوگیری از پیمایش سطح بالا و بدون تعامل کاربر استفاده کند. |
use Unique Domain ? | منسوخ شده است. این که آیا SafeFrame باید از زیر دامنه های تصادفی برای خلاقیت های رزرو استفاده کند. |
- همچنین ببینید
خواص
AllowOverlayExpansion Optional
allowOverlayExpansion ?: boolean
Optional
AllowpushExpansion
allowPushExpansion ?: boolean
نیروهای Optional
forceSafeFrame ?: boolean
جعبه ماسه Optional
sandbox ?: boolean
true
است (نمی توان مجبور به false
شد). توجه داشته باشید که ویژگی Sandbox افزونه ها را غیرفعال می کند (به عنوان مثال Flash). استفاده Optional
useUniqueDomain ?: boolean
null
عبور کنید.توجه: این ویژگی به طور پیش فرض فعال است.
- همچنین ببینید
googletag.config.slotsettingsconfig
اجازه می دهد تا چندین ویژگی را با یک تماس API واحد برای یک شکاف واحد تنظیم کنید.
کلیه خصوصیات ذکر شده در زیر نمونه هایی هستند و ویژگی های واقعی استفاده از SetConfig را منعکس نمی کنند. برای مجموعه ویژگی ها ، زمینه های موجود در نوع slotsettingsconfig را در زیر مشاهده کنید.
مثال ها:
- فقط ویژگی های مشخص شده در تماس slot.setConfig اصلاح شده است.
const slot = googletag.defineSlot("/1234567/example", [160, 600]); // Configure feature alpha. slot.setConfig({ alpha: {...} }); // Configure feature bravo. Feature alpha is unchanged. slot.setConfig({ bravo: {...} });
- تمام تنظیمات برای یک ویژگی معین با هر تماس به Slot.SetConfig به روز می شود.
// Configure feature charlie to echo = 1, foxtrot = true. slot.setConfig({ charlie: { echo: 1, foxtrot: true, } }); // Update feature charlie to echo = 2. Since foxtrot was not specified, // the value is cleared. slot.setConfig({ charlie: { echo: 2 } });
- تمام تنظیمات یک ویژگی را می توان با عبور
null
پاک کرد.// Configure features delta, golf, and hotel. slot.setConfig({ delta: {...}, golf: {...}, hotel: {...}, }); // Feature delta and hotel are cleared, but feature golf remains set. slot.setConfig({ delta: null, hotel: null, });
خواص | |
---|---|
ad Expansion ? | تنظیمات برای پیکربندی گسترش تبلیغ. |
adsense Attributes ? | تنظیم برای پیکربندی ویژگی های AdSense. |
category Exclusion ? | تنظیم برای پیکربندی استثناء دسته بندی تبلیغات. |
click Url ? | تنظیم برای پیکربندی URL که کاربران پس از کلیک بر روی آگهی هدایت می شوند. |
collapse Div ? | تنظیم برای پیکربندی رفتار فروپاشی شکاف آگهی. |
component Auction ? | مجموعه ای از حراج های مؤلفه که در حراج تبلیغاتی در دستگاه قرار می گیرند. |
interstitial ? | تنظیماتی که رفتار شکاف تبلیغاتی بینابینی را پیکربندی می کنند. |
safe Frame ? | تنظیمات برای پیکربندی استفاده از SafeFrame در GPT. |
targeting ? | تنظیم برای پیکربندی هدفگذاری ارزش کلید. |
خواص
adexpansion Optional
adExpansion ?: AdExpansionConfig
- همچنین ببینید
adsenseattributes Optional
adsenseAttributes ?: AdSenseAttributesConfig
ویژگی های AdSense پیکربندی شده از طریق این تنظیم فقط در مورد شکاف AD اعمال می شود. این تنظیم ممکن است چندین بار نامیده شود تا مقادیر چند ویژگی را تعریف کند ، یا مقادیر موجود را بازنویسی کند.
تغییرات ویژگی AdSense فقط در مورد تبلیغات درخواست شده پس از فراخوانی این روش اعمال می شود. به همین دلیل ، توصیه می شود قبل از هرگونه تماس با googletag.display یا pubadsservice.refresh ، این روش را فراخوانی کنید.
- مثال
جاوا اسکریپت
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Set the AdSense ad format and channel IDs. slot.setConfig({ adsenseAttributes: { adsense_ad_format: "120x240_as", adsense_channel_ids: "271828183+314159265", }, }); // Clear the AdSense channel IDs only. slot.setConfig({ adsenseAttributes: { adsense_channel_ids: null } }); // Clear all AdSense attributes. slot.setConfig({ adsenseAttributes: null });
جاوا اسکریپت (میراث)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Set the AdSense ad format and channel IDs. slot.setConfig({ adsenseAttributes: { adsense_ad_format: "120x240_as", adsense_channel_ids: "271828183+314159265", }, }); // Clear the AdSense channel IDs only. slot.setConfig({ adsenseAttributes: { adsense_channel_ids: null } }); // Clear all AdSense attributes. slot.setConfig({ adsenseAttributes: null });
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); // Set the AdSense ad format and channel IDs. slot.setConfig({ adsenseAttributes: { adsense_ad_format: "120x240_as", adsense_channel_ids: "271828183+314159265", }, }); // Clear the AdSense channel IDs only. slot.setConfig({ adsenseAttributes: { adsense_channel_ids: null } }); // Clear all AdSense attributes. slot.setConfig({ adsenseAttributes: null });
دسته بندی Optional
xclusion
categoryExclusion ?: string []
- مثال
جاوا اسکریپت
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Label = AirlineAd slot.setConfig({ categoryExclusion: ["AirlineAd"], }); // Clearing category exclusion setting. slot.setConfig({ categoryExclusion: null });
جاوا اسکریپت (میراث)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Label = AirlineAd slot.setConfig({ categoryExclusion: ["AirlineAd"], }); // Clearing category exclusion setting. slot.setConfig({ categoryExclusion: null });
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); // Label = AirlineAd slot.setConfig({ categoryExclusion: ["AirlineAd"], }); // Clearing category exclusion setting. slot.setConfig({ categoryExclusion: null });
- همچنین ببینید
clickurl Optional
clickUrl ?: string
سرورهای Google Ad Manager هنوز هم یک کلیک را ضبط می کنند حتی اگر URL کلیک جایگزین شود. هر URL صفحه فرود در ارتباط با خلاقیتی که ارائه می شود به مقدار ارائه شده اضافه می شود. تنظیم این مقدار بیش از یک بار ، هر مقدار قبلی پیکربندی شده را بازنویسی می کند. عبور در
null
مقدار را پاک می کند.توجه: این تنظیم فقط در مورد درخواست های غیر SRA اعمال می شود.
- مثال
جاوا اسکریپت
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Sets the click URL to 'http://www.example.com?original_click_url='. slot.setConfig({ clickUrl: "http://www.example.com?original_click_url=", }); // Clears the click URL. slot.setConfig({ clickUrl: null, });
جاوا اسکریپت (میراث)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Sets the click URL to 'http://www.example.com?original_click_url='. slot.setConfig({ clickUrl: "http://www.example.com?original_click_url=", }); // Clears the click URL. slot.setConfig({ clickUrl: null, });
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); // Sets the click URL to 'http://www.example.com?original_click_url='. slot.setConfig({ clickUrl: "http://www.example.com?original_click_url=", }); // Clears the click URL. slot.setConfig({ clickUrl: null, });
Optional
فروپاشی
collapseDiv ?: "DISABLED" | "BEFORE_FETCH" | "ON_NO_FILL"
یک شکاف تبلیغاتی فروپاشی هیچ فضایی در صفحه نمی گیرد.
مقادیر پشتیبانی شده:
-
null
(پیش فرض): شکاف از بین نمی رود. -
DISABLED
: شکاف فروپاشی نخواهد کرد ، خواه یک تبلیغ بازگردانده شود یا خیر. -
BEFORE_FETCH
: شکاف شروع به فروپاشی می کند و هنگام بازگشت یک تبلیغ گسترش می یابد. -
ON_NO_FILL
: شکاف شروع می شود و در صورت عدم بازگشت تبلیغ ، فروپاشی می شود.
- مثال
جاوا اسکریپت
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Collapse the div for this slot if no ad is returned. slot.setConfig({ collapseDiv: "ON_NO_FILL", }); // Collapse the div for this slot by default, and expand only // if an ad is returned. slot.setConfig({ collapseDiv: "BEFORE_FETCH", }); // Do not collapse the div for this slot. slot.setConfig({ collapseDiv: "DISABLED", }); // Clear the collapse setting. slot.setConfig({ collapseDiv: null, });
جاوا اسکریپت (میراث)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Collapse the div for this slot if no ad is returned. slot.setConfig({ collapseDiv: "ON_NO_FILL", }); // Collapse the div for this slot by default, and expand only // if an ad is returned. slot.setConfig({ collapseDiv: "BEFORE_FETCH", }); // Do not collapse the div for this slot. slot.setConfig({ collapseDiv: "DISABLED", }); // Clear the collapse setting. slot.setConfig({ collapseDiv: null, });
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); // Collapse the div for this slot if no ad is returned. slot.setConfig({ collapseDiv: "ON_NO_FILL", }); // Collapse the div for this slot by default, and expand only // if an ad is returned. slot.setConfig({ collapseDiv: "BEFORE_FETCH", }); // Do not collapse the div for this slot. slot.setConfig({ collapseDiv: "DISABLED", }); // Clear the collapse setting. slot.setConfig({ collapseDiv: null, });
- همچنین ببینید
مؤلفه Optional
componentAuction ?: ComponentAuctionConfig []
بینابینی Optional
interstitial ?: InterstitialConfig
- همچنین ببینید
SafeFrame Optional
safeFrame ?: SafeFrameConfig
مقادیر پیکربندی شده از طریق این تنظیم فقط برای شکاف AD اعمال می شود و مقادیر را که از طریق PagesEttingsConfig.SafeFrame تنظیم شده است ، نادیده می گیرند.
- مثال
جاوا اسکریپت
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Force SafeFrame for the slot. slot.setConfig({ safeFrame: { forceSafeFrame: true }, }); // Configure SafeFrame to allow overlay expansion for the slot. slot.setConfig({ safeFrame: { allowOverlayExpansion: true }, }); // Clear forceSafeFrame setting for the slot. slot.setConfig({ safeFrame: { forceSafeFrame: null }, }); // Clear all SafeFrame settings for the slot. slot.setConfig({ safeFrame: null });
جاوا اسکریپت (میراث)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Force SafeFrame for the slot. slot.setConfig({ safeFrame: { forceSafeFrame: true }, }); // Configure SafeFrame to allow overlay expansion for the slot. slot.setConfig({ safeFrame: { allowOverlayExpansion: true }, }); // Clear forceSafeFrame setting for the slot. slot.setConfig({ safeFrame: { forceSafeFrame: null }, }); // Clear all SafeFrame settings for the slot. slot.setConfig({ safeFrame: null });
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); // Force SafeFrame for the slot. slot.setConfig({ safeFrame: { forceSafeFrame: true }, }); // Configure SafeFrame to allow overlay expansion for the slot. slot.setConfig({ safeFrame: { allowOverlayExpansion: true }, }); // Clear forceSafeFrame setting for the slot. slot.setConfig({ safeFrame: { forceSafeFrame: null }, }); // Clear all SafeFrame settings for the slot. slot.setConfig({ safeFrame: null });
هدف گیری Optional
targeting ?: Record < string , string | string [] >
هدف قرار دادن پیکربندی شده از طریق این تنظیم فقط در شکاف AD اعمال می شود. این تنظیم ممکن است چندین بار نامیده شود تا چندین ارزش کلید هدفمند را تعریف کند ، یا مقادیر موجود را بازنویسی کند. کلیدهای هدفمند در حساب Google Ad Manager شما تعریف شده اند.
- مثال
جاوا اسکریپت
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Setting a single targeting key-value. slot.setConfig({ targeting: { interests: "sports" } }); // Setting multiple values for a single targeting key. slot.setConfig({ targeting: { interests: ["sports", "music"] } }); // Setting multiple targeting key-values at once. slot.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } }); // Clearing a single targeting key. slot.setConfig({ targeting: { interests: null } }); // Clear all targeting keys. slot.setConfig({ targeting: null });
جاوا اسکریپت (میراث)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Setting a single targeting key-value. slot.setConfig({ targeting: { interests: "sports" } }); // Setting multiple values for a single targeting key. slot.setConfig({ targeting: { interests: ["sports", "music"] } }); // Setting multiple targeting key-values at once. slot.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } }); // Clearing a single targeting key. slot.setConfig({ targeting: { interests: null } }); // Clear all targeting keys. slot.setConfig({ targeting: null });
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); // Setting a single targeting key-value. slot.setConfig({ targeting: { interests: "sports" } }); // Setting multiple values for a single targeting key. slot.setConfig({ targeting: { interests: ["sports", "music"] } }); // Setting multiple targeting key-values at once. slot.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } }); // Clearing a single targeting key. slot.setConfig({ targeting: { interests: null } }); // Clear all targeting keys. slot.setConfig({ targeting: null });
- همچنین ببینید
googletag.config.taxonomydata
خواص | |
---|---|
values | لیستی از ارزشهای طبقه بندی . |
خواص
ارزش ها
values : readonly string []
googletag.config.videoadsconfig
خواص | |
---|---|
enable Video Ads | آیا تبلیغات فیلم در صفحه حضور خواهد داشت. |
video Cms Id ? | شناسه منبع محتوای ویدیویی. |
video Content Id ? | شناسه محتوای ویدیویی. |
- همچنین ببینید
خواص
EnableVideoads
enableVideoAds : boolean
هنگامی که روی
true
تنظیم شده است ، این محدودیت های محرومیت محتوا را در تبلیغات نمایش و ویدیویی امکان پذیر می کند.اگر محتوای ویدیویی شناخته شده است ، VideoContentID و VideoCMSID را بر روی مقادیر ارائه شده به سرویس مصرف محتوای Google Ad Manager برای استفاده از محرومیت محتوا برای تبلیغات نمایش تنظیم کنید.
VideoCmsid Optional
videoCmsId ?: string
این یک مقدار منحصر به فرد است که توسط سرویس مصرف محتوای Google Ad Manager اختصاص داده شده است تا منبع محتوای ویدیویی مشخص شده توسط VideoContentID را شناسایی کند.
- همچنین ببینید
VideoContentid Optional
videoContentId ?: string
این یک مقدار منحصر به فرد است که یک فیلم خاص را از منبع محتوا مشخص شده توسط VideoCMSID مشخص می کند. این مقدار توسط CMS که میزبان محتوای ویدیویی شما است اختصاص داده شده است.
- همچنین ببینید
googletag.enums
شمارش ها | |
---|---|
Out Of Page Format | قالب های خارج از صفحه پشتیبانی شده توسط GPT. |
Traffic Source | منابع ترافیکی پشتیبانی شده توسط GPT. |
شمارش ها
پیش بینی
OutOfPageFormat
- همچنین ببینید
پیشخدمت
TrafficSource
- همچنین ببینید
اعضای شمارش | |
---|---|
ORGANIC | ورود مستقیم URL ، جستجوی سایت یا بارگیری برنامه. |
PURCHASED | ترافیک از خواص غیر از متعلق به (فعالیت خریداری شده یا در غیر این صورت تحریک شده) هدایت می شود. |
googletag.events
رابط ها | |
---|---|
Event | رابط پایه برای همه رویدادهای GPT. |
Event Type Map | این یک نوع شبه است که یک نام رویداد را به نوع شیء رویداد مربوطه برای Service.AddeventListener و Service.RemoveEventListener ترسیم می کند. |
Game Manual Interstitial Slot Closed Event | این رویداد هنگامی اخراج می شود که یک شکاف بینابینی دستی توسط کاربر بسته شده است. |
Game Manual Interstitial Slot Ready Event | This event is fired when a game manual interstitial slot is ready to be shown to the user. |
Impression Viewable Event | This event is fired when an impression becomes viewable, according to the Active View criteria . |
Rewarded Slot Closed Event | This event is fired when a rewarded ad slot is closed by the user. |
Rewarded Slot Granted Event | This event is fired when a reward is granted for viewing a rewarded ad . |
Rewarded Slot Ready Event | This event is fired when a rewarded ad is ready to be displayed. |
Slot Onload Event | This event is fired when the creative's iframe fires its load event. |
Slot Render Ended Event | This event is fired when the creative code is injected into a slot. |
Slot Requested Event | This event is fired when an ad has been requested for a particular slot. |
Slot Response Received | This event is fired when an ad response has been received for a particular slot. |
Slot Visibility Changed Event | This event is fired whenever the on-screen percentage of an ad slot's area changes. |
googletag.events.Event
خواص | |
---|---|
service Name | Name of the service that triggered the event. |
slot | The slot that triggered the event. |
- همچنین ببینید
خواص
serviceName
serviceName : string
شکاف
slot : Slot
googletag.events.EventTypeMap
خواص | |
---|---|
game Manual Interstitial Slot Closed | Alias for events.GameManualInterstitialSlotClosedEvent . |
game Manual Interstitial Slot Ready | Alias for events.GameManualInterstitialSlotReadyEvent . |
impression Viewable | Alias for events.ImpressionViewableEvent . |
rewarded Slot Closed | Alias for events.RewardedSlotClosedEvent . |
rewarded Slot Granted | Alias for events.RewardedSlotGrantedEvent . |
rewarded Slot Ready | Alias for events.RewardedSlotReadyEvent . |
slot Onload | Alias for events.SlotOnloadEvent . |
slot Render Ended | Alias for events.SlotRenderEndedEvent . |
slot Requested | Alias for events.SlotRequestedEvent . |
slot Response Received | Alias for events.SlotResponseReceived . |
slot Visibility Changed | Alias for events.SlotVisibilityChangedEvent . |
خواص
gameManualInterstitialSlotClosed
gameManualInterstitialSlotClosed : GameManualInterstitialSlotClosedEvent
gameManualInterstitialSlotReady
gameManualInterstitialSlotReady : GameManualInterstitialSlotReadyEvent
impressionViewable
impressionViewable : ImpressionViewableEvent
rewardedSlotClosed
rewardedSlotClosed : RewardedSlotClosedEvent
rewardedSlotGranted
rewardedSlotGranted : RewardedSlotGrantedEvent
rewardedSlotReady
rewardedSlotReady : RewardedSlotReadyEvent
slotOnload
slotOnload : SlotOnloadEvent
slotRenderEnded
slotRenderEnded : SlotRenderEndedEvent
slotRequested
slotRequested : SlotRequestedEvent
slotResponseReceived
slotResponseReceived : SlotResponseReceived
slotVisibilityChanged
slotVisibilityChanged : SlotVisibilityChangedEvent
googletag.events.GameManualInterstitialSlotClosedEvent
ExtendsNote: Game manual interstitial is a limited-access format.
خواص | |
---|---|
service Name | Name of the service that triggered the event. Inherited from |
slot | The slot that triggered the event. Inherited from |
- مثال
جاوا اسکریپت
// This listener is called when a game manual interstitial slot is closed. const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL, ); // Slot returns null if the page or device does not support game manual interstitial ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); googletag.pubads().addEventListener("gameManualInterstitialSlotClosed", (event) => { const slot = event.slot; console.log("Game manual interstital slot", slot.getSlotElementId(), "is closed."); if (slot === targetSlot) { // Slot specific logic. } }); }
JavaScript (legacy)
// This listener is called when a game manual interstitial slot is closed. var targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL, ); // Slot returns null if the page or device does not support game manual interstitial ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); googletag.pubads().addEventListener("gameManualInterstitialSlotClosed", function (event) { var slot = event.slot; console.log("Game manual interstital slot", slot.getSlotElementId(), "is closed."); if (slot === targetSlot) { // Slot specific logic. } }); }
TypeScript
// This listener is called when a game manual interstitial slot is closed. const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL, ); // Slot returns null if the page or device does not support game manual interstitial ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); googletag.pubads().addEventListener("gameManualInterstitialSlotClosed", (event) => { const slot = event.slot; console.log("Game manual interstital slot", slot.getSlotElementId(), "is closed."); if (slot === targetSlot) { // Slot specific logic. } }); }
- همچنین ببینید
googletag.events.GameManualInterstitialSlotReadyEvent
ExtendsNote: Game manual interstitial is a limited-access format.
خواص | |
---|---|
service Name | Name of the service that triggered the event. Inherited from |
slot | The slot that triggered the event. Inherited from |
روش ها | |
---|---|
make Game Manual Interstitial Visible | Displays the game manual interstitial ad to the user. |
- مثال
جاوا اسکریپت
// This listener is called when a game manual interstitial slot is ready to // be displayed. const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL, ); // Slot returns null if the page or device does not support game manual interstitial ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); googletag.pubads().addEventListener("gameManualInterstitialSlotReady", (event) => { const slot = event.slot; console.log( "Game manual interstital slot", slot.getSlotElementId(), "is ready to be displayed.", ); // Replace with custom logic. const displayGmiAd = true; if (displayGmiAd) { event.makeGameManualInterstitialVisible(); } if (slot === targetSlot) { // Slot specific logic. } }); }
JavaScript (legacy)
// This listener is called when a game manual interstitial slot is ready to // be displayed. var targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL, ); // Slot returns null if the page or device does not support game manual interstitial ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); googletag.pubads().addEventListener("gameManualInterstitialSlotReady", function (event) { var slot = event.slot; console.log( "Game manual interstital slot", slot.getSlotElementId(), "is ready to be displayed.", ); // Replace with custom logic. var displayGmiAd = true; if (displayGmiAd) { event.makeGameManualInterstitialVisible(); } if (slot === targetSlot) { // Slot specific logic. } }); }
TypeScript
// This listener is called when a game manual interstitial slot is ready to // be displayed. const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL, ); // Slot returns null if the page or device does not support game manual interstitial ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); googletag.pubads().addEventListener("gameManualInterstitialSlotReady", (event) => { const slot = event.slot; console.log( "Game manual interstital slot", slot.getSlotElementId(), "is ready to be displayed.", ); // Replace with custom logic. const displayGmiAd = true; if (displayGmiAd) { event.makeGameManualInterstitialVisible(); } if (slot === targetSlot) { // Slot specific logic. } }); }
- همچنین ببینید
روش ها
makeGameManualInterstitialVisible
makeGameManualInterstitialVisible ( ) : void
googletag.events.ImpressionViewableEvent
Extendsخواص | |
---|---|
service Name | Name of the service that triggered the event. Inherited from |
slot | The slot that triggered the event. Inherited from |
- مثال
جاوا اسکریپت
// This listener is called when an impression becomes viewable. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("impressionViewable", (event) => { const slot = event.slot; console.log("Impression for slot", slot.getSlotElementId(), "became viewable."); if (slot === targetSlot) { // Slot specific logic. } });
JavaScript (legacy)
// This listener is called when an impression becomes viewable. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("impressionViewable", function (event) { var slot = event.slot; console.log("Impression for slot", slot.getSlotElementId(), "became viewable."); if (slot === targetSlot) { // Slot specific logic. } });
TypeScript
// This listener is called when an impression becomes viewable. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("impressionViewable", (event) => { const slot = event.slot; console.log("Impression for slot", slot.getSlotElementId(), "became viewable."); if (slot === targetSlot) { // Slot specific logic. } });
- همچنین ببینید
googletag.events.RewardedSlotClosedEvent
Extendsخواص | |
---|---|
service Name | Name of the service that triggered the event. Inherited from |
slot | The slot that triggered the event. Inherited from |
- مثال
جاوا اسکریپت
const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called when the user closes a rewarded ad slot. googletag.pubads().addEventListener("rewardedSlotClosed", (event) => { const slot = event.slot; console.log("Rewarded ad slot", slot.getSlotElementId(), "has been closed."); if (slot === targetSlot) { // Slot specific logic. } }); }
JavaScript (legacy)
var targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called when the user closes a rewarded ad slot. googletag.pubads().addEventListener("rewardedSlotClosed", function (event) { var slot = event.slot; console.log("Rewarded ad slot", slot.getSlotElementId(), "has been closed."); if (slot === targetSlot) { // Slot specific logic. } }); }
TypeScript
const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called when the user closes a rewarded ad slot. googletag.pubads().addEventListener("rewardedSlotClosed", (event) => { const slot = event.slot; console.log("Rewarded ad slot", slot.getSlotElementId(), "has been closed."); if (slot === targetSlot) { // Slot specific logic. } }); }
- همچنین ببینید
googletag.events.RewardedSlotGrantedEvent
Extendsخواص | |
---|---|
payload | An object containing information about the reward that was granted. |
service Name | Name of the service that triggered the event. Inherited from |
slot | The slot that triggered the event. Inherited from |
- مثال
جاوا اسکریپت
const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called whenever a reward is granted for a // rewarded ad. googletag.pubads().addEventListener("rewardedSlotGranted", (event) => { const slot = event.slot; console.group("Reward granted for slot", slot.getSlotElementId(), "."); // Log details of the reward. console.log("Reward type:", event.payload?.type); console.log("Reward amount:", event.payload?.amount); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } }); }
JavaScript (legacy)
var targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called whenever a reward is granted for a // rewarded ad. googletag.pubads().addEventListener("rewardedSlotGranted", function (event) { var _a, _b; var slot = event.slot; console.group("Reward granted for slot", slot.getSlotElementId(), "."); // Log details of the reward. console.log("Reward type:", (_a = event.payload) === null || _a === void 0 ? void 0 : _a.type); console.log( "Reward amount:", (_b = event.payload) === null || _b === void 0 ? void 0 : _b.amount, ); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } }); }
TypeScript
const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called whenever a reward is granted for a // rewarded ad. googletag.pubads().addEventListener("rewardedSlotGranted", (event) => { const slot = event.slot; console.group("Reward granted for slot", slot.getSlotElementId(), "."); // Log details of the reward. console.log("Reward type:", event.payload?.type); console.log("Reward amount:", event.payload?.amount); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } }); }
- همچنین ببینید
خواص
محموله
payload : RewardedPayload
googletag.events.RewardedSlotReadyEvent
Extendsخواص | |
---|---|
service Name | Name of the service that triggered the event. Inherited from |
slot | The slot that triggered the event. Inherited from |
روش ها | |
---|---|
make Rewarded Visible | Displays the rewarded ad. |
- مثال
جاوا اسکریپت
// This listener is called when a rewarded ad slot becomes ready to be // displayed. const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called whenever a reward is granted for a // rewarded ad. googletag.pubads().addEventListener("rewardedSlotReady", (event) => { const slot = event.slot; console.log("Rewarded ad slot", slot.getSlotElementId(), "is ready to be displayed."); // Replace with custom logic. const userHasConsented = true; if (userHasConsented) { event.makeRewardedVisible(); } if (slot === targetSlot) { // Slot specific logic. } }); }
JavaScript (legacy)
// This listener is called when a rewarded ad slot becomes ready to be // displayed. var targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called whenever a reward is granted for a // rewarded ad. googletag.pubads().addEventListener("rewardedSlotReady", function (event) { var slot = event.slot; console.log("Rewarded ad slot", slot.getSlotElementId(), "is ready to be displayed."); // Replace with custom logic. var userHasConsented = true; if (userHasConsented) { event.makeRewardedVisible(); } if (slot === targetSlot) { // Slot specific logic. } }); }
TypeScript
// This listener is called when a rewarded ad slot becomes ready to be // displayed. const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called whenever a reward is granted for a // rewarded ad. googletag.pubads().addEventListener("rewardedSlotReady", (event) => { const slot = event.slot; console.log("Rewarded ad slot", slot.getSlotElementId(), "is ready to be displayed."); // Replace with custom logic. const userHasConsented = true; if (userHasConsented) { event.makeRewardedVisible(); } if (slot === targetSlot) { // Slot specific logic. } }); }
- همچنین ببینید
روش ها
makeRewardedVisible
makeRewardedVisible ( ) : void
googletag.events.SlotOnloadEvent
ExtendsSlotOnloadEvent
will be fired. خواص | |
---|---|
service Name | Name of the service that triggered the event. Inherited from |
slot | The slot that triggered the event. Inherited from |
- مثال
جاوا اسکریپت
// This listener is called when a creative iframe load event fires. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotOnload", (event) => { const slot = event.slot; console.log("Creative iframe for slot", slot.getSlotElementId(), "has loaded."); if (slot === targetSlot) { // Slot specific logic. } });
JavaScript (legacy)
// This listener is called when a creative iframe load event fires. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotOnload", function (event) { var slot = event.slot; console.log("Creative iframe for slot", slot.getSlotElementId(), "has loaded."); if (slot === targetSlot) { // Slot specific logic. } });
TypeScript
// This listener is called when a creative iframe load event fires. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotOnload", (event) => { const slot = event.slot; console.log("Creative iframe for slot", slot.getSlotElementId(), "has loaded."); if (slot === targetSlot) { // Slot specific logic. } });
- همچنین ببینید
googletag.events.SlotRenderEndedEvent
Extendsخواص | |
---|---|
advertiser Id | Advertiser ID of the rendered ad. |
campaign Id | Campaign ID of the rendered ad. |
company Ids | IDs of the companies that bid on the rendered backfill ad. |
creative Id | Creative ID of the rendered reservation ad. |
creative Template Id | Creative template ID of the rendered reservation ad. |
is Backfill | Whether an ad was a backfill ad. |
is Empty | Whether an ad was returned for the slot. |
label Ids | منسوخ شده است. |
line Item Id | Line item ID of the rendered reservation ad. |
response Identifier | The response identifier is a unique identifier for the ad response. |
service Name | Name of the service that triggered the event. Inherited from |
size | Indicates the pixel size of the rendered creative. |
slot | The slot that triggered the event. Inherited from |
slot Content Changed | Whether the slot content was changed with the rendered ad. |
source Agnostic Creative Id | Creative ID of the rendered reservation or backfill ad. |
source Agnostic Line Item Id | Line item ID of the rendered reservation or backfill ad. |
yield Group Ids | IDs of the yield groups for the rendered backfill ad. |
- مثال
جاوا اسکریپت
// This listener is called when a slot has finished rendering. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotRenderEnded", (event) => { const slot = event.slot; console.group("Slot", slot.getSlotElementId(), "finished rendering."); // Log details of the rendered ad. console.log("Advertiser ID:", event.advertiserId); console.log("Campaign ID:", event.campaignId); console.log("Company IDs:", event.companyIds); console.log("Creative ID:", event.creativeId); console.log("Creative Template ID:", event.creativeTemplateId); console.log("Is backfill?:", event.isBackfill); console.log("Is empty?:", event.isEmpty); console.log("Line Item ID:", event.lineItemId); console.log("Size:", event.size); console.log("Slot content changed?", event.slotContentChanged); console.log("Source Agnostic Creative ID:", event.sourceAgnosticCreativeId); console.log("Source Agnostic Line Item ID:", event.sourceAgnosticLineItemId); console.log("Yield Group IDs:", event.yieldGroupIds); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } });
JavaScript (legacy)
// This listener is called when a slot has finished rendering. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotRenderEnded", function (event) { var slot = event.slot; console.group("Slot", slot.getSlotElementId(), "finished rendering."); // Log details of the rendered ad. console.log("Advertiser ID:", event.advertiserId); console.log("Campaign ID:", event.campaignId); console.log("Company IDs:", event.companyIds); console.log("Creative ID:", event.creativeId); console.log("Creative Template ID:", event.creativeTemplateId); console.log("Is backfill?:", event.isBackfill); console.log("Is empty?:", event.isEmpty); console.log("Line Item ID:", event.lineItemId); console.log("Size:", event.size); console.log("Slot content changed?", event.slotContentChanged); console.log("Source Agnostic Creative ID:", event.sourceAgnosticCreativeId); console.log("Source Agnostic Line Item ID:", event.sourceAgnosticLineItemId); console.log("Yield Group IDs:", event.yieldGroupIds); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } });
TypeScript
// This listener is called when a slot has finished rendering. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotRenderEnded", (event) => { const slot = event.slot; console.group("Slot", slot.getSlotElementId(), "finished rendering."); // Log details of the rendered ad. console.log("Advertiser ID:", event.advertiserId); console.log("Campaign ID:", event.campaignId); console.log("Company IDs:", event.companyIds); console.log("Creative ID:", event.creativeId); console.log("Creative Template ID:", event.creativeTemplateId); console.log("Is backfill?:", event.isBackfill); console.log("Is empty?:", event.isEmpty); console.log("Line Item ID:", event.lineItemId); console.log("Size:", event.size); console.log("Slot content changed?", event.slotContentChanged); console.log("Source Agnostic Creative ID:", event.sourceAgnosticCreativeId); console.log("Source Agnostic Line Item ID:", event.sourceAgnosticLineItemId); console.log("Yield Group IDs:", event.yieldGroupIds); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } });
- همچنین ببینید
خواص
advertiserId
advertiserId : number
null
for empty slots, backfill ads, and creatives rendered by services other than PubAdsService . شناسه کمپین
campaignId : number
null
for empty slots, backfill ads, and creatives rendered by services other than PubAdsService . companyIds
companyIds : number []
null
for empty slots, reservation ads, and creatives rendered by services other than PubAdsService . creativeId
creativeId : number
null
for empty slots, backfill ads, and creatives rendered by services other than PubAdsService . creativeTemplateId
creativeTemplateId : number
null
for empty slots, backfill ads, and creatives rendered by services other than PubAdsService . isBackfill
isBackfill : boolean
true
if the ad was a backfill ad, false
otherwise. خالی است
isEmpty : boolean
true
if no ad was returned, false
otherwise. labelIds
labelIds : number []
lineItemId
lineItemId : number
null
for empty slots, backfill ads, and creatives rendered by services other than PubAdsService . responseIdentifier
responseIdentifier : string
اندازه
size : string | number []
[728, 90]
. Value is null
for empty ad slots. slotContentChanged
slotContentChanged : boolean
true
if the content was changed, false
otherwise. sourceAgnosticCreativeId
sourceAgnosticCreativeId : number
null
if the ad is not a reservation or line item backfill, or the creative is rendered by services other than PubAdsService . sourceAgnosticLineItemId
sourceAgnosticLineItemId : number
null
if the ad is not a reservation or line item backfill, or the creative is rendered by services other than PubAdsService . yieldGroupIds
yieldGroupIds : number []
null
for empty slots, reservation ads, and creatives rendered by services other than PubAdsService . googletag.events.SlotRequestedEvent
Extendsخواص | |
---|---|
service Name | Name of the service that triggered the event. Inherited from |
slot | The slot that triggered the event. Inherited from |
- مثال
جاوا اسکریپت
// This listener is called when the specified service issues an ad // request for a slot. Each slot will fire this event, even though they // may be batched together in a single request if single request // architecture (SRA) is enabled. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotRequested", (event) => { const slot = event.slot; console.log("Slot", slot.getSlotElementId(), "has been requested."); if (slot === targetSlot) { // Slot specific logic. } });
JavaScript (legacy)
// This listener is called when the specified service issues an ad // request for a slot. Each slot will fire this event, even though they // may be batched together in a single request if single request // architecture (SRA) is enabled. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotRequested", function (event) { var slot = event.slot; console.log("Slot", slot.getSlotElementId(), "has been requested."); if (slot === targetSlot) { // Slot specific logic. } });
TypeScript
// This listener is called when the specified service issues an ad // request for a slot. Each slot will fire this event, even though they // may be batched together in a single request if single request // architecture (SRA) is enabled. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotRequested", (event) => { const slot = event.slot; console.log("Slot", slot.getSlotElementId(), "has been requested."); if (slot === targetSlot) { // Slot specific logic. } });
- همچنین ببینید
googletag.events.SlotResponseReceived
Extendsخواص | |
---|---|
service Name | Name of the service that triggered the event. Inherited from |
slot | The slot that triggered the event. Inherited from |
- مثال
جاوا اسکریپت
// This listener is called when an ad response has been received // for a slot. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotResponseReceived", (event) => { const slot = event.slot; console.log("Ad response for slot", slot.getSlotElementId(), "received."); if (slot === targetSlot) { // Slot specific logic. } });
JavaScript (legacy)
// This listener is called when an ad response has been received // for a slot. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotResponseReceived", function (event) { var slot = event.slot; console.log("Ad response for slot", slot.getSlotElementId(), "received."); if (slot === targetSlot) { // Slot specific logic. } });
TypeScript
// This listener is called when an ad response has been received // for a slot. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotResponseReceived", (event) => { const slot = event.slot; console.log("Ad response for slot", slot.getSlotElementId(), "received."); if (slot === targetSlot) { // Slot specific logic. } });
- همچنین ببینید
googletag.events.SlotVisibilityChangedEvent
Extendsخواص | |
---|---|
in View Percentage | The percentage of the ad's area that is visible. |
service Name | Name of the service that triggered the event. Inherited from |
slot | The slot that triggered the event. Inherited from |
- مثال
جاوا اسکریپت
// This listener is called whenever the on-screen percentage of an // ad slot's area changes. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotVisibilityChanged", (event) => { const slot = event.slot; console.group("Visibility of slot", slot.getSlotElementId(), "changed."); // Log details of the event. console.log("Visible area:", `${event.inViewPercentage}%`); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } });
JavaScript (legacy)
// This listener is called whenever the on-screen percentage of an // ad slot's area changes. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotVisibilityChanged", function (event) { var slot = event.slot; console.group("Visibility of slot", slot.getSlotElementId(), "changed."); // Log details of the event. console.log("Visible area:", "".concat(event.inViewPercentage, "%")); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } });
TypeScript
// This listener is called whenever the on-screen percentage of an // ad slot's area changes. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotVisibilityChanged", (event) => { const slot = event.slot; console.group("Visibility of slot", slot.getSlotElementId(), "changed."); // Log details of the event. console.log("Visible area:", `${event.inViewPercentage}%`); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } });
- همچنین ببینید
خواص
inViewPercentage
inViewPercentage : number
googletag.secureSignals
رابط ها | |
---|---|
Bidder Signal Provider | Returns a secure signal for a specific bidder. |
Publisher Signal Provider | Returns a secure signal for a specific publisher. |
Secure Signal Providers Array | An interface for managing secure signals. |
Type Aliases | |
---|---|
Secure Signal Provider | Interface for returning a secure signal for a specific bidder or provider. |
Type Aliases
SecureSignalProvider
SecureSignalProvider : BidderSignalProvider | PublisherSignalProvider
id
or networkCode
must be provided, but not both. googletag.secureSignals.BidderSignalProvider
A bidder secure signal provider consists of 2 parts:
- A collector function, which returns a
Promise
that resolves to a secure signal. - An
id
which identifies the bidder associated with the signal.
خواص | |
---|---|
collector Function | A function which returns a Promise that resolves to a secure signal. |
id | A unique identifier for the collector associated with this secure signal, as registered in Google Ad Manager. |
- مثال
جاوا اسکریپت
// id is provided googletag.secureSignalProviders.push({ id: "collector123", collectorFunction: () => { // ...custom signal generation logic... return Promise.resolve("signal"); }, });
JavaScript (legacy)
// id is provided googletag.secureSignalProviders.push({ id: "collector123", collectorFunction: function () { // ...custom signal generation logic... return Promise.resolve("signal"); }, });
TypeScript
// id is provided googletag.secureSignalProviders!.push({ id: "collector123", collectorFunction: () => { // ...custom signal generation logic... return Promise.resolve("signal"); }, });
- همچنین ببینید
خواص
collectorFunction
collectorFunction : ( ( ) => Promise < string > )
Promise
that resolves to a secure signal. شناسه
id : string
googletag.secureSignals.PublisherSignalProvider
A publisher signal provider consists of 2 parts:
- A collector function, which returns a
Promise
that resolves to a secure signal. - A
networkCode
which identifies the publisher associated with the signal.
خواص | |
---|---|
collector Function | A function which returns a Promise that resolves to a secure signal. |
network Code | The network code (as seen in the ad unit path) for the publisher associated with this secure signal. |
- مثال
جاوا اسکریپت
// networkCode is provided googletag.secureSignalProviders.push({ networkCode: "123456", collectorFunction: () => { // ...custom signal generation logic... return Promise.resolve("signal"); }, });
JavaScript (legacy)
// networkCode is provided googletag.secureSignalProviders.push({ networkCode: "123456", collectorFunction: function () { // ...custom signal generation logic... return Promise.resolve("signal"); }, });
TypeScript
// networkCode is provided googletag.secureSignalProviders!.push({ networkCode: "123456", collectorFunction: () => { // ...custom signal generation logic... return Promise.resolve("signal"); }, });
- همچنین ببینید
خواص
collectorFunction
collectorFunction : ( ( ) => Promise < string > )
Promise
that resolves to a secure signal. networkCode
networkCode : string
googletag.secureSignals.SecureSignalProvidersArray
روش ها | |
---|---|
clear All Cache | Clears all signals for all collectors from cache. |
push | Adds a new secureSignals.SecureSignalProvider to the signal provider array and begins the signal generation process. |
روش ها
clearAllCache
clearAllCache ( ) : void
Calling this method may reduce the likelihood of signals being included in ad requests for the current and potentially later page views. Due to this, it should only be called when meaningful state changes occur, such as events that indicate a new user (log in, log out, sign up, etc.).
فشار دهید
push ( provider : SecureSignalProvider ) : void
پارامترها | |
---|---|
provider : SecureSignalProvider | The secureSignals.SecureSignalProvider object to be added to the array. |
This reference uses TypeScript notation to describe types. The following table provides a brief explanation by example.
Type expression | |
---|---|
string | The primitive string type. |
string[] | An array type, where values may only be strings. |
number | string | A union type, where the value may be either a number or a string. |
Array<number | string> | An array type, where values are a complex (union) type. |
[number, string] | A tuple type, where the value is a two-element array that must contain a number and a string in that order. |
Slot | An object type, where the value is an instance of googletag.Slot . |
() => void | A function type with no defined arguments and no return value. |
To learn more about supported types and type expressions, refer to the TypeScript Handbook .
Type annotations
A colon after a variable, parameter name, property name, or function signature denotes a type annotation. Type annotations describe the types the element to the left of the colon can accept or return. The following table shows examples of type annotations you may see in this reference.
Type annotation | |
---|---|
param: string | Indicates that param accepts or returns a string value. This syntax is used for variables, parameters, properties, and return types. |
param?: number | string | Indicates that param is optional, but accepts either a number or a string when specified. This syntax is used for parameters and properties. |
...params: Array<() => void> | Indicates that params is a rest parameter that accepts functions. Rest parameters accept an unbounded number of values of the specified type. |
googletag
فضاهای نام | |
---|---|
config | Main configuration interface for page-level settings. |
enums | This is the namespace that GPT uses for enum types. |
events | This is the namespace that GPT uses for Events. |
secure Signals | This is the namespace that GPT uses for managing secure signals. |
رابط ها | |
---|---|
Command Array | The command array accepts a sequence of functions and invokes them in order. |
Companion Ads Service | Companion Ads service. |
Privacy Settings Config | Configuration object for privacy settings. |
Pub Ads Service | Publisher Ads service. |
Response Information | An object representing a single ad response. |
Rewarded Payload | An object representing the reward associated with a rewarded ad . |
Service | Base service class that contains methods common for all services. |
Size Mapping Builder | Builder for size mapping specification objects. |
Slot | Slot is an object representing a single ad slot on a page. |
Type Aliases | |
---|---|
General Size | A valid size configuration for a slot, which can be one or multiple sizes. |
Multi Size | A list of single valid sizes. |
Named Size | Named sizes that a slot can have. |
Single Size | A single valid size for a slot. |
Single Size Array | Array of two numbers representing [width, height]. |
Size Mapping | A mapping of viewport size to ad sizes. |
Size Mapping Array | A list of size mappings. |
متغیرها | |
---|---|
api Ready | Flag indicating that the GPT API is loaded and ready to be called. |
cmd | Reference to the global command queue for asynchronous execution of GPT-related calls. |
pubads Ready | Flag indicating that PubAdsService is enabled, loaded and fully operational. |
secure Signal Providers | Reference to the secure signal providers array. |
توابع | |
---|---|
companion Ads | Returns a reference to the CompanionAdsService . |
define Out Of Page Slot | Constructs an out-of-page ad slot with the given ad unit path. |
define Slot | Constructs an ad slot with a given ad unit path and size and associates it with the ID of a div element on the page that will contain the ad. |
destroy Slots | Destroys the given slots, removing all related objects and references of those slots from GPT. |
disable Publisher Console | Disables the Google Publisher Console. |
display | Instructs slot services to render the slot. |
enable Services | Enables all GPT services that have been defined for ad slots on the page. |
get Config | Gets general configuration options for the page set by setConfig . |
get Version | Returns the current version of GPT. |
open Console | Opens the Google Publisher Console. |
pubads | Returns a reference to the PubAdsService . |
set Ad Iframe Title | Sets the title for all ad container iframes created by PubAdsService , from this point onwards. |
set Config | Sets general configuration options for the page. |
size Mapping | Creates a new SizeMappingBuilder . |
Type Aliases
GeneralSize
GeneralSize : SingleSize | MultiSize
MultiSize
MultiSize : SingleSize []
NamedSize
NamedSize : "fluid" | [ "fluid" ]
- fluid : the ad container takes 100% width of parent div and then resizes its height to fit creative content. Similar to how regular block elements on a page behave. Used for native ads (see related article ). Note that both
fluid
and['fluid']
are acceptable forms to declare a slot size as fluid.
SingleSize
SingleSize : SingleSizeArray | NamedSize
SingleSizeArray
SingleSizeArray : [ number , number ]
SizeMapping
SizeMapping : [ SingleSizeArray , GeneralSize ]
SizeMappingArray
SizeMappingArray : SizeMapping []
متغیرها
Const
apiReady
apiReady : boolean | undefined
undefined
until the API is ready.Note that the recommended way of handling async is to use googletag.cmd to queue callbacks for when GPT is ready. These callbacks do not have to check googletag.apiReady as they are guaranteed to execute once the API is set up.
Const
cmd
cmd : ( ( this : typeof globalThis ) => void ) [] | CommandArray
The
googletag.cmd
variable is initialized to an empty JavaScript array by the GPT tag syntax on the page, and cmd.push
is the standard Array.push
method that adds an element to the end of the array. When the GPT JavaScript is loaded, it looks through the array and executes all the functions in order. The script then replaces cmd
with a CommandArray object whose push method is defined to execute the function argument passed to it. This mechanism allows GPT to reduce perceived latency by fetching the JavaScript asynchronously while allowing the browser to continue rendering the page.- مثال
جاوا اسکریپت
googletag.cmd.push(() => { googletag.defineSlot("/1234567/sports", [160, 600]).addService(googletag.pubads()); });
JavaScript (legacy)
googletag.cmd.push(function () { googletag.defineSlot("/1234567/sports", [160, 600]).addService(googletag.pubads()); });
TypeScript
googletag.cmd.push(() => { googletag.defineSlot("/1234567/sports", [160, 600])!.addService(googletag.pubads()); });
Const
pubadsReady
pubadsReady : boolean | undefined
undefined
until enableServices is called and PubAdsService is loaded and initialized. secureSignalProviders
secureSignalProviders : SecureSignalProvider [] | SecureSignalProvidersArray | undefined
The secure signal providers array accepts a sequence of signal-generating functions and invokes them in order. It is intended to replace a standard array that is used to enqueue signal-generating functions to be invoked once GPT is loaded.
- مثال
جاوا اسکریپت
window.googletag = window.googletag || { cmd: [] }; googletag.secureSignalProviders = googletag.secureSignalProviders || []; googletag.secureSignalProviders.push({ id: "collector123", collectorFunction: () => { return Promise.resolve("signal"); }, });
JavaScript (legacy)
window.googletag = window.googletag || { cmd: [] }; googletag.secureSignalProviders = googletag.secureSignalProviders || []; googletag.secureSignalProviders.push({ id: "collector123", collectorFunction: function () { return Promise.resolve("signal"); }, });
TypeScript
window.googletag = window.googletag || { cmd: [] }; googletag.secureSignalProviders = googletag.secureSignalProviders || []; googletag.secureSignalProviders.push({ id: "collector123", collectorFunction: () => { return Promise.resolve("signal"); }, });
- همچنین ببینید
توابع
companionAds
companionAds ( ) : CompanionAdsService
برمی گرداند | |
---|---|
CompanionAdsService | The Companion Ads service. |
defineOutOfPageSlot
defineOutOfPageSlot ( adUnitPath : string , div ?: string | OutOfPageFormat ) : Slot | null
For custom out-of-page ads,
div
is the ID of the div element that will contain the ad. See the article on out-of-page creatives for more details.For GPT managed out-of-page ads,
div
is a supported OutOfPageFormat .- مثال
جاوا اسکریپت
// Define a custom out-of-page ad slot. googletag.defineOutOfPageSlot("/1234567/sports", "div-1"); // Define a GPT managed web interstitial ad slot. googletag.defineOutOfPageSlot("/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL);
JavaScript (legacy)
// Define a custom out-of-page ad slot. googletag.defineOutOfPageSlot("/1234567/sports", "div-1"); // Define a GPT managed web interstitial ad slot. googletag.defineOutOfPageSlot("/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL);
TypeScript
// Define a custom out-of-page ad slot. googletag.defineOutOfPageSlot("/1234567/sports", "div-1"); // Define a GPT managed web interstitial ad slot. googletag.defineOutOfPageSlot("/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL);
- همچنین ببینید
پارامترها | |
---|---|
adUnitPath : string | Full ad unit path with the network code and ad unit code. |
| ID of the div that will contain this ad unit or OutOfPageFormat. |
برمی گرداند | |
---|---|
Slot | null | The newly created slot, or null if a slot cannot be created. |
defineSlot
defineSlot ( adUnitPath : string , size : GeneralSize , div ?: string ) : Slot | null
- مثال
جاوا اسکریپت
googletag.defineSlot("/1234567/sports", [728, 90], "div-1");
JavaScript (legacy)
googletag.defineSlot("/1234567/sports", [728, 90], "div-1");
TypeScript
googletag.defineSlot("/1234567/sports", [728, 90], "div-1");
- همچنین ببینید
پارامترها | |
---|---|
adUnitPath : string | Full ad unit path with the network code and unit code. |
size : GeneralSize | Width and height of the added slot. This is the size that is used in the ad request if no responsive size mapping is provided or the size of the viewport is smaller than the smallest size provided in the mapping. |
| ID of the div that will contain this ad unit. |
برمی گرداند | |
---|---|
Slot | null | The newly created slot, or null if a slot cannot be created. |
destroySlots
destroySlots ( slots ?: Slot [] ) : boolean
Calling this API on a slot clears the ad and removes the slot object from the internal state maintained by GPT. Calling any more functions on the slot object will result in undefined behavior. Note the browser may still not free the memory associated with that slot if a reference to it is maintained by the publisher page. Calling this API makes the div associated with that slot available for reuse.
In particular, destroying a slot removes the ad from GPT's long-lived pageview , so future requests will not be influenced by roadblocks or competitive exclusions involving this ad. Failure to call this function before removing a slot's div from the page will result in undefined behavior.
- مثال
جاوا اسکریپت
// The calls to construct an ad and display contents. const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1"); googletag.display("div-1"); const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2"); googletag.display("div-2"); // This call to destroy only slot1. googletag.destroySlots([slot1]); // This call to destroy both slot1 and slot2. googletag.destroySlots([slot1, slot2]); // This call to destroy all slots. googletag.destroySlots();
JavaScript (legacy)
// The calls to construct an ad and display contents. var slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1"); googletag.display("div-1"); var slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2"); googletag.display("div-2"); // This call to destroy only slot1. googletag.destroySlots([slot1]); // This call to destroy both slot1 and slot2. googletag.destroySlots([slot1, slot2]); // This call to destroy all slots. googletag.destroySlots();
TypeScript
// The calls to construct an ad and display contents. const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1")!; googletag.display("div-1"); const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2")!; googletag.display("div-2"); // This call to destroy only slot1. googletag.destroySlots([slot1]); // This call to destroy both slot1 and slot2. googletag.destroySlots([slot1, slot2]); // This call to destroy all slots. googletag.destroySlots();
پارامترها | |
---|---|
| The array of slots to destroy. Array is optional; all slots will be destroyed if it is unspecified. |
برمی گرداند | |
---|---|
boolean | true if slots have been destroyed, false otherwise. |
disablePublisherConsole
disablePublisherConsole ( ) : void
- همچنین ببینید
نمایش داده شود
display ( divOrSlot : string | Element | Slot ) : void
If single request architecture (SRA) is being used, all unfetched ad slots at the time this method is called will be fetched at once. To force an ad slot not to display, the entire div must be removed.
- همچنین ببینید
پارامترها | |
---|---|
divOrSlot : string | Element | Slot | Either the ID of the div element containing the ad slot or the div element, or the slot object. If a div element is provided, it must have an 'id' attribute which matches the ID passed into defineSlot . |
enableServices
enableServices ( ) : void
getConfig
getConfig ( keys : string | string [] ) : Pick < PageSettingsConfig , "adsenseAttributes" | "disableInitialLoad" | "targeting" >
Not all
setConfig()
properties are supported by this method. Supported properties are:- مثال
جاوا اسکریپت
// Get the value of the `targeting` setting. const targetingConfig = googletag.getConfig("targeting"); // Get the value of the `adsenseAttributes` and `disableInitialLoad` settings. const config = googletag.getConfig(["adsenseAttributes", "disableInitialLoad"]);
JavaScript (legacy)
// Get the value of the `targeting` setting. var targetingConfig = googletag.getConfig("targeting"); // Get the value of the `adsenseAttributes` and `disableInitialLoad` settings. var config = googletag.getConfig(["adsenseAttributes", "disableInitialLoad"]);
TypeScript
// Get the value of the `targeting` setting. const targetingConfig = googletag.getConfig("targeting"); // Get the value of the `adsenseAttributes` and `disableInitialLoad` settings. const config = googletag.getConfig(["adsenseAttributes", "disableInitialLoad"]);
پارامترها | |
---|---|
keys : string | string [] | The keys of the configuration options to get. |
برمی گرداند | |
---|---|
Pick < PageSettingsConfig , "adsenseAttributes" | "disableInitialLoad" | "targeting" > | The configuration options for the slot. |
getVersion
getVersion ( ) : string
- همچنین ببینید
برمی گرداند | |
---|---|
string | The currently executing GPT version string. |
openConsole
openConsole ( div ?: string ) : void
- مثال
جاوا اسکریپت
// Calling with div ID. googletag.openConsole("div-1"); // Calling without div ID. googletag.openConsole();
JavaScript (legacy)
// Calling with div ID. googletag.openConsole("div-1"); // Calling without div ID. googletag.openConsole();
TypeScript
// Calling with div ID. googletag.openConsole("div-1"); // Calling without div ID. googletag.openConsole();
- همچنین ببینید
پارامترها | |
---|---|
| An ad slot div ID. This value is optional. When provided, the Publisher Console will attempt to open with details of the specified ad slot in view. |
pubads
pubads ( ) : PubAdsService
برمی گرداند | |
---|---|
PubAdsService | The Publisher Ads service. |
setAdIframeTitle
setAdIframeTitle ( title : string ) : void
- مثال
جاوا اسکریپت
googletag.setAdIframeTitle("title");
JavaScript (legacy)
googletag.setAdIframeTitle("title");
TypeScript
googletag.setAdIframeTitle("title");
پارامترها | |
---|---|
title : string | The new title for all ad container iframes. |
setConfig
setConfig ( config : PageSettingsConfig ) : void
پارامترها | |
---|---|
config : PageSettingsConfig |
sizeMapping
sizeMapping ( ) : SizeMappingBuilder
googletag.CommandArray
روش ها | |
---|---|
push | Executes the sequence of functions specified in the arguments in order. |
روش ها
فشار دهید
push ( ... f : ( ( this : typeof globalThis ) => void ) [] ) : number
- مثال
جاوا اسکریپت
googletag.cmd.push(() => { googletag.defineSlot("/1234567/sports", [160, 600]).addService(googletag.pubads()); });
JavaScript (legacy)
googletag.cmd.push(function () { googletag.defineSlot("/1234567/sports", [160, 600]).addService(googletag.pubads()); });
TypeScript
googletag.cmd.push(() => { googletag.defineSlot("/1234567/sports", [160, 600])!.addService(googletag.pubads()); });
پارامترها | |
---|---|
| A JavaScript function to be executed. The runtime binding will always be globalThis . Consider passing an arrow function to retain the this value of the enclosing lexical context. |
برمی گرداند | |
---|---|
number | The number of commands processed so far. This is compatible with Array.push 's return value (the current length of the array). |
googletag.CompanionAdsService
Extendsروش ها | |
---|---|
add Event Listener | Registers a listener that allows you to set up and call a JavaScript function when a specific GPT event happens on the page. Inherited from |
get Slots | Get the list of slots associated with this service. Inherited from |
remove Event Listener | Removes a previously registered listener. Inherited from |
set Refresh Unfilled Slots | Sets whether companion slots that have not been filled will be automatically backfilled. |
- همچنین ببینید
روش ها
setRefreshUnfilledSlots
setRefreshUnfilledSlots ( value : boolean ) : void
This method can be called multiple times during the page's lifetime to turn backfill on and off. Only slots that are also registered with the PubAdsService will be backfilled. Due to policy restrictions, this method is not designed to fill empty companion slots when an Ad Exchange video is served.
- مثال
جاوا اسکریپت
googletag.companionAds().setRefreshUnfilledSlots(true);
JavaScript (legacy)
googletag.companionAds().setRefreshUnfilledSlots(true);
TypeScript
googletag.companionAds().setRefreshUnfilledSlots(true);
پارامترها | |
---|---|
value : boolean | true to automatically backfill unfilled slots, false to leave them unchanged. |
googletag.PrivacySettingsConfig
خواص | |
---|---|
child Directed Treatment ? | Indicates whether the page should be treated as child-directed . |
limited Ads ? | Enables serving to run in limited ads mode to aid in publisher regulatory compliance needs. |
non Personalized Ads ? | Enables serving to run in non-personalized ads mode to aid in publisher regulatory compliance needs. |
restrict Data Processing ? | Enables serving to run in restricted processing mode to aid in publisher regulatory compliance needs. |
traffic Source ? | Indicates whether requests represent purchased or organic traffic. |
under Age Of Consent ? | Indicates whether to mark ad requests as coming from users under the age of consent . |
- همچنین ببینید
خواص
Optional
childDirectedTreatment
childDirectedTreatment ?: boolean
null
to clear the configuration. Optional
limitedAds
limitedAds ?: boolean
You can instruct GPT to request limited ads in two ways:
- Automatically, by using a signal from an IAB TCF v2.0 consent management platform.
- Manually, by setting the value of this field to
true
.
Note that it is not necessary to manually enable limited ads when a CMP is in use.
- مثال
جاوا اسکریپت
// Manually enable limited ads serving. // GPT must be loaded from the limited ads URL to configure this setting. googletag.pubads().setPrivacySettings({ limitedAds: true, });
JavaScript (legacy)
// Manually enable limited ads serving. // GPT must be loaded from the limited ads URL to configure this setting. googletag.pubads().setPrivacySettings({ limitedAds: true, });
TypeScript
// Manually enable limited ads serving. // GPT must be loaded from the limited ads URL to configure this setting. googletag.pubads().setPrivacySettings({ limitedAds: true, });
- همچنین ببینید
Optional
nonPersonalizedAds
nonPersonalizedAds ?: boolean
Optional
restrictDataProcessing
restrictDataProcessing ?: boolean
Optional
trafficSource
trafficSource ?: TrafficSource
undefined
in reporting.- مثال
جاوا اسکریپت
// Indicate requests represent organic traffic. googletag.pubads().setPrivacySettings({ trafficSource: googletag.enums.TrafficSource.ORGANIC, }); // Indicate requests represent purchased traffic. googletag.pubads().setPrivacySettings({ trafficSource: googletag.enums.TrafficSource.PURCHASED, });
JavaScript (legacy)
// Indicate requests represent organic traffic. googletag.pubads().setPrivacySettings({ trafficSource: googletag.enums.TrafficSource.ORGANIC, }); // Indicate requests represent purchased traffic. googletag.pubads().setPrivacySettings({ trafficSource: googletag.enums.TrafficSource.PURCHASED, });
TypeScript
// Indicate requests represent organic traffic. googletag.pubads().setPrivacySettings({ trafficSource: googletag.enums.TrafficSource.ORGANIC, }); // Indicate requests represent purchased traffic. googletag.pubads().setPrivacySettings({ trafficSource: googletag.enums.TrafficSource.PURCHASED, });
Optional
underAgeOfConsent
underAgeOfConsent ?: boolean
null
to clear the configuration. googletag.PubAdsService
Extendsروش ها | |
---|---|
add Event Listener | Registers a listener that allows you to set up and call a JavaScript function when a specific GPT event happens on the page. Inherited from |
clear | Removes the ads from the given slots and replaces them with blank content. |
clear Category Exclusions | منسوخ شده است. Clears all page-level ad category exclusion labels. |
clear Targeting | منسوخ شده است. Clears custom targeting parameters for a specific key or for all keys. |
collapse Empty Divs | منسوخ شده است. Enables collapsing of slot divs so that they don't take up any space on the page when there is no ad content to display. |
disable Initial Load | منسوخ شده است. Disables requests for ads on page load, but allows ads to be requested with a PubAdsService.refresh call. |
display | Constructs and displays an ad slot with the given ad unit path and size. |
enable Lazy Load | منسوخ شده است. Enables lazy loading in GPT as defined by the config object. |
enable Single Request | منسوخ شده است. Enables single request mode for fetching multiple ads at the same time. |
enable Video Ads | منسوخ شده است. Signals to GPT that video ads will be present on the page. |
get | منسوخ شده است. Returns the value for the AdSense attribute associated with the given key. |
get Attribute Keys | منسوخ شده است. Returns the attribute keys that have been set on this service. |
get Slots | Get the list of slots associated with this service. Inherited from |
get Targeting | منسوخ شده است. Returns a specific custom service-level targeting parameter that has been set. |
get Targeting Keys | منسوخ شده است. Returns the list of all custom service-level targeting keys that have been set. |
is Initial Load Disabled | منسوخ شده است. Returns whether or not initial requests for ads was successfully disabled by a previous PubAdsService.disableInitialLoad call. |
refresh | Fetches and displays new ads for specific or all slots on the page. |
remove Event Listener | Removes a previously registered listener. Inherited from |
set | منسوخ شده است. Sets values for AdSense attributes that apply to all ad slots under the Publisher Ads service. |
set Category Exclusion | منسوخ شده است. Sets a page-level ad category exclusion for the given label name. |
set Centering | منسوخ شده است. Enables and disables horizontal centering of ads. |
set Force Safe Frame | منسوخ شده است. Configures whether all ads on the page should be forced to be rendered using a SafeFrame container. |
set Location | منسوخ شده است. Passes location information from websites so you can geo-target line items to specific locations. |
set Privacy Settings | Allows configuration of all privacy settings from a single API using a config object. |
set Publisher Provided Id | Sets the value for the publisher-provided ID. |
set Safe Frame Config | منسوخ شده است. Sets the page-level preferences for SafeFrame configuration. |
set Targeting | منسوخ شده است. Sets custom targeting parameters for a given key that apply to all Publisher Ads service ad slots. |
set Video Content | منسوخ شده است. Sets the video content information to be sent along with the ad requests for targeting and content exclusion purposes. |
update Correlator | Changes the correlator that is sent with ad requests, effectively starting a new page view. |
روش ها
روشن
clear ( slots ?: Slot [] ) : boolean
In particular, clearing a slot removes the ad from GPT's long-lived pageview , so future requests will not be influenced by roadblocks or competitive exclusions involving this ad.
- مثال
جاوا اسکریپت
const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1"); googletag.display("div-1"); const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2"); googletag.display("div-2"); // This call to clear only slot1. googletag.pubads().clear([slot1]); // This call to clear both slot1 and slot2. googletag.pubads().clear([slot1, slot2]); // This call to clear all slots. googletag.pubads().clear();
JavaScript (legacy)
var slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1"); googletag.display("div-1"); var slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2"); googletag.display("div-2"); // This call to clear only slot1. googletag.pubads().clear([slot1]); // This call to clear both slot1 and slot2. googletag.pubads().clear([slot1, slot2]); // This call to clear all slots. googletag.pubads().clear();
TypeScript
const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1")!; googletag.display("div-1"); const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2")!; googletag.display("div-2"); // This call to clear only slot1. googletag.pubads().clear([slot1]); // This call to clear both slot1 and slot2. googletag.pubads().clear([slot1, slot2]); // This call to clear all slots. googletag.pubads().clear();
پارامترها | |
---|---|
| The array of slots to clear. Array is optional; all slots will be cleared if it is unspecified. |
برمی گرداند | |
---|---|
boolean | Returns true if slots have been cleared, false otherwise. |
clearCategoryExclusions
clearCategoryExclusions ( ) : PubAdsService
- مثال
جاوا اسکریپت
// Set category exclusion to exclude ads with 'AirlineAd' labels. googletag.pubads().setCategoryExclusion("AirlineAd"); // Make ad requests. No ad with 'AirlineAd' label will be returned. // Clear category exclusions so all ads can be returned. googletag.pubads().clearCategoryExclusions(); // Make ad requests. Any ad can be returned.
JavaScript (legacy)
// Set category exclusion to exclude ads with 'AirlineAd' labels. googletag.pubads().setCategoryExclusion("AirlineAd"); // Make ad requests. No ad with 'AirlineAd' label will be returned. // Clear category exclusions so all ads can be returned. googletag.pubads().clearCategoryExclusions(); // Make ad requests. Any ad can be returned.
TypeScript
// Set category exclusion to exclude ads with 'AirlineAd' labels. googletag.pubads().setCategoryExclusion("AirlineAd"); // Make ad requests. No ad with 'AirlineAd' label will be returned. // Clear category exclusions so all ads can be returned. googletag.pubads().clearCategoryExclusions(); // Make ad requests. Any ad can be returned.
- همچنین ببینید
برمی گرداند | |
---|---|
PubAdsService | The service object on which the method was called. |
clearTargeting
clearTargeting ( key ?: string ) : PubAdsService
- مثال
جاوا اسکریپت
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().setTargeting("colors", "blue"); googletag.pubads().setTargeting("fruits", "apple"); googletag.pubads().clearTargeting("interests"); // Targeting 'colors' and 'fruits' are still present, while 'interests' // was cleared. googletag.pubads().clearTargeting(); // All targeting has been cleared.
JavaScript (legacy)
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().setTargeting("colors", "blue"); googletag.pubads().setTargeting("fruits", "apple"); googletag.pubads().clearTargeting("interests"); // Targeting 'colors' and 'fruits' are still present, while 'interests' // was cleared. googletag.pubads().clearTargeting(); // All targeting has been cleared.
TypeScript
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().setTargeting("colors", "blue"); googletag.pubads().setTargeting("fruits", "apple"); googletag.pubads().clearTargeting("interests"); // Targeting 'colors' and 'fruits' are still present, while 'interests' // was cleared. googletag.pubads().clearTargeting(); // All targeting has been cleared.
- همچنین ببینید
پارامترها | |
---|---|
| Targeting parameter key. The key is optional; all targeting parameters will be cleared if it is unspecified. |
برمی گرداند | |
---|---|
PubAdsService | The service object on which the method was called. |
collapseEmptyDivs
collapseEmptyDivs ( collapseBeforeAdFetch ?: boolean ) : boolean
- همچنین ببینید
پارامترها | |
---|---|
| Whether to collapse the slots even before the ads are fetched. This parameter is optional; if not provided, false will be used as the default value. |
برمی گرداند | |
---|---|
boolean | Returns true if div collapse mode was enabled and false if it is impossible to enable collapse mode because the method was called after the service was enabled. |
disableInitialLoad
disableInitialLoad ( ) : void
refresh
.- همچنین ببینید
نمایش داده شود
display ( adUnitPath : string , size : GeneralSize , div ?: string | Element , clickUrl ?: string ) : void
Note: When this method is called, a snapshot of the slot and page state is created to ensure consistency when sending the ad request and rendering the response. Any changes that are made to the slot or page state after this method is called (including targeting, privacy settings, force SafeFrame, etc.) will only apply to subsequent
display()
or refresh()
requests.- مثال
جاوا اسکریپت
googletag.pubads().display("/1234567/sports", [728, 90], "div-1");
JavaScript (legacy)
googletag.pubads().display("/1234567/sports", [728, 90], "div-1");
TypeScript
googletag.pubads().display("/1234567/sports", [728, 90], "div-1");
- همچنین ببینید
پارامترها | |
---|---|
adUnitPath : string | The ad unit path of slot to be rendered. |
size : GeneralSize | Width and height of the slot. |
| Either the ID of the div containing the slot or the div element itself. |
| The click URL to use on this slot. |
enableLazyLoad
enableLazyLoad ( config ?: {
fetchMarginPercent ?: number ;
mobileScaling ?: number ;
renderMarginPercent ?: number ;
} ) : void
Note: Lazy fetching in SRA only works if all slots are outside the fetching margin.
- مثال
جاوا اسکریپت
googletag.pubads().enableLazyLoad({ // Fetch slots within 5 viewports. fetchMarginPercent: 500, // Render slots within 2 viewports. renderMarginPercent: 200, // Double the above values on mobile. mobileScaling: 2.0, });
JavaScript (legacy)
googletag.pubads().enableLazyLoad({ // Fetch slots within 5 viewports. fetchMarginPercent: 500, // Render slots within 2 viewports. renderMarginPercent: 200, // Double the above values on mobile. mobileScaling: 2.0, });
TypeScript
googletag.pubads().enableLazyLoad({ // Fetch slots within 5 viewports. fetchMarginPercent: 500, // Render slots within 2 viewports. renderMarginPercent: 200, // Double the above values on mobile. mobileScaling: 2.0, });
پارامترها | |
---|---|
| Configuration object allows customization of lazy behavior. Any omitted configurations will use a default set by Google that will be tuned over time. To disable a particular setting, such as a fetching margin, set the value to -1 .
|
enableSingleRequest
enableSingleRequest ( ) : boolean
برمی گرداند | |
---|---|
boolean | Returns true if single request mode was enabled and false if it is impossible to enable single request mode because the method was called after the service was enabled. |
enableVideoAds
enableVideoAds ( ) : void
دریافت کنید
get ( key : string ) : string
- مثال
جاوا اسکریپت
googletag.pubads().set("adsense_background_color", "#FFFFFF"); googletag.pubads().get("adsense_background_color"); // Returns '#FFFFFF'.
JavaScript (legacy)
googletag.pubads().set("adsense_background_color", "#FFFFFF"); googletag.pubads().get("adsense_background_color"); // Returns '#FFFFFF'.
TypeScript
googletag.pubads().set("adsense_background_color", "#FFFFFF"); googletag.pubads().get("adsense_background_color"); // Returns '#FFFFFF'.
- همچنین ببینید
پارامترها | |
---|---|
key : string | Name of the attribute to look for. |
برمی گرداند | |
---|---|
string | Current value for the attribute key, or null if the key is not present. |
getAttributeKeys
getAttributeKeys ( ) : string []
- مثال
جاوا اسکریپت
googletag.pubads().set("adsense_background_color", "#FFFFFF"); googletag.pubads().set("adsense_border_color", "#AABBCC"); googletag.pubads().getAttributeKeys(); // Returns ['adsense_background_color', 'adsense_border_color'].
JavaScript (legacy)
googletag.pubads().set("adsense_background_color", "#FFFFFF"); googletag.pubads().set("adsense_border_color", "#AABBCC"); googletag.pubads().getAttributeKeys(); // Returns ['adsense_background_color', 'adsense_border_color'].
TypeScript
googletag.pubads().set("adsense_background_color", "#FFFFFF"); googletag.pubads().set("adsense_border_color", "#AABBCC"); googletag.pubads().getAttributeKeys(); // Returns ['adsense_background_color', 'adsense_border_color'].
برمی گرداند | |
---|---|
string [] | Array of attribute keys set on this service. Ordering is undefined. |
getTargeting
getTargeting ( key : string ) : string []
- مثال
جاوا اسکریپت
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().getTargeting("interests"); // Returns ['sports']. googletag.pubads().getTargeting("age"); // Returns [] (empty array).
JavaScript (legacy)
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().getTargeting("interests"); // Returns ['sports']. googletag.pubads().getTargeting("age"); // Returns [] (empty array).
TypeScript
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().getTargeting("interests"); // Returns ['sports']. googletag.pubads().getTargeting("age"); // Returns [] (empty array).
پارامترها | |
---|---|
key : string | The targeting key to look for. |
برمی گرداند | |
---|---|
string [] | The values associated with this key, or an empty array if there is no such key. |
getTargetingKeys
getTargetingKeys ( ) : string []
- مثال
جاوا اسکریپت
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().setTargeting("colors", "blue"); googletag.pubads().getTargetingKeys(); // Returns ['interests', 'colors'].
JavaScript (legacy)
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().setTargeting("colors", "blue"); googletag.pubads().getTargetingKeys(); // Returns ['interests', 'colors'].
TypeScript
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().setTargeting("colors", "blue"); googletag.pubads().getTargetingKeys(); // Returns ['interests', 'colors'].
برمی گرداند | |
---|---|
string [] | Array of targeting keys. Ordering is undefined. |
isInitialLoadDisabled
isInitialLoadDisabled ( ) : boolean
برمی گرداند | |
---|---|
boolean | Returns true if a previous call to PubAdsService.disableInitialLoad was successful, false otherwise. |
تازه کردن
refresh ( slots ?: Slot [] , options ?: {
changeCorrelator : boolean ;
} ) : void
For proper behavior across all browsers, calling
refresh
must be preceded by a call to display
the ad slot. If the call to display
is omitted, refresh may behave unexpectedly. If desired, the PubAdsService.disableInitialLoad method can be used to stop display
from fetching an ad.Refreshing a slot removes the old ad from GPT's long-lived pageview , so future requests will not be influenced by roadblocks or competitive exclusions involving that ad.
- مثال
جاوا اسکریپت
const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1"); googletag.display("div-1"); const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2"); googletag.display("div-2"); // This call to refresh fetches a new ad for slot1 only. googletag.pubads().refresh([slot1]); // This call to refresh fetches a new ad for both slot1 and slot2. googletag.pubads().refresh([slot1, slot2]); // This call to refresh fetches a new ad for each slot. googletag.pubads().refresh(); // This call to refresh fetches a new ad for slot1, without changing // the correlator. googletag.pubads().refresh([slot1], { changeCorrelator: false }); // This call to refresh fetches a new ad for each slot, without // changing the correlator. googletag.pubads().refresh(null, { changeCorrelator: false });
JavaScript (legacy)
var slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1"); googletag.display("div-1"); var slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2"); googletag.display("div-2"); // This call to refresh fetches a new ad for slot1 only. googletag.pubads().refresh([slot1]); // This call to refresh fetches a new ad for both slot1 and slot2. googletag.pubads().refresh([slot1, slot2]); // This call to refresh fetches a new ad for each slot. googletag.pubads().refresh(); // This call to refresh fetches a new ad for slot1, without changing // the correlator. googletag.pubads().refresh([slot1], { changeCorrelator: false }); // This call to refresh fetches a new ad for each slot, without // changing the correlator. googletag.pubads().refresh(null, { changeCorrelator: false });
TypeScript
const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1")!; googletag.display("div-1"); const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2")!; googletag.display("div-2"); // This call to refresh fetches a new ad for slot1 only. googletag.pubads().refresh([slot1]); // This call to refresh fetches a new ad for both slot1 and slot2. googletag.pubads().refresh([slot1, slot2]); // This call to refresh fetches a new ad for each slot. googletag.pubads().refresh(); // This call to refresh fetches a new ad for slot1, without changing // the correlator. googletag.pubads().refresh([slot1], { changeCorrelator: false }); // This call to refresh fetches a new ad for each slot, without // changing the correlator. googletag.pubads().refresh(null, { changeCorrelator: false });
- همچنین ببینید
پارامترها | |
---|---|
| The slots to refresh. Array is optional; all slots will be refreshed if it is unspecified. |
| Configuration options associated with this refresh call.
|
مجموعه
set ( key : string , value : string ) : PubAdsService
Calling this more than once for the same key will override previously set values for that key. All values must be set before calling
display
or refresh
.- مثال
جاوا اسکریپت
googletag.pubads().set("adsense_background_color", "#FFFFFF");
JavaScript (legacy)
googletag.pubads().set("adsense_background_color", "#FFFFFF");
TypeScript
googletag.pubads().set("adsense_background_color", "#FFFFFF");
- همچنین ببینید
پارامترها | |
---|---|
key : string | The name of the attribute. |
value : string | Attribute value. |
برمی گرداند | |
---|---|
PubAdsService | The service object on which the method was called. |
setCategoryExclusion
setCategoryExclusion ( categoryExclusion : string ) : PubAdsService
- مثال
جاوا اسکریپت
// Label = AirlineAd. googletag.pubads().setCategoryExclusion("AirlineAd");
JavaScript (legacy)
// Label = AirlineAd. googletag.pubads().setCategoryExclusion("AirlineAd");
TypeScript
// Label = AirlineAd. googletag.pubads().setCategoryExclusion("AirlineAd");
- همچنین ببینید
پارامترها | |
---|---|
categoryExclusion : string | The ad category exclusion label to add. |
برمی گرداند | |
---|---|
PubAdsService | The service object on which the method was called. |
setCentering
setCentering ( centerAds : boolean ) : void
This method should be invoked before calling
display
or refresh
because only ads that are requested after calling this method will be centered.- مثال
جاوا اسکریپت
// Make ads centered. googletag.pubads().setCentering(true);
JavaScript (legacy)
// Make ads centered. googletag.pubads().setCentering(true);
TypeScript
// Make ads centered. googletag.pubads().setCentering(true);
پارامترها | |
---|---|
centerAds : boolean | true to center ads, false to left-align them. |
setForceSafeFrame
setForceSafeFrame ( forceSafeFrame : boolean ) : PubAdsService
Please keep the following things in mind while using this API:
- This setting will only take effect for subsequent ad requests made for the respective slots.
- The slot level setting, if specified, will always override the page level setting.
- If set to
true
(at slot-level or page level), the ad will always be rendered using a SafeFrame container independent of the choice made in the Google Ad Manager UI. - However, if set to
false
or left unspecified, the ad will be rendered using a SafeFrame container depending on the type of creative and the selection made in the Google Ad Manager UI. - This API should be used with caution as it could impact the behaviour of creatives that attempt to break out of their iFrames or rely on them being rendered directly in a publishers page.
- مثال
جاوا اسکریپت
googletag.pubads().setForceSafeFrame(true); // The following slot will be opted-out of the page-level force // SafeFrame instruction. googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setForceSafeFrame(false) .addService(googletag.pubads()); // The following slot will have SafeFrame forced. googletag.defineSlot("/1234567/news", [160, 600], "div-2").addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
JavaScript (legacy)
googletag.pubads().setForceSafeFrame(true); // The following slot will be opted-out of the page-level force // SafeFrame instruction. googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setForceSafeFrame(false) .addService(googletag.pubads()); // The following slot will have SafeFrame forced. googletag.defineSlot("/1234567/news", [160, 600], "div-2").addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
TypeScript
googletag.pubads().setForceSafeFrame(true); // The following slot will be opted-out of the page-level force // SafeFrame instruction. googletag .defineSlot("/1234567/sports", [160, 600], "div-1")! .setForceSafeFrame(false) .addService(googletag.pubads()); // The following slot will have SafeFrame forced. googletag.defineSlot("/1234567/news", [160, 600], "div-2")!.addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
- همچنین ببینید
پارامترها | |
---|---|
forceSafeFrame : boolean | true to force all ads on the page to be rendered in SafeFrames and false to change the previous setting to false. Setting this to false when unspecified earlier, won't change anything. |
برمی گرداند | |
---|---|
PubAdsService | The service object on which the method was called. |
setLocation
setLocation ( address : string ) : PubAdsService
- مثال
جاوا اسکریپت
// Postal code: googletag.pubads().setLocation("10001,US");
JavaScript (legacy)
// Postal code: googletag.pubads().setLocation("10001,US");
TypeScript
// Postal code: googletag.pubads().setLocation("10001,US");
پارامترها | |
---|---|
address : string | Freeform address. |
برمی گرداند | |
---|---|
PubAdsService | The service object on which the method was called. |
setPrivacySettings
setPrivacySettings ( privacySettings : PrivacySettingsConfig ) : PubAdsService
- مثال
جاوا اسکریپت
googletag.pubads().setPrivacySettings({ restrictDataProcessing: true, }); // Set multiple privacy settings at the same time. googletag.pubads().setPrivacySettings({ childDirectedTreatment: true, underAgeOfConsent: true, }); // Clear the configuration for childDirectedTreatment. googletag.pubads().setPrivacySettings({ childDirectedTreatment: null, });
JavaScript (legacy)
googletag.pubads().setPrivacySettings({ restrictDataProcessing: true, }); // Set multiple privacy settings at the same time. googletag.pubads().setPrivacySettings({ childDirectedTreatment: true, underAgeOfConsent: true, }); // Clear the configuration for childDirectedTreatment. googletag.pubads().setPrivacySettings({ childDirectedTreatment: null, });
TypeScript
googletag.pubads().setPrivacySettings({ restrictDataProcessing: true, }); // Set multiple privacy settings at the same time. googletag.pubads().setPrivacySettings({ childDirectedTreatment: true, underAgeOfConsent: true, }); // Clear the configuration for childDirectedTreatment. googletag.pubads().setPrivacySettings({ childDirectedTreatment: null, });
- همچنین ببینید
پارامترها | |
---|---|
privacySettings : PrivacySettingsConfig | Object containing privacy settings config. |
برمی گرداند | |
---|---|
PubAdsService | The service object on which the function was called. |
setPublisherProvidedId
setPublisherProvidedId ( ppid : string ) : PubAdsService
- مثال
جاوا اسکریپت
googletag.pubads().setPublisherProvidedId("12JD92JD8078S8J29SDOAKC0EF230337");
JavaScript (legacy)
googletag.pubads().setPublisherProvidedId("12JD92JD8078S8J29SDOAKC0EF230337");
TypeScript
googletag.pubads().setPublisherProvidedId("12JD92JD8078S8J29SDOAKC0EF230337");
- همچنین ببینید
پارامترها | |
---|---|
ppid : string | An alphanumeric ID provided by the publisher. Must be between 32 and 150 characters. |
برمی گرداند | |
---|---|
PubAdsService | The service object on which the method was called. |
setSafeFrameConfig
setSafeFrameConfig ( config : SafeFrameConfig ) : PubAdsService
These page-level preferences will be overridden by slot-level preferences, if specified.
- مثال
جاوا اسکریپت
googletag.pubads().setForceSafeFrame(true); const pageConfig = { allowOverlayExpansion: true, allowPushExpansion: true, sandbox: true, }; const slotConfig = { allowOverlayExpansion: false }; googletag.pubads().setSafeFrameConfig(pageConfig); // The following slot will not allow for expansion by overlay. googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setSafeFrameConfig(slotConfig) .addService(googletag.pubads()); // The following slot will inherit the page level settings, and hence // would allow for expansion by overlay. googletag.defineSlot("/1234567/news", [160, 600], "div-2").addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
JavaScript (legacy)
googletag.pubads().setForceSafeFrame(true); var pageConfig = { allowOverlayExpansion: true, allowPushExpansion: true, sandbox: true, }; var slotConfig = { allowOverlayExpansion: false }; googletag.pubads().setSafeFrameConfig(pageConfig); // The following slot will not allow for expansion by overlay. googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setSafeFrameConfig(slotConfig) .addService(googletag.pubads()); // The following slot will inherit the page level settings, and hence // would allow for expansion by overlay. googletag.defineSlot("/1234567/news", [160, 600], "div-2").addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
TypeScript
googletag.pubads().setForceSafeFrame(true); const pageConfig = { allowOverlayExpansion: true, allowPushExpansion: true, sandbox: true, }; const slotConfig = { allowOverlayExpansion: false }; googletag.pubads().setSafeFrameConfig(pageConfig); // The following slot will not allow for expansion by overlay. googletag .defineSlot("/1234567/sports", [160, 600], "div-1")! .setSafeFrameConfig(slotConfig) .addService(googletag.pubads()); // The following slot will inherit the page level settings, and hence // would allow for expansion by overlay. googletag.defineSlot("/1234567/news", [160, 600], "div-2")!.addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
- همچنین ببینید
پارامترها | |
---|---|
config : SafeFrameConfig | The configuration object. |
برمی گرداند | |
---|---|
PubAdsService | The service object on which the method was called. |
setTargeting
setTargeting ( key : string , value : string | string [] ) : PubAdsService
- مثال
جاوا اسکریپت
// Example with a single value for a key. googletag.pubads().setTargeting("interests", "sports"); // Example with multiple values for a key inside in an array. googletag.pubads().setTargeting("interests", ["sports", "music"]);
JavaScript (legacy)
// Example with a single value for a key. googletag.pubads().setTargeting("interests", "sports"); // Example with multiple values for a key inside in an array. googletag.pubads().setTargeting("interests", ["sports", "music"]);
TypeScript
// Example with a single value for a key. googletag.pubads().setTargeting("interests", "sports"); // Example with multiple values for a key inside in an array. googletag.pubads().setTargeting("interests", ["sports", "music"]);
- همچنین ببینید
پارامترها | |
---|---|
key : string | Targeting parameter key. |
value : string | string [] | Targeting parameter value or array of values. |
برمی گرداند | |
---|---|
PubAdsService | The service object on which the method was called. |
setVideoContent
setVideoContent ( videoContentId : string , videoCmsId : string ) : void
videoContentId
and videoCmsId
, use the values that are provided to the Google Ad Manager content ingestion service.- همچنین ببینید
پارامترها | |
---|---|
videoContentId : string | The video content ID. |
videoCmsId : string | The video CMS ID. |
updateCorrelator
updateCorrelator ( ) : PubAdsService
Note: this has no effect on GPT's long-lived pageview , which automatically reflects the ads actually on the page and has no expiration time.
- مثال
جاوا اسکریپت
// Assume that the correlator is currently 12345. All ad requests made // by this page will currently use that value. // Replace the current correlator with a new correlator. googletag.pubads().updateCorrelator(); // The correlator will now be a new randomly selected value, different // from 12345. All subsequent ad requests made by this page will use // the new value.
JavaScript (legacy)
// Assume that the correlator is currently 12345. All ad requests made // by this page will currently use that value. // Replace the current correlator with a new correlator. googletag.pubads().updateCorrelator(); // The correlator will now be a new randomly selected value, different // from 12345. All subsequent ad requests made by this page will use // the new value.
TypeScript
// Assume that the correlator is currently 12345. All ad requests made // by this page will currently use that value. // Replace the current correlator with a new correlator. googletag.pubads().updateCorrelator(); // The correlator will now be a new randomly selected value, different // from 12345. All subsequent ad requests made by this page will use // the new value.
برمی گرداند | |
---|---|
PubAdsService | The service object on which the function was called. |
googletag.ResponseInformation
خواص | |
---|---|
advertiser Id | The ID of the advertiser. |
campaign Id | The ID of the campaign. |
creative Id | The ID of the creative. |
creative Template Id | The template ID of the ad. |
line Item Id | The ID of the line item. |
- همچنین ببینید
خواص
advertiserId
advertiserId : number
شناسه کمپین
campaignId : number
creativeId
creativeId : number
creativeTemplateId
creativeTemplateId : number
lineItemId
lineItemId : number
googletag.RewardedPayload
خواص | |
---|---|
amount | The number of items included in the reward. |
type | The type of item included in the reward (for example, "coin"). |
- همچنین ببینید
خواص
مقدار
amount : number
نوع
type : string
googletag.Service
روش ها | |
---|---|
add Event Listener | Registers a listener that allows you to set up and call a JavaScript function when a specific GPT event happens on the page. |
get Slots | Get the list of slots associated with this service. |
remove Event Listener | Removes a previously registered listener. |
روش ها
addEventListener
addEventListener < K extends keyof EventTypeMap > ( eventType : K , listener : ( ( arg : EventTypeMap [ K ] ) => void ) ) : Service
- events.GameManualInterstitialSlotClosedEvent
- events.GameManualInterstitialSlotReadyEvent
- events.ImpressionViewableEvent
- events.RewardedSlotClosedEvent
- events.RewardedSlotGrantedEvent
- events.RewardedSlotReadyEvent
- events.SlotOnloadEvent
- events.SlotRenderEndedEvent
- events.SlotRequestedEvent
- events.SlotResponseReceived
- events.SlotVisibilityChangedEvent
- مثال
جاوا اسکریپت
// 1. Adding an event listener for the PubAdsService. googletag.pubads().addEventListener("slotOnload", (event) => { console.log("Slot has been loaded:"); console.log(event); }); // 2. Adding an event listener with slot specific logic. // Listeners operate at service level, which means that you cannot add // a listener for an event for a specific slot only. You can, however, // programmatically filter a listener to respond only to a certain ad // slot, using this pattern: const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotOnload", (event) => { if (event.slot === targetSlot) { // Slot specific logic. } });
JavaScript (legacy)
// 1. Adding an event listener for the PubAdsService. googletag.pubads().addEventListener("slotOnload", function (event) { console.log("Slot has been loaded:"); console.log(event); }); // 2. Adding an event listener with slot specific logic. // Listeners operate at service level, which means that you cannot add // a listener for an event for a specific slot only. You can, however, // programmatically filter a listener to respond only to a certain ad // slot, using this pattern: var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotOnload", function (event) { if (event.slot === targetSlot) { // Slot specific logic. } });
TypeScript
// 1. Adding an event listener for the PubAdsService. googletag.pubads().addEventListener("slotOnload", (event) => { console.log("Slot has been loaded:"); console.log(event); }); // 2. Adding an event listener with slot specific logic. // Listeners operate at service level, which means that you cannot add // a listener for an event for a specific slot only. You can, however, // programmatically filter a listener to respond only to a certain ad // slot, using this pattern: const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotOnload", (event) => { if (event.slot === targetSlot) { // Slot specific logic. } });
- همچنین ببینید
پارامترها | |
---|---|
eventType : K | A string representing the type of event generated by GPT. Event types are case sensitive. |
listener : ( ( arg : EventTypeMap [ K ] ) => void ) | Function that takes a single event object argument. |
برمی گرداند | |
---|---|
Service | The service object on which the method was called. |
getSlots
removeEventListener
removeEventListener < K extends keyof EventTypeMap > ( eventType : K , listener : ( ( event : EventTypeMap [ K ] ) => void ) ) : void
- مثال
جاوا اسکریپت
googletag.cmd.push(() => { // Define a new ad slot. googletag.defineSlot("/6355419/Travel", [728, 90], "div-for-slot").addService(googletag.pubads()); // Define a new function that removes itself via removeEventListener // after the impressionViewable event fires. const onViewableListener = (event) => { googletag.pubads().removeEventListener("impressionViewable", onViewableListener); setTimeout(() => { googletag.pubads().refresh([event.slot]); }, 30000); }; // Add onViewableListener as a listener for impressionViewable events. googletag.pubads().addEventListener("impressionViewable", onViewableListener); googletag.enableServices(); });
JavaScript (legacy)
googletag.cmd.push(function () { // Define a new ad slot. googletag.defineSlot("/6355419/Travel", [728, 90], "div-for-slot").addService(googletag.pubads()); // Define a new function that removes itself via removeEventListener // after the impressionViewable event fires. var onViewableListener = function (event) { googletag.pubads().removeEventListener("impressionViewable", onViewableListener); setTimeout(function () { googletag.pubads().refresh([event.slot]); }, 30000); }; // Add onViewableListener as a listener for impressionViewable events. googletag.pubads().addEventListener("impressionViewable", onViewableListener); googletag.enableServices(); });
TypeScript
googletag.cmd.push(() => { // Define a new ad slot. googletag .defineSlot("/6355419/Travel", [728, 90], "div-for-slot")! .addService(googletag.pubads()); // Define a new function that removes itself via removeEventListener // after the impressionViewable event fires. const onViewableListener = (event: googletag.events.ImpressionViewableEvent) => { googletag.pubads().removeEventListener("impressionViewable", onViewableListener); setTimeout(() => { googletag.pubads().refresh([event.slot]); }, 30000); }; // Add onViewableListener as a listener for impressionViewable events. googletag.pubads().addEventListener("impressionViewable", onViewableListener); googletag.enableServices(); });
پارامترها | |
---|---|
eventType : K | A string representing the type of event generated by GPT. Event types are case sensitive. |
listener : ( ( event : EventTypeMap [ K ] ) => void ) | Function that takes a single event object argument. |
googletag.SizeMappingBuilder
روش ها | |
---|---|
add Size | Adds a mapping from a single-size array (representing the viewport) to a single- or multi-size array representing the slot. |
build | Builds a size map specification from the mappings added to this builder. |
- همچنین ببینید
روش ها
addSize
addSize ( viewportSize : SingleSizeArray , slotSize : GeneralSize ) : SizeMappingBuilder
- مثال
جاوا اسکریپت
// Mapping 1 googletag .sizeMapping() .addSize([1024, 768], [970, 250]) .addSize([980, 690], [728, 90]) .addSize([640, 480], "fluid") .addSize([0, 0], [88, 31]) // All viewports < 640x480 .build(); // Mapping 2 googletag .sizeMapping() .addSize([1024, 768], [970, 250]) .addSize([980, 690], []) .addSize([640, 480], [120, 60]) .addSize([0, 0], []) .build(); // Mapping 2 will not show any ads for the following viewport sizes: // [1024, 768] > size >= [980, 690] and // [640, 480] > size >= [0, 0]
JavaScript (legacy)
// Mapping 1 googletag .sizeMapping() .addSize([1024, 768], [970, 250]) .addSize([980, 690], [728, 90]) .addSize([640, 480], "fluid") .addSize([0, 0], [88, 31]) // All viewports < 640x480 .build(); // Mapping 2 googletag .sizeMapping() .addSize([1024, 768], [970, 250]) .addSize([980, 690], []) .addSize([640, 480], [120, 60]) .addSize([0, 0], []) .build(); // Mapping 2 will not show any ads for the following viewport sizes: // [1024, 768] > size >= [980, 690] and // [640, 480] > size >= [0, 0]
TypeScript
// Mapping 1 googletag .sizeMapping() .addSize([1024, 768], [970, 250]) .addSize([980, 690], [728, 90]) .addSize([640, 480], "fluid") .addSize([0, 0], [88, 31]) // All viewports < 640x480 .build(); // Mapping 2 googletag .sizeMapping() .addSize([1024, 768], [970, 250]) .addSize([980, 690], []) .addSize([640, 480], [120, 60]) .addSize([0, 0], []) .build(); // Mapping 2 will not show any ads for the following viewport sizes: // [1024, 768] > size >= [980, 690] and // [640, 480] > size >= [0, 0]
پارامترها | |
---|---|
viewportSize : SingleSizeArray | The size of the viewport for this mapping entry. |
slotSize : GeneralSize | The sizes of the slot for this mapping entry. |
برمی گرداند | |
---|---|
SizeMappingBuilder | A reference to this builder. |
ساختن
build ( ) : SizeMappingArray
If any invalid mappings have been supplied, this method will return
null
. Otherwise it returns a specification in the correct format to pass to Slot.defineSizeMapping .Note: the behavior of the builder after calling this method is undefined.
برمی گرداند | |
---|---|
SizeMappingArray | The result built by this builder. Can be null if invalid size mappings were supplied. |
googletag.Slot
روش ها | |
---|---|
add Service | Adds a Service to this slot. |
clear Category Exclusions | منسوخ شده است. Clears all slot-level ad category exclusion labels for this slot. |
clear Targeting | منسوخ شده است. Clears specific or all custom slot-level targeting parameters for this slot. |
define Size Mapping | Sets an array of mappings from a minimum viewport size to slot size for this slot. |
get | منسوخ شده است. Returns the value for the AdSense attribute associated with the given key for this slot. |
get Ad Unit Path | Returns the full path of the ad unit, with the network code and ad unit path. |
get Attribute Keys | منسوخ شده است. Returns the list of attribute keys set on this slot. |
get Category Exclusions | منسوخ شده است. Returns the ad category exclusion labels for this slot. |
get Config | Gets general configuration options for the slot set by setConfig . |
get Response Information | Returns the ad response information. |
get Slot Element Id | Returns the ID of the slot div provided when the slot was defined. |
get Targeting | منسوخ شده است. Returns a specific custom targeting parameter set on this slot. |
get Targeting Keys | منسوخ شده است. Returns the list of all custom targeting keys set on this slot. |
set | منسوخ شده است. Sets a value for an AdSense attribute on this ad slot. |
set Category Exclusion | منسوخ شده است. Sets a slot-level ad category exclusion label on this slot. |
set Click Url | منسوخ شده است. Sets the click URL to which users will be redirected after clicking on the ad. |
set Collapse Empty Div | منسوخ شده است. Sets whether the slot div should be hidden when there is no ad in the slot. |
set Config | Sets general configuration options for this slot. |
set Force Safe Frame | منسوخ شده است. Configures whether ads in this slot should be forced to be rendered using a SafeFrame container. |
set Safe Frame Config | منسوخ شده است. Sets the slot-level preferences for SafeFrame configuration. |
set Targeting | منسوخ شده است. Sets a custom targeting parameter for this slot. |
update Targeting From Map | منسوخ شده است. Sets custom targeting parameters for this slot, from a key:value map in a JSON object. |
روش ها
addService
addService ( service : Service ) : Slot
- مثال
جاوا اسکریپت
googletag.defineSlot("/1234567/sports", [160, 600], "div").addService(googletag.pubads());
JavaScript (legacy)
googletag.defineSlot("/1234567/sports", [160, 600], "div").addService(googletag.pubads());
TypeScript
googletag.defineSlot("/1234567/sports", [160, 600], "div")!.addService(googletag.pubads());
- همچنین ببینید
پارامترها | |
---|---|
service : Service | The service to be added. |
برمی گرداند | |
---|---|
Slot | The slot object on which the method was called. |
clearCategoryExclusions
clearCategoryExclusions ( ) : Slot
- مثال
جاوا اسکریپت
// Set category exclusion to exclude ads with 'AirlineAd' labels. const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setCategoryExclusion("AirlineAd") .addService(googletag.pubads()); // Make an ad request. No ad with 'AirlineAd' label will be returned // for the slot. // Clear category exclusions so all ads can be returned. slot.clearCategoryExclusions(); // Make an ad request. Any ad can be returned for the slot.
JavaScript (legacy)
// Set category exclusion to exclude ads with 'AirlineAd' labels. var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setCategoryExclusion("AirlineAd") .addService(googletag.pubads()); // Make an ad request. No ad with 'AirlineAd' label will be returned // for the slot. // Clear category exclusions so all ads can be returned. slot.clearCategoryExclusions(); // Make an ad request. Any ad can be returned for the slot.
TypeScript
// Set category exclusion to exclude ads with 'AirlineAd' labels. const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setCategoryExclusion("AirlineAd") .addService(googletag.pubads()); // Make an ad request. No ad with 'AirlineAd' label will be returned // for the slot. // Clear category exclusions so all ads can be returned. slot.clearCategoryExclusions(); // Make an ad request. Any ad can be returned for the slot.
برمی گرداند | |
---|---|
Slot | The slot object on which the method was called. |
clearTargeting
clearTargeting ( key ?: string ) : Slot
- مثال
جاوا اسکریپت
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setTargeting("allow_expandable", "true") .setTargeting("interests", ["sports", "music"]) .setTargeting("color", "red") .addService(googletag.pubads()); slot.clearTargeting("color"); // Targeting 'allow_expandable' and 'interests' are still present, // while 'color' was cleared. slot.clearTargeting(); // All targeting has been cleared.
JavaScript (legacy)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setTargeting("allow_expandable", "true") .setTargeting("interests", ["sports", "music"]) .setTargeting("color", "red") .addService(googletag.pubads()); slot.clearTargeting("color"); // Targeting 'allow_expandable' and 'interests' are still present, // while 'color' was cleared. slot.clearTargeting(); // All targeting has been cleared.
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setTargeting("allow_expandable", "true") .setTargeting("interests", ["sports", "music"]) .setTargeting("color", "red") .addService(googletag.pubads()); slot.clearTargeting("color"); // Targeting 'allow_expandable' and 'interests' are still present, // while 'color' was cleared. slot.clearTargeting(); // All targeting has been cleared.
- همچنین ببینید
پارامترها | |
---|---|
| Targeting parameter key. The key is optional; all targeting parameters will be cleared if it is unspecified. |
برمی گرداند | |
---|---|
Slot | The slot object on which the method was called. |
defineSizeMapping
defineSizeMapping ( sizeMapping : SizeMappingArray ) : Slot
- مثال
جاوا اسکریپت
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); const mapping = googletag .sizeMapping() .addSize([100, 100], [88, 31]) .addSize( [320, 400], [ [320, 50], [300, 50], ], ) .build(); slot.defineSizeMapping(mapping);
JavaScript (legacy)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); var mapping = googletag .sizeMapping() .addSize([100, 100], [88, 31]) .addSize( [320, 400], [ [320, 50], [300, 50], ], ) .build(); slot.defineSizeMapping(mapping);
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); const mapping = googletag .sizeMapping() .addSize([100, 100], [88, 31]) .addSize( [320, 400], [ [320, 50], [300, 50], ], ) .build(); slot.defineSizeMapping(mapping!);
- همچنین ببینید
پارامترها | |
---|---|
sizeMapping : SizeMappingArray | Array of size mappings. You can use SizeMappingBuilder to create it. Each size mapping is an array of two elements: SingleSizeArray and GeneralSize . |
برمی گرداند | |
---|---|
Slot | The slot object on which the method was called. |
دریافت کنید
get ( key : string ) : string
- مثال
جاوا اسکریپت
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .set("adsense_background_color", "#FFFFFF") .addService(googletag.pubads()); slot.get("adsense_background_color"); // Returns '#FFFFFF'.
JavaScript (legacy)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .set("adsense_background_color", "#FFFFFF") .addService(googletag.pubads()); slot.get("adsense_background_color"); // Returns '#FFFFFF'.
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .set("adsense_background_color", "#FFFFFF") .addService(googletag.pubads()); slot.get("adsense_background_color"); // Returns '#FFFFFF'.
- همچنین ببینید
پارامترها | |
---|---|
key : string | Name of the attribute to look for. |
برمی گرداند | |
---|---|
string | Current value for the attribute key, or null if the key is not present. |
getAdUnitPath
getAdUnitPath ( ) : string
- مثال
جاوا اسکریپت
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); slot.getAdUnitPath(); // Returns '/1234567/sports'.
JavaScript (legacy)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); slot.getAdUnitPath(); // Returns '/1234567/sports'.
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); slot.getAdUnitPath(); // Returns '/1234567/sports'.
برمی گرداند | |
---|---|
string | Ad unit path. |
getAttributeKeys
getAttributeKeys ( ) : string []
- مثال
جاوا اسکریپت
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .set("adsense_background_color", "#FFFFFF") .set("adsense_border_color", "#AABBCC") .addService(googletag.pubads()); slot.getAttributeKeys(); // Returns ['adsense_background_color', 'adsense_border_color'].
JavaScript (legacy)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .set("adsense_background_color", "#FFFFFF") .set("adsense_border_color", "#AABBCC") .addService(googletag.pubads()); slot.getAttributeKeys(); // Returns ['adsense_background_color', 'adsense_border_color'].
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .set("adsense_background_color", "#FFFFFF") .set("adsense_border_color", "#AABBCC") .addService(googletag.pubads()); slot.getAttributeKeys(); // Returns ['adsense_background_color', 'adsense_border_color'].
برمی گرداند | |
---|---|
string [] | Array of attribute keys. Ordering is undefined. |
getCategoryExclusions
getCategoryExclusions ( ) : string []
- مثال
جاوا اسکریپت
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setCategoryExclusion("AirlineAd") .setCategoryExclusion("TrainAd") .addService(googletag.pubads()); slot.getCategoryExclusions(); // Returns ['AirlineAd', 'TrainAd'].
JavaScript (legacy)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setCategoryExclusion("AirlineAd") .setCategoryExclusion("TrainAd") .addService(googletag.pubads()); slot.getCategoryExclusions(); // Returns ['AirlineAd', 'TrainAd'].
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setCategoryExclusion("AirlineAd") .setCategoryExclusion("TrainAd") .addService(googletag.pubads()); slot.getCategoryExclusions(); // Returns ['AirlineAd', 'TrainAd'].
برمی گرداند | |
---|---|
string [] | The ad category exclusion labels for this slot, or an empty array if none have been set. |
getConfig
getConfig ( keys : string | string [] ) : Pick < SlotSettingsConfig , "adsenseAttributes" | "targeting" | "categoryExclusion" >
Not all
setConfig()
properties are supported by this method. Supported properties are:- مثال
جاوا اسکریپت
const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div"); // Get the value of the `targeting` setting. const targetingConfig = slot.getConfig("targeting"); // Get the value of the `adsenseAttributes` and `categoryExclusion` settings. const config = slot.getConfig(["adsenseAttributes", "categoryExclusion"]);
JavaScript (legacy)
var slot = googletag.defineSlot("/1234567/sports", [160, 600], "div"); // Get the value of the `targeting` setting. var targetingConfig = slot.getConfig("targeting"); // Get the value of the `adsenseAttributes` and `categoryExclusion` settings. var config = slot.getConfig(["adsenseAttributes", "categoryExclusion"]);
TypeScript
const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div")!; // Get the value of the `targeting` setting. const targetingConfig = slot.getConfig("targeting"); // Get the value of the `adsenseAttributes` and `categoryExclusion` settings. const config = slot.getConfig(["adsenseAttributes", "categoryExclusion"]);
پارامترها | |
---|---|
keys : string | string [] | The keys of the configuration options to get. |
برمی گرداند | |
---|---|
Pick < SlotSettingsConfig , "adsenseAttributes" | "targeting" | "categoryExclusion" > | The configuration options for the slot. |
getResponseInformation
getResponseInformation ( ) : ResponseInformation
null
will be returned. برمی گرداند | |
---|---|
ResponseInformation | The latest ad response information, or null if the slot has no ad. |
getSlotElementId
getSlotElementId ( ) : string
div
provided when the slot was defined.- مثال
جاوا اسکریپت
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); slot.getSlotElementId(); // Returns 'div'.
JavaScript (legacy)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); slot.getSlotElementId(); // Returns 'div'.
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); slot.getSlotElementId(); // Returns 'div'.
برمی گرداند | |
---|---|
string | Slot div ID. |
getTargeting
getTargeting ( key : string ) : string []
- مثال
جاوا اسکریپت
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setTargeting("allow_expandable", "true") .addService(googletag.pubads()); slot.getTargeting("allow_expandable"); // Returns ['true']. slot.getTargeting("age"); // Returns [] (empty array).
JavaScript (legacy)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setTargeting("allow_expandable", "true") .addService(googletag.pubads()); slot.getTargeting("allow_expandable"); // Returns ['true']. slot.getTargeting("age"); // Returns [] (empty array).
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setTargeting("allow_expandable", "true") .addService(googletag.pubads()); slot.getTargeting("allow_expandable"); // Returns ['true']. slot.getTargeting("age"); // Returns [] (empty array).
پارامترها | |
---|---|
key : string | The targeting key to look for. |
برمی گرداند | |
---|---|
string [] | The values associated with this key, or an empty array if there is no such key. |
getTargetingKeys
getTargetingKeys ( ) : string []
- مثال
جاوا اسکریپت
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setTargeting("allow_expandable", "true") .setTargeting("interests", ["sports", "music"]) .addService(googletag.pubads()); slot.getTargetingKeys(); // Returns ['interests', 'allow_expandable'].
JavaScript (legacy)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setTargeting("allow_expandable", "true") .setTargeting("interests", ["sports", "music"]) .addService(googletag.pubads()); slot.getTargetingKeys(); // Returns ['interests', 'allow_expandable'].
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setTargeting("allow_expandable", "true") .setTargeting("interests", ["sports", "music"]) .addService(googletag.pubads()); slot.getTargetingKeys(); // Returns ['interests', 'allow_expandable'].
برمی گرداند | |
---|---|
string [] | Array of targeting keys. Ordering is undefined. |
مجموعه
set ( key : string , value : string ) : Slot
Calling this method more than once for the same key will override previously set values for that key. All values must be set before calling
display
or refresh
.- مثال
جاوا اسکریپت
// Setting an attribute on a single ad slot. googletag .defineSlot("/1234567/sports", [160, 600], "div") .set("adsense_background_color", "#FFFFFF") .addService(googletag.pubads());
JavaScript (legacy)
// Setting an attribute on a single ad slot. googletag .defineSlot("/1234567/sports", [160, 600], "div") .set("adsense_background_color", "#FFFFFF") .addService(googletag.pubads());
TypeScript
// Setting an attribute on a single ad slot. googletag .defineSlot("/1234567/sports", [160, 600], "div")! .set("adsense_background_color", "#FFFFFF") .addService(googletag.pubads());
- همچنین ببینید
پارامترها | |
---|---|
key : string | The name of the attribute. |
value : string | Attribute value. |
برمی گرداند | |
---|---|
Slot | The slot object on which the method was called. |
setCategoryExclusion
setCategoryExclusion ( categoryExclusion : string ) : Slot
- مثال
جاوا اسکریپت
// Label = AirlineAd googletag .defineSlot("/1234567/sports", [160, 600], "div") .setCategoryExclusion("AirlineAd") .addService(googletag.pubads());
JavaScript (legacy)
// Label = AirlineAd googletag .defineSlot("/1234567/sports", [160, 600], "div") .setCategoryExclusion("AirlineAd") .addService(googletag.pubads());
TypeScript
// Label = AirlineAd googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setCategoryExclusion("AirlineAd") .addService(googletag.pubads());
- همچنین ببینید
پارامترها | |
---|---|
categoryExclusion : string | The ad category exclusion label to add. |
برمی گرداند | |
---|---|
Slot | The slot object on which the method was called. |
setClickUrl
setClickUrl ( value : string ) : Slot
The Google Ad Manager servers still record a click even if the click URL is replaced. Any landing page URL associated with the creative that is served is appended to the provided value. Subsequent calls overwrite the value. This works only for non-SRA requests.
- مثال
جاوا اسکریپت
googletag .defineSlot("/1234567/sports", [160, 600], "div") .setClickUrl("http://www.example.com?original_click_url=") .addService(googletag.pubads());
JavaScript (legacy)
googletag .defineSlot("/1234567/sports", [160, 600], "div") .setClickUrl("http://www.example.com?original_click_url=") .addService(googletag.pubads());
TypeScript
googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setClickUrl("http://www.example.com?original_click_url=") .addService(googletag.pubads());
پارامترها | |
---|---|
value : string | The click URL to set. |
برمی گرداند | |
---|---|
Slot | The slot object on which the method was called. |
setCollapseEmptyDiv
setCollapseEmptyDiv ( collapse : boolean , collapseBeforeAdFetch ?: boolean ) : Slot
div
should be hidden when there is no ad in the slot. This overrides the service-level settings.- مثال
جاوا اسکریپت
googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setCollapseEmptyDiv(true, true) .addService(googletag.pubads()); // The above will cause the div for this slot to be collapsed // when the page is loaded, before ads are requested. googletag .defineSlot("/1234567/sports", [160, 600], "div-2") .setCollapseEmptyDiv(true) .addService(googletag.pubads()); // The above will cause the div for this slot to be collapsed // only after GPT detects that no ads are available for the slot.
JavaScript (legacy)
googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setCollapseEmptyDiv(true, true) .addService(googletag.pubads()); // The above will cause the div for this slot to be collapsed // when the page is loaded, before ads are requested. googletag .defineSlot("/1234567/sports", [160, 600], "div-2") .setCollapseEmptyDiv(true) .addService(googletag.pubads()); // The above will cause the div for this slot to be collapsed // only after GPT detects that no ads are available for the slot.
TypeScript
googletag .defineSlot("/1234567/sports", [160, 600], "div-1")! .setCollapseEmptyDiv(true, true) .addService(googletag.pubads()); // The above will cause the div for this slot to be collapsed // when the page is loaded, before ads are requested. googletag .defineSlot("/1234567/sports", [160, 600], "div-2")! .setCollapseEmptyDiv(true) .addService(googletag.pubads()); // The above will cause the div for this slot to be collapsed // only after GPT detects that no ads are available for the slot.
- همچنین ببینید
پارامترها | |
---|---|
collapse : boolean | Whether to collapse the slot if no ad is returned. |
| Whether to collapse the slot even before an ad is fetched. Ignored if collapse is not true . |
برمی گرداند | |
---|---|
Slot | The slot object on which the method was called. |
setConfig
setConfig ( slotConfig : SlotSettingsConfig ) : void
پارامترها | |
---|---|
slotConfig : SlotSettingsConfig | The configuration object. |
setForceSafeFrame
setForceSafeFrame ( forceSafeFrame : boolean ) : Slot
Please keep the following things in mind while using this API:
- This setting will only take effect for subsequent ad requests made for the respective slots.
- The slot level setting, if specified, will always override the page level setting.
- If set to
true
(at slot-level or page level), the ad will always be rendered using a SafeFrame container independent of the choice made in the Google Ad Manager UI. - However, if set to
false
or left unspecified, the ad will be rendered using a SafeFrame container depending on the type of creative and the selection made in the Google Ad Manager UI. - This API should be used with caution as it could impact the behaviour of creatives that attempt to break out of their iFrames or rely on them being rendered directly in a publishers page.
- مثال
جاوا اسکریپت
googletag .defineSlot("/1234567/sports", [160, 600], "div") .setForceSafeFrame(true) .addService(googletag.pubads());
JavaScript (legacy)
googletag .defineSlot("/1234567/sports", [160, 600], "div") .setForceSafeFrame(true) .addService(googletag.pubads());
TypeScript
googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setForceSafeFrame(true) .addService(googletag.pubads());
- همچنین ببینید
پارامترها | |
---|---|
forceSafeFrame : boolean | true to force all ads in this slot to be rendered in SafeFrames and false to opt-out of a page-level setting (if present). Setting this to false when not specified at the page-level won't change anything. |
برمی گرداند | |
---|---|
Slot | The slot object on which the method was called. |
setSafeFrameConfig
setSafeFrameConfig ( config : SafeFrameConfig ) : Slot
These slot-level preferences, if specified, will override any page-level preferences.
- مثال
جاوا اسکریپت
googletag.pubads().setForceSafeFrame(true); // The following slot will have a sandboxed safeframe that only // disallows top-level navigation. googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setSafeFrameConfig({ sandbox: true }) .addService(googletag.pubads()); // The following slot will inherit page-level settings. googletag.defineSlot("/1234567/news", [160, 600], "div-2").addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
JavaScript (legacy)
googletag.pubads().setForceSafeFrame(true); // The following slot will have a sandboxed safeframe that only // disallows top-level navigation. googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setSafeFrameConfig({ sandbox: true }) .addService(googletag.pubads()); // The following slot will inherit page-level settings. googletag.defineSlot("/1234567/news", [160, 600], "div-2").addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
TypeScript
googletag.pubads().setForceSafeFrame(true); // The following slot will have a sandboxed safeframe that only // disallows top-level navigation. googletag .defineSlot("/1234567/sports", [160, 600], "div-1")! .setSafeFrameConfig({ sandbox: true }) .addService(googletag.pubads()); // The following slot will inherit page-level settings. googletag.defineSlot("/1234567/news", [160, 600], "div-2")!.addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
- همچنین ببینید
پارامترها | |
---|---|
config : SafeFrameConfig | The configuration object. |
برمی گرداند | |
---|---|
Slot | The slot object on which the method was called. |
setTargeting
setTargeting ( key : string , value : string | string [] ) : Slot
- مثال
جاوا اسکریپت
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Example with a single value for a key. slot.setTargeting("allow_expandable", "true"); // Example with multiple values for a key inside in an array. slot.setTargeting("interests", ["sports", "music"]);
JavaScript (legacy)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Example with a single value for a key. slot.setTargeting("allow_expandable", "true"); // Example with multiple values for a key inside in an array. slot.setTargeting("interests", ["sports", "music"]);
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); // Example with a single value for a key. slot.setTargeting("allow_expandable", "true"); // Example with multiple values for a key inside in an array. slot.setTargeting("interests", ["sports", "music"]);
- همچنین ببینید
پارامترها | |
---|---|
key : string | Targeting parameter key. |
value : string | string [] | Targeting parameter value or array of values. |
برمی گرداند | |
---|---|
Slot | The slot object on which the method was called. |
updateTargetingFromMap
updateTargetingFromMap ( map : {
[ adUnitPath : string ] : string | string [] ;
} ) : Slot
یادداشت ها:
- In case of overwriting, only the last value will be kept.
- If the value is an array, any previous value will be overwritten, not merged.
- Values set here will overwrite targeting parameters set at the service-level.
- مثال
جاوا اسکریپت
const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div"); slot.updateTargetingFromMap({ color: "red", interests: ["sports", "music", "movies"], });
JavaScript (legacy)
var slot = googletag.defineSlot("/1234567/sports", [160, 600], "div"); slot.updateTargetingFromMap({ color: "red", interests: ["sports", "music", "movies"], });
TypeScript
const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div")!; slot.updateTargetingFromMap({ color: "red", interests: ["sports", "music", "movies"], });
پارامترها | |
---|---|
map : { | Targeting parameter key:value map. |
برمی گرداند | |
---|---|
Slot | The slot object on which the method was called. |
googletag.config
رابط ها | |
---|---|
Ad Expansion Config | Settings to control ad expansion. |
Ad Sense Attributes Config | Settings to control the behavior of AdSense ads. |
Component Auction Config | An object representing a single component auction in a on-device ad auction. |
Interstitial Config | An object which defines the behavior of a single interstitial ad slot. |
Lazy Load Config | Settings to control the use of lazy loading in GPT. |
Page Settings Config | Main configuration interface for page-level settings. |
Privacy Treatments Config | Settings to control publisher privacy treatments. |
Publisher Provided Signals Config | Publisher provided signals (PPS) configuration object. |
Safe Frame Config | Settings to control SafeFrame in GPT. |
Slot Settings Config | Main configuration interface for slot-level settings. |
Taxonomy Data | An object containing the values for a single Taxonomy . |
Video Ads Config | Settings to configure video ad related settings. |
Type Aliases | |
---|---|
Interstitial Trigger | Supported interstitial ad triggers. |
Privacy Treatment | Supported publisher privacy treatments. |
Taxonomy | Supported taxonomies for publisher provided signals (PPS) . |
Type Aliases
InterstitialTrigger
InterstitialTrigger : "unhideWindow" | "navBar"
PrivacyTreatment
PrivacyTreatment : "disablePersonalization"
طبقه بندی
Taxonomy : "IAB_AUDIENCE_1_1" | "IAB_CONTENT_2_2"
- همچنین ببینید
googletag.config.AdExpansionConfig
خواص | |
---|---|
enabled ? | Whether ad expansion is enabled or disabled. |
- مثال
جاوا اسکریپت
// Enable ad slot expansion across the entire page. googletag.setConfig({ adExpansion: { enabled: true }, });
JavaScript (legacy)
// Enable ad slot expansion across the entire page. googletag.setConfig({ adExpansion: { enabled: true }, });
TypeScript
// Enable ad slot expansion across the entire page. googletag.setConfig({ adExpansion: { enabled: true }, });
خواص
Optional
enabled
enabled ?: boolean
Setting this value overrides the default configured in Google Ad Manager.
googletag.config.AdSenseAttributesConfig
These attributes can be used to override server-side settings on a per-request basis.
خواص | |
---|---|
adsense _ad _format ? | AdSense ad format. |
adsense _channel _ids ? | AdSense channel IDs. |
adsense _test _mode ? | Whether or not test mode is enabled. |
document _language ? | Language of the page on which ads are displayed. |
page _url ? | URL of the page on which ads are displayed. |
خواص
Optional
adsense_ad_format
adsense_ad_format ?: "120x240_as" | "120x600_as" | "125x125_as" | "160x600_as" | "180x150_as" | "200x200_as" | "234x60_as" | "250x250_as" | "300x250_as" | "336x280_as" | "468x60_as" | "728x90_as"
Optional
adsense_channel_ids
adsense_channel_ids ?: string
Allowed values are channel IDs separated by '+'.
Example:
271828183+314159265
- همچنین ببینید
Optional
adsense_test_mode
adsense_test_mode ?: "on"
When set to
on
, ads are marked as test-only, and won't be included in counting or billing. This setting must be unset for production, non-test traffic. Optional
document_language
document_language ?: string
Allowed values are valid ISO 639-1 language codes.
Example:
en
- همچنین ببینید
Optional
page_url
page_url ?: string
Allowed values are valid URLs.
Example:
http://www.example.com
googletag.config.ComponentAuctionConfig
خواص | |
---|---|
auction Config | An auction configuration object for this component auction. |
config Key | The configuration key associated with this component auction. |
- همچنین ببینید
خواص
auctionConfig
auctionConfig : {
auctionSignals ?: unknown ;
decisionLogicURL : string ;
interestGroupBuyers ?: string [] ;
perBuyerExperimentGroupIds ?: {
[ buyer : string ] : number ;
} ;
perBuyerGroupLimits ?: {
[ buyer : string ] : number ;
} ;
perBuyerSignals ?: {
[ buyer : string ] : unknown ;
} ;
perBuyerTimeouts ?: {
[ buyer : string ] : number ;
} ;
seller : string ;
sellerExperimentGroupId ?: number ;
sellerSignals ?: unknown ;
sellerTimeout ?: number ;
trustedScoringSignalsURL ?: string ;
}
If this value is set to
null
, any existing configuration for the specified configKey
will be deleted.- مثال
جاوا اسکریپت
const componentAuctionConfig = { // Seller URL should be https and the same as decisionLogicURL's origin seller: "https://testSeller.com", decisionLogicURL: "https://testSeller.com/ssp/decision-logic.js", interestGroupBuyers: ["https://example-buyer.com"], auctionSignals: { auction_signals: "auction_signals" }, sellerSignals: { seller_signals: "seller_signals" }, perBuyerSignals: { // listed on interestGroupBuyers "https://example-buyer.com": { per_buyer_signals: "per_buyer_signals", }, }, }; const auctionSlot = googletag.defineSlot("/1234567/example", [160, 600]); // To add configKey to the component auction: auctionSlot.setConfig({ componentAuction: [ { configKey: "https://testSeller.com", auctionConfig: componentAuctionConfig, }, ], }); // To remove configKey from the component auction: auctionSlot.setConfig({ componentAuction: [ { configKey: "https://testSeller.com", auctionConfig: null, }, ], });
JavaScript (legacy)
var componentAuctionConfig = { // Seller URL should be https and the same as decisionLogicURL's origin seller: "https://testSeller.com", decisionLogicURL: "https://testSeller.com/ssp/decision-logic.js", interestGroupBuyers: ["https://example-buyer.com"], auctionSignals: { auction_signals: "auction_signals" }, sellerSignals: { seller_signals: "seller_signals" }, perBuyerSignals: { // listed on interestGroupBuyers "https://example-buyer.com": { per_buyer_signals: "per_buyer_signals", }, }, }; var auctionSlot = googletag.defineSlot("/1234567/example", [160, 600]); // To add configKey to the component auction: auctionSlot.setConfig({ componentAuction: [ { configKey: "https://testSeller.com", auctionConfig: componentAuctionConfig, }, ], }); // To remove configKey from the component auction: auctionSlot.setConfig({ componentAuction: [ { configKey: "https://testSeller.com", auctionConfig: null, }, ], });
TypeScript
const componentAuctionConfig = { // Seller URL should be https and the same as decisionLogicURL's origin seller: "https://testSeller.com", decisionLogicURL: "https://testSeller.com/ssp/decision-logic.js", interestGroupBuyers: ["https://example-buyer.com"], auctionSignals: { auction_signals: "auction_signals" }, sellerSignals: { seller_signals: "seller_signals" }, perBuyerSignals: { // listed on interestGroupBuyers "https://example-buyer.com": { per_buyer_signals: "per_buyer_signals", }, }, }; const auctionSlot = googletag.defineSlot("/1234567/example", [160, 600])!; // To add configKey to the component auction: auctionSlot.setConfig({ componentAuction: [ { configKey: "https://testSeller.com", auctionConfig: componentAuctionConfig, }, ], }); // To remove configKey from the component auction: auctionSlot.setConfig({ componentAuction: [ { configKey: "https://testSeller.com", auctionConfig: null, }, ], });
- همچنین ببینید
configKey
configKey : string
This value must be non-empty and should be unique. If two
ComponentAuctionConfig
objects share the same configKey value, the last to be set will overwrite prior configurations. googletag.config.InterstitialConfig
خواص | |
---|---|
require Storage Access ? | Whether local storage consent is required to display this interstitial ad. |
triggers ? | The interstitial trigger configuration for this interstitial ad. |
خواص
Optional
requireStorageAccess
requireStorageAccess ?: boolean
GPT uses local storage to enforce a frequency cap for interstitial ads. However, users who have not provided local storage consent are still eligible to be served interstitial ads. Setting this property to
true
opts out of the default behavior, and ensures interstial ads are only shown to users who have provided local storage consent.- مثال
جاوا اسکریپت
// Opt out of showing interstitials to users // without local storage consent. const interstitialSlot = googletag.defineOutOfPageSlot( "/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL, ); interstitialSlot.setConfig({ interstitial: { requireStorageAccess: true, // defaults to false }, });
JavaScript (legacy)
// Opt out of showing interstitials to users // without local storage consent. var interstitialSlot = googletag.defineOutOfPageSlot( "/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL, ); interstitialSlot.setConfig({ interstitial: { requireStorageAccess: true, // defaults to false }, });
TypeScript
// Opt out of showing interstitials to users // without local storage consent. const interstitialSlot = googletag.defineOutOfPageSlot( "/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL, )!; interstitialSlot.setConfig({ interstitial: { requireStorageAccess: true, // defaults to false }, });
- همچنین ببینید
Optional
triggers
triggers ?: Partial < Record < InterstitialTrigger , boolean > >
Setting the value of an interstitial trigger to
true
will enable it and false
will disable it. This will override the default values configured in Google Ad Manager .- مثال
جاوا اسکریپت
// Define a GPT managed web interstitial ad slot. const interstitialSlot = googletag.defineOutOfPageSlot( "/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL, ); // Enable optional interstitial triggers. // Change this value to false to disable. const enableTriggers = true; interstitialSlot.setConfig({ interstitial: { triggers: { navBar: enableTriggers, unhideWindow: enableTriggers, }, }, });
JavaScript (legacy)
// Define a GPT managed web interstitial ad slot. var interstitialSlot = googletag.defineOutOfPageSlot( "/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL, ); // Enable optional interstitial triggers. // Change this value to false to disable. var enableTriggers = true; interstitialSlot.setConfig({ interstitial: { triggers: { navBar: enableTriggers, unhideWindow: enableTriggers, }, }, });
TypeScript
// Define a GPT managed web interstitial ad slot. const interstitialSlot = googletag.defineOutOfPageSlot( "/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL, )!; // Enable optional interstitial triggers. // Change this value to false to disable. const enableTriggers = true; interstitialSlot.setConfig({ interstitial: { triggers: { navBar: enableTriggers, unhideWindow: enableTriggers, }, }, });
- همچنین ببینید
googletag.config.LazyLoadConfig
خواص | |
---|---|
fetch Margin Percent ? | The minimum distance from the current viewport a slot must be before we request an ad, expressed as a percentage of viewport size. |
mobile Scaling ? | A multiplier applied to margins on mobile devices. |
render Margin Percent ? | The minimum distance from the current viewport a slot must be before we render an ad, expressed as a percentage of viewport size. |
- همچنین ببینید
خواص
Optional
fetchMarginPercent
fetchMarginPercent ?: number
Used in conjunction with renderMarginPercent , this setting allows for prefetching an ad, but waiting to render and download other subresources. As such, this value should always be greater than or equal to renderMarginPercent .
A value of
0
means "when the slot enters the viewport", 100
means "when the ad is 1 viewport away", and so on. Optional
mobileScaling
mobileScaling ?: number
This allows for different margins on mobile vs. desktop, where viewport sizes and scroll speeds may be different. For example, a value of 2.0 will multiply all margins by 2 on mobile devices, increasing the minimum distance a slot can be from the viewport before fetching and rendering.
Optional
renderMarginPercent
renderMarginPercent ?: number
Used in conjunction with fetchMarginPercent , this setting allows for prefetching an ad, but waiting to render and download other subresources. As such, this value should always be less than or equal to fetchMarginPercent .
A value of
0
means "when the slot enters the viewport", 100
means "when the ad is 1 viewport away", and so on. googletag.config.PageSettingsConfig
Allows setting multiple features with a single API call.
All properties listed below are examples and do not reflect actual features that utilize setConfig. For the set of features, see fields within the PageSettingsConfig type below.
مثال ها:
- Only features specified in the googletag.setConfig call are modified.
// Configure feature alpha. googletag.setConfig({ alpha: {...} }); // Configure feature bravo. Feature alpha is unchanged. googletag.setConfig({ bravo: {...} });
- All settings for a given feature are updated with each call to googletag.setConfig .
// Configure feature charlie to echo = 1, foxtrot = true. googletag.setConfig({ charlie: { echo: 1, foxtrot: true, } }); // Update feature charlie to echo = 2. Since foxtrot was not specified, // the value is cleared. googletag.setConfig({ charlie: { echo: 2 } });
- All settings for a feature can be cleared by passing
null
.// Configure features delta, golf, and hotel. googletag.setConfig({ delta: {...}, golf: {...}, hotel: {...}, }); // Feature delta and hotel are cleared, but feature golf remains set. googletag.setConfig({ delta: null, hotel: null, });
خواص | |
---|---|
ad Expansion ? | Settings to control ad expansion. |
adsense Attributes ? | Setting to configure AdSense attributes. |
ad Yield ? | منسوخ شده است. |
category Exclusion ? | Setting to configure ad category exclusions. |
centering ? | Setting to control the horizontal centering of ads. |
collapse Div ? | Setting to control the collapsing behavior of ad slots. |
disable Initial Load ? | Setting to control when ads are requested. |
lazy Load ? | Settings to control the use of lazy loading in GPT. |
location ? | Setting to geo-target line items to geographic locations. |
pps ? | Settings to control publisher provided signals (PPS). |
privacy Treatments ? | Settings to control publisher privacy treatments. |
safe Frame ? | Settings to control the use of SafeFrame in GPT. |
single Request ? | Setting to enable or disable Single Request Architecture (SRA). |
targeting ? | Setting to control key-value targeting. |
thread Yield ? | Setting to control whether GPT should yield the JS thread when requesting and rendering creatives. |
video Ads ? | Settings to control video ads. |
خواص
Optional
adExpansion
adExpansion ?: AdExpansionConfig
Optional
adsenseAttributes
adsenseAttributes ?: AdSenseAttributesConfig
AdSense attributes configured via this setting will apply to all ad slots on the page. This setting may be called multiple times to define multiple attribute values, or overwrite existing values.
AdSense attribute changes only apply to ads requested after this method has been called. For that reason, it is recommended to call this method before any calls to googletag.display or PubAdsService.refresh .
- مثال
جاوا اسکریپت
// Set the document language and page URL. googletag.setConfig({ adsenseAttributes: { document_language: "en", page_url: "http://www.example.com" }, }); // Clear the page URL only. googletag.setConfig({ adsenseAttributes: { page_url: null } }); // Clear all AdSense attributes. googletag.setConfig({ adsenseAttributes: null });
JavaScript (legacy)
// Set the document language and page URL. googletag.setConfig({ adsenseAttributes: { document_language: "en", page_url: "http://www.example.com" }, }); // Clear the page URL only. googletag.setConfig({ adsenseAttributes: { page_url: null } }); // Clear all AdSense attributes. googletag.setConfig({ adsenseAttributes: null });
TypeScript
// Set the document language and page URL. googletag.setConfig({ adsenseAttributes: { document_language: "en", page_url: "http://www.example.com" }, }); // Clear the page URL only. googletag.setConfig({ adsenseAttributes: { page_url: null } }); // Clear all AdSense attributes. googletag.setConfig({ adsenseAttributes: null });
Optional
adYield
adYield ?: "DISABLED" | "ENABLED_ALL_SLOTS"
Optional
categoryExclusion
categoryExclusion ?: string []
- مثال
جاوا اسکریپت
// Label = AirlineAd. googletag.setConfig({ categoryExclusion: ["AirlineAd"] }); // Clearing category exclusion setting. googletag.setConfig({ categoryExclusion: null });
JavaScript (legacy)
// Label = AirlineAd. googletag.setConfig({ categoryExclusion: ["AirlineAd"] }); // Clearing category exclusion setting. googletag.setConfig({ categoryExclusion: null });
TypeScript
// Label = AirlineAd. googletag.setConfig({ categoryExclusion: ["AirlineAd"] }); // Clearing category exclusion setting. googletag.setConfig({ categoryExclusion: null });
- همچنین ببینید
Optional
centering
centering ?: boolean
Horizontal centering changes only apply to ads requested after this method has been called. For that reason, it is recommended to call this method before any calls to googletag.display or PubAdsService.refresh .
- مثال
جاوا اسکریپت
// Make ads centered. googletag.setConfig({ centering: true }); // Clear the centering setting. googletag.setConfig({ centering: null });
JavaScript (legacy)
// Make ads centered. googletag.setConfig({ centering: true }); // Clear the centering setting. googletag.setConfig({ centering: null });
TypeScript
// Make ads centered. googletag.setConfig({ centering: true }); // Clear the centering setting. googletag.setConfig({ centering: null });
Optional
collapseDiv
collapseDiv ?: "DISABLED" | "BEFORE_FETCH" | "ON_NO_FILL"
A collapsed ad slot does not take up any space on the page.
Supported values:
-
null
(default): The slot will not be collapsed. -
DISABLED
: The slot will not collapse, whether or not an ad is returned. -
BEFORE_FETCH
: The slot will start out collapsed, and expand when an ad is returned. -
ON_NO_FILL
: The slot will start out expanded, and collapse if no ad is returned.
- مثال
جاوا اسکریپت
// Collapse the div for this slot if no ad is returned. googletag.setConfig({ collapseDiv: "ON_NO_FILL" }); // Collapse the div for this slot by default, and expand only // if an ad is returned. googletag.setConfig({ collapseDiv: "BEFORE_FETCH" }); // Do not collapse the div for this slot. googletag.setConfig({ collapseDiv: "DISABLED" }); // Clear the collapse setting. googletag.setConfig({ collapseDiv: null });
JavaScript (legacy)
// Collapse the div for this slot if no ad is returned. googletag.setConfig({ collapseDiv: "ON_NO_FILL" }); // Collapse the div for this slot by default, and expand only // if an ad is returned. googletag.setConfig({ collapseDiv: "BEFORE_FETCH" }); // Do not collapse the div for this slot. googletag.setConfig({ collapseDiv: "DISABLED" }); // Clear the collapse setting. googletag.setConfig({ collapseDiv: null });
TypeScript
// Collapse the div for this slot if no ad is returned. googletag.setConfig({ collapseDiv: "ON_NO_FILL" }); // Collapse the div for this slot by default, and expand only // if an ad is returned. googletag.setConfig({ collapseDiv: "BEFORE_FETCH" }); // Do not collapse the div for this slot. googletag.setConfig({ collapseDiv: "DISABLED" }); // Clear the collapse setting. googletag.setConfig({ collapseDiv: null });
- همچنین ببینید
Optional
disableInitialLoad
disableInitialLoad ?: boolean
By default, the googletag.display method both registers ad slots and requests ads for them. However, there are times when it may be preferable to separate these actions, in order to more precisely control when ad content is loaded.
By enabling this setting, ads will not be requested for registered slots when the
display()
method is called. Instead, a separate call to PubAdsService.refresh must be made to initiate an ad request.This method must be called before calling googletag.enableServices .
- مثال
جاوا اسکریپت
// Prevent requesting ads when `display()` is called. googletag.setConfig({ disableInitialLoad: true });
JavaScript (legacy)
// Prevent requesting ads when `display()` is called. googletag.setConfig({ disableInitialLoad: true });
TypeScript
// Prevent requesting ads when `display()` is called. googletag.setConfig({ disableInitialLoad: true });
- همچنین ببینید
Optional
lazyLoad
lazyLoad ?: LazyLoadConfig
Lazy loading is a technique to delay the requesting and rendering of ads until they approach the user's viewport. For a more detailed example, see the Lazy loading sample.
Note: If
singleRequest
is enabled, lazy fetching only works when all slots are outside the fetch margin.Any lazy load settings which are not specified when calling
setConfig()
will use a default value set by Google. These defaults may be tuned over time. To disable a particular setting, set the value to null
.- مثال
جاوا اسکریپت
// Enable lazy loading. googletag.setConfig({ lazyLoad: { // Fetch slots within 5 viewports. fetchMarginPercent: 500, // Render slots within 2 viewports. renderMarginPercent: 200, // Double the above values on mobile. mobileScaling: 2.0, }, }); // Clear fetch margin only. googletag.setConfig({ lazyLoad: { fetchMarginPercent: null }, }); // Clear all lazy loading settings. googletag.setConfig({ lazyLoad: null });
JavaScript (legacy)
// Enable lazy loading. googletag.setConfig({ lazyLoad: { // Fetch slots within 5 viewports. fetchMarginPercent: 500, // Render slots within 2 viewports. renderMarginPercent: 200, // Double the above values on mobile. mobileScaling: 2.0, }, }); // Clear fetch margin only. googletag.setConfig({ lazyLoad: { fetchMarginPercent: null }, }); // Clear all lazy loading settings. googletag.setConfig({ lazyLoad: null });
TypeScript
// Enable lazy loading. googletag.setConfig({ lazyLoad: { // Fetch slots within 5 viewports. fetchMarginPercent: 500, // Render slots within 2 viewports. renderMarginPercent: 200, // Double the above values on mobile. mobileScaling: 2.0, }, }); // Clear fetch margin only. googletag.setConfig({ lazyLoad: { fetchMarginPercent: null }, }); // Clear all lazy loading settings. googletag.setConfig({ lazyLoad: null });
Optional
location
location ?: string
- مثال
جاوا اسکریپت
// Geo-target line items to US postal code 10001. googletag.setConfig({ location: "10001,US" }); // Clear the location setting. googletag.setConfig({ location: null });
JavaScript (legacy)
// Geo-target line items to US postal code 10001. googletag.setConfig({ location: "10001,US" }); // Clear the location setting. googletag.setConfig({ location: null });
TypeScript
// Geo-target line items to US postal code 10001. googletag.setConfig({ location: "10001,US" }); // Clear the location setting. googletag.setConfig({ location: null });
- همچنین ببینید
Optional
pps
Optional
privacyTreatments
privacyTreatments ?: PrivacyTreatmentsConfig
Optional
safeFrame
safeFrame ?: SafeFrameConfig
Values configured via this setting will apply to all ad slots on the page. Individual ad slots may override these values via SlotSettingsConfig.safeFrame .
- مثال
جاوا اسکریپت
// Force SafeFrame for all ads on the page. googletag.setConfig({ safeFrame: { forceSafeFrame: true }, }); // Configure SafeFrame to allow overlay expansion. googletag.setConfig({ safeFrame: { allowOverlayExpansion: true }, }); // Clear forceSafeFrame setting. googletag.setConfig({ safeFrame: { forceSafeFrame: null }, }); // Clear all SafeFrame settings. googletag.setConfig({ safeFrame: null });
JavaScript (legacy)
// Force SafeFrame for all ads on the page. googletag.setConfig({ safeFrame: { forceSafeFrame: true }, }); // Configure SafeFrame to allow overlay expansion. googletag.setConfig({ safeFrame: { allowOverlayExpansion: true }, }); // Clear forceSafeFrame setting. googletag.setConfig({ safeFrame: { forceSafeFrame: null }, }); // Clear all SafeFrame settings. googletag.setConfig({ safeFrame: null });
TypeScript
// Force SafeFrame for all ads on the page. googletag.setConfig({ safeFrame: { forceSafeFrame: true }, }); // Configure SafeFrame to allow overlay expansion. googletag.setConfig({ safeFrame: { allowOverlayExpansion: true }, }); // Clear forceSafeFrame setting. googletag.setConfig({ safeFrame: { forceSafeFrame: null }, }); // Clear all SafeFrame settings. googletag.setConfig({ safeFrame: null });
Optional
singleRequest
singleRequest ?: boolean
When SRA is enabled, all ad slots defined prior to a googletag.display or PubAdsService.refresh call will be batched into a single ad request. This provides performance benefits, but is also necessary to ensure roadblocks and competetive exclusions are honored.
When SRA is disabled, each ad slot is requested individually. This is the default behavior of GPT.
This method must be called prior to calling googletag.enableServices .
- مثال
جاوا اسکریپت
// Enable Single Request Architecture. googletag.setConfig({ singleRequest: true });
JavaScript (legacy)
// Enable Single Request Architecture. googletag.setConfig({ singleRequest: true });
TypeScript
// Enable Single Request Architecture. googletag.setConfig({ singleRequest: true });
Optional
targeting
targeting ?: Record < string , string | string [] >
Targeting configured via this setting will apply to all ad slots on the page. This setting may be called multiple times to define multiple targeting key-values, or overwrite existing values. Targeting keys are defined in your Google Ad Manager account.
- مثال
جاوا اسکریپت
// Setting a single targeting key-value. googletag.setConfig({ targeting: { interests: "sports" } }); // Setting multiple values for a single targeting key googletag.setConfig({ targeting: { interests: ["sports", "music"] } }); // Setting multiple targeting key-values at once. googletag.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } }); // Clearing a single targeting key. googletag.setConfig({ targeting: { interests: null } });
JavaScript (legacy)
// Setting a single targeting key-value. googletag.setConfig({ targeting: { interests: "sports" } }); // Setting multiple values for a single targeting key googletag.setConfig({ targeting: { interests: ["sports", "music"] } }); // Setting multiple targeting key-values at once. googletag.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } }); // Clearing a single targeting key. googletag.setConfig({ targeting: { interests: null } });
TypeScript
// Setting a single targeting key-value. googletag.setConfig({ targeting: { interests: "sports" } }); // Setting multiple values for a single targeting key googletag.setConfig({ targeting: { interests: ["sports", "music"] } }); // Setting multiple targeting key-values at once. googletag.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } }); // Clearing a single targeting key. googletag.setConfig({ targeting: { interests: null } });
- همچنین ببینید
Optional
threadYield
threadYield ?: "DISABLED" | "ENABLED_ALL_SLOTS"
GPT will yield only for browsers that support the Scheduler.postTask or Scheduler.yield API.
Supported values:
-
null
(default): GPT will yield the JS thread for slots outside of the viewport. -
ENABLED_ALL_SLOTS
: GPT will yield the JS thread for all slots regardless of whether the slot is within the viewport. -
DISABLED
: GPT will not yield the JS thread.
- مثال
جاوا اسکریپت
// Disable yielding. googletag.setConfig({ threadYield: "DISABLED" }); // Enable yielding for all slots. googletag.setConfig({ threadYield: "ENABLED_ALL_SLOTS" }); // Enable yielding only for slots outside of the viewport (default). googletag.setConfig({ threadYield: null });
JavaScript (legacy)
// Disable yielding. googletag.setConfig({ threadYield: "DISABLED" }); // Enable yielding for all slots. googletag.setConfig({ threadYield: "ENABLED_ALL_SLOTS" }); // Enable yielding only for slots outside of the viewport (default). googletag.setConfig({ threadYield: null });
TypeScript
// Disable yielding. googletag.setConfig({ threadYield: "DISABLED" }); // Enable yielding for all slots. googletag.setConfig({ threadYield: "ENABLED_ALL_SLOTS" }); // Enable yielding only for slots outside of the viewport (default). googletag.setConfig({ threadYield: null });
- همچنین ببینید
Optional
videoAds
videoAds ?: VideoAdsConfig
- مثال
جاوا اسکریپت
// Enable video ads and set video content and content source IDs. googletag.setConfig({ videoAds: { enableVideoAds: true, videoContentId: "e1eGlRL7ju8", videoCmsId: "1234567", }, });
JavaScript (legacy)
// Enable video ads and set video content and content source IDs. googletag.setConfig({ videoAds: { enableVideoAds: true, videoContentId: "e1eGlRL7ju8", videoCmsId: "1234567", }, });
TypeScript
// Enable video ads and set video content and content source IDs. googletag.setConfig({ videoAds: { enableVideoAds: true, videoContentId: "e1eGlRL7ju8", videoCmsId: "1234567", }, });
- همچنین ببینید
googletag.config.PrivacyTreatmentsConfig
خواص | |
---|---|
treatments | An array of publisher privacy treatments to enable. |
خواص
درمان ها
treatments : "disablePersonalization" []
- مثال
جاوا اسکریپت
// Disable personalization across the entire page. googletag.setConfig({ privacyTreatments: { treatments: ["disablePersonalization"] }, });
JavaScript (legacy)
// Disable personalization across the entire page. googletag.setConfig({ privacyTreatments: { treatments: ["disablePersonalization"] }, });
TypeScript
// Disable personalization across the entire page. googletag.setConfig({ privacyTreatments: { treatments: ["disablePersonalization"] }, });
googletag.config.PublisherProvidedSignalsConfig
خواص | |
---|---|
taxonomies | An object containing Taxonomy mappings or null to clear the config. |
- مثال
جاوا اسکریپت
googletag.setConfig({ pps: { taxonomies: { IAB_AUDIENCE_1_1: { values: ["6", "626"] }, // '6' = 'Demographic | Age Range | 30-34' // '626' = 'Interest | Sports | Darts' IAB_CONTENT_2_2: { values: ["48", "127"] }, // '48' = 'Books and Literature | Fiction' // '127' = 'Careers | Job Search' }, }, });
JavaScript (legacy)
googletag.setConfig({ pps: { taxonomies: { IAB_AUDIENCE_1_1: { values: ["6", "626"] }, // '6' = 'Demographic | Age Range | 30-34' // '626' = 'Interest | Sports | Darts' IAB_CONTENT_2_2: { values: ["48", "127"] }, // '48' = 'Books and Literature | Fiction' // '127' = 'Careers | Job Search' }, }, });
TypeScript
googletag.setConfig({ pps: { taxonomies: { IAB_AUDIENCE_1_1: { values: ["6", "626"] }, // '6' = 'Demographic | Age Range | 30-34' // '626' = 'Interest | Sports | Darts' IAB_CONTENT_2_2: { values: ["48", "127"] }, // '48' = 'Books and Literature | Fiction' // '127' = 'Careers | Job Search' }, }, });
خواص
taxonomies
taxonomies : Partial < Record < Taxonomy , TaxonomyData > >
googletag.config.SafeFrameConfig
خواص | |
---|---|
allow Overlay Expansion ? | Whether SafeFrame should allow ad content to expand by overlaying page content. |
allow Push Expansion ? | Whether SafeFrame should allow ad content to expand by pushing page content. |
force Safe Frame ? | Whether ad(s) should be forced to be rendered using a SafeFrame container. |
sandbox ? | Whether SafeFrame should use the HTML5 sandbox attribute to prevent top level navigation without user interaction. |
use Unique Domain ? | منسوخ شده است. Whether SafeFrame should use randomized subdomains for Reservation creatives. |
- همچنین ببینید
خواص
Optional
allowOverlayExpansion
allowOverlayExpansion ?: boolean
Optional
allowPushExpansion
allowPushExpansion ?: boolean
Optional
forceSafeFrame
forceSafeFrame ?: boolean
Optional
sandbox
sandbox ?: boolean
true
(cannot be forced to false
). Note that the sandbox attribute disables plugins (eg Flash). Optional
useUniqueDomain
useUniqueDomain ?: boolean
null
to clear the stored value.Note: this feature is enabled by default.
- همچنین ببینید
googletag.config.SlotSettingsConfig
Allows setting multiple features with a single API call for a single slot.
All properties listed below are examples and do not reflect actual features that utilize setConfig. For the set of features, see fields within the SlotSettingsConfig type below.
مثال ها:
- Only features specified in the Slot.setConfig call are modified.
const slot = googletag.defineSlot("/1234567/example", [160, 600]); // Configure feature alpha. slot.setConfig({ alpha: {...} }); // Configure feature bravo. Feature alpha is unchanged. slot.setConfig({ bravo: {...} });
- All settings for a given feature are updated with each call to Slot.setConfig .
// Configure feature charlie to echo = 1, foxtrot = true. slot.setConfig({ charlie: { echo: 1, foxtrot: true, } }); // Update feature charlie to echo = 2. Since foxtrot was not specified, // the value is cleared. slot.setConfig({ charlie: { echo: 2 } });
- All settings for a feature can be cleared by passing
null
.// Configure features delta, golf, and hotel. slot.setConfig({ delta: {...}, golf: {...}, hotel: {...}, }); // Feature delta and hotel are cleared, but feature golf remains set. slot.setConfig({ delta: null, hotel: null, });
خواص | |
---|---|
ad Expansion ? | Settings to configure ad expansion. |
adsense Attributes ? | Setting to configure AdSense attributes. |
category Exclusion ? | Setting to configure ad category exclusions. |
click Url ? | Setting to configure the URL to which users will be redirected after clicking on the ad. |
collapse Div ? | Setting to configure the collapsing behavior of the ad slot. |
component Auction ? | An array of component auctions to be included in an on-device ad auction. |
interstitial ? | Settings that configure interstitial ad slot behavior. |
safe Frame ? | Settings to configure the use of SafeFrame in GPT. |
targeting ? | Setting to configure key-value targeting. |
خواص
Optional
adExpansion
adExpansion ?: AdExpansionConfig
- همچنین ببینید
Optional
adsenseAttributes
adsenseAttributes ?: AdSenseAttributesConfig
AdSense attributes configured via this setting will only apply to the ad slot. This setting may be called multiple times to define multiple attribute values, or overwrite existing values.
AdSense attribute changes only apply to ads requested after this method has been called. For that reason, it is recommended to call this method before any calls to googletag.display or PubAdsService.refresh .
- مثال
جاوا اسکریپت
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Set the AdSense ad format and channel IDs. slot.setConfig({ adsenseAttributes: { adsense_ad_format: "120x240_as", adsense_channel_ids: "271828183+314159265", }, }); // Clear the AdSense channel IDs only. slot.setConfig({ adsenseAttributes: { adsense_channel_ids: null } }); // Clear all AdSense attributes. slot.setConfig({ adsenseAttributes: null });
JavaScript (legacy)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Set the AdSense ad format and channel IDs. slot.setConfig({ adsenseAttributes: { adsense_ad_format: "120x240_as", adsense_channel_ids: "271828183+314159265", }, }); // Clear the AdSense channel IDs only. slot.setConfig({ adsenseAttributes: { adsense_channel_ids: null } }); // Clear all AdSense attributes. slot.setConfig({ adsenseAttributes: null });
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); // Set the AdSense ad format and channel IDs. slot.setConfig({ adsenseAttributes: { adsense_ad_format: "120x240_as", adsense_channel_ids: "271828183+314159265", }, }); // Clear the AdSense channel IDs only. slot.setConfig({ adsenseAttributes: { adsense_channel_ids: null } }); // Clear all AdSense attributes. slot.setConfig({ adsenseAttributes: null });
Optional
categoryExclusion
categoryExclusion ?: string []
- مثال
جاوا اسکریپت
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Label = AirlineAd slot.setConfig({ categoryExclusion: ["AirlineAd"], }); // Clearing category exclusion setting. slot.setConfig({ categoryExclusion: null });
JavaScript (legacy)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Label = AirlineAd slot.setConfig({ categoryExclusion: ["AirlineAd"], }); // Clearing category exclusion setting. slot.setConfig({ categoryExclusion: null });
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); // Label = AirlineAd slot.setConfig({ categoryExclusion: ["AirlineAd"], }); // Clearing category exclusion setting. slot.setConfig({ categoryExclusion: null });
- همچنین ببینید
Optional
clickUrl
clickUrl ?: string
The Google Ad Manager servers still record a click even if the click URL is replaced. Any landing page URL associated with the creative that is served is appended to the provided value. Setting this value more than once will overwrite any previously configured value. Passing in
null
will clear the value.Note: This setting only applies to non-SRA requests .
- مثال
جاوا اسکریپت
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Sets the click URL to 'http://www.example.com?original_click_url='. slot.setConfig({ clickUrl: "http://www.example.com?original_click_url=", }); // Clears the click URL. slot.setConfig({ clickUrl: null, });
JavaScript (legacy)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Sets the click URL to 'http://www.example.com?original_click_url='. slot.setConfig({ clickUrl: "http://www.example.com?original_click_url=", }); // Clears the click URL. slot.setConfig({ clickUrl: null, });
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); // Sets the click URL to 'http://www.example.com?original_click_url='. slot.setConfig({ clickUrl: "http://www.example.com?original_click_url=", }); // Clears the click URL. slot.setConfig({ clickUrl: null, });
Optional
collapseDiv
collapseDiv ?: "DISABLED" | "BEFORE_FETCH" | "ON_NO_FILL"
A collapsed ad slot does not take up any space on the page.
Supported values:
-
null
(default): The slot will not be collapsed. -
DISABLED
: The slot will not collapse, whether or not an ad is returned. -
BEFORE_FETCH
: The slot will start out collapsed, and expand when an ad is returned. -
ON_NO_FILL
: The slot will start out expanded, and collapse if no ad is returned.
- مثال
جاوا اسکریپت
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Collapse the div for this slot if no ad is returned. slot.setConfig({ collapseDiv: "ON_NO_FILL", }); // Collapse the div for this slot by default, and expand only // if an ad is returned. slot.setConfig({ collapseDiv: "BEFORE_FETCH", }); // Do not collapse the div for this slot. slot.setConfig({ collapseDiv: "DISABLED", }); // Clear the collapse setting. slot.setConfig({ collapseDiv: null, });
JavaScript (legacy)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Collapse the div for this slot if no ad is returned. slot.setConfig({ collapseDiv: "ON_NO_FILL", }); // Collapse the div for this slot by default, and expand only // if an ad is returned. slot.setConfig({ collapseDiv: "BEFORE_FETCH", }); // Do not collapse the div for this slot. slot.setConfig({ collapseDiv: "DISABLED", }); // Clear the collapse setting. slot.setConfig({ collapseDiv: null, });
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); // Collapse the div for this slot if no ad is returned. slot.setConfig({ collapseDiv: "ON_NO_FILL", }); // Collapse the div for this slot by default, and expand only // if an ad is returned. slot.setConfig({ collapseDiv: "BEFORE_FETCH", }); // Do not collapse the div for this slot. slot.setConfig({ collapseDiv: "DISABLED", }); // Clear the collapse setting. slot.setConfig({ collapseDiv: null, });
- همچنین ببینید
Optional
componentAuction
componentAuction ?: ComponentAuctionConfig []
Optional
interstitial
interstitial ?: InterstitialConfig
- همچنین ببینید
Optional
safeFrame
safeFrame ?: SafeFrameConfig
Values configured via this setting will only apply to the ad slot, and override values set via PageSettingsConfig.safeFrame .
- مثال
جاوا اسکریپت
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Force SafeFrame for the slot. slot.setConfig({ safeFrame: { forceSafeFrame: true }, }); // Configure SafeFrame to allow overlay expansion for the slot. slot.setConfig({ safeFrame: { allowOverlayExpansion: true }, }); // Clear forceSafeFrame setting for the slot. slot.setConfig({ safeFrame: { forceSafeFrame: null }, }); // Clear all SafeFrame settings for the slot. slot.setConfig({ safeFrame: null });
JavaScript (legacy)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Force SafeFrame for the slot. slot.setConfig({ safeFrame: { forceSafeFrame: true }, }); // Configure SafeFrame to allow overlay expansion for the slot. slot.setConfig({ safeFrame: { allowOverlayExpansion: true }, }); // Clear forceSafeFrame setting for the slot. slot.setConfig({ safeFrame: { forceSafeFrame: null }, }); // Clear all SafeFrame settings for the slot. slot.setConfig({ safeFrame: null });
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); // Force SafeFrame for the slot. slot.setConfig({ safeFrame: { forceSafeFrame: true }, }); // Configure SafeFrame to allow overlay expansion for the slot. slot.setConfig({ safeFrame: { allowOverlayExpansion: true }, }); // Clear forceSafeFrame setting for the slot. slot.setConfig({ safeFrame: { forceSafeFrame: null }, }); // Clear all SafeFrame settings for the slot. slot.setConfig({ safeFrame: null });
Optional
targeting
targeting ?: Record < string , string | string [] >
Targeting configured via this setting will only apply to the ad slot. This setting may be called multiple times to define multiple targeting key-values, or overwrite existing values. Targeting keys are defined in your Google Ad Manager account.
- مثال
جاوا اسکریپت
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Setting a single targeting key-value. slot.setConfig({ targeting: { interests: "sports" } }); // Setting multiple values for a single targeting key. slot.setConfig({ targeting: { interests: ["sports", "music"] } }); // Setting multiple targeting key-values at once. slot.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } }); // Clearing a single targeting key. slot.setConfig({ targeting: { interests: null } }); // Clear all targeting keys. slot.setConfig({ targeting: null });
JavaScript (legacy)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Setting a single targeting key-value. slot.setConfig({ targeting: { interests: "sports" } }); // Setting multiple values for a single targeting key. slot.setConfig({ targeting: { interests: ["sports", "music"] } }); // Setting multiple targeting key-values at once. slot.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } }); // Clearing a single targeting key. slot.setConfig({ targeting: { interests: null } }); // Clear all targeting keys. slot.setConfig({ targeting: null });
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); // Setting a single targeting key-value. slot.setConfig({ targeting: { interests: "sports" } }); // Setting multiple values for a single targeting key. slot.setConfig({ targeting: { interests: ["sports", "music"] } }); // Setting multiple targeting key-values at once. slot.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } }); // Clearing a single targeting key. slot.setConfig({ targeting: { interests: null } }); // Clear all targeting keys. slot.setConfig({ targeting: null });
- همچنین ببینید
googletag.config.TaxonomyData
خواص | |
---|---|
values | A list of Taxonomy values. |
خواص
ارزش ها
values : readonly string []
googletag.config.VideoAdsConfig
خواص | |
---|---|
enable Video Ads | Whether videos ads will be present on the page. |
video Cms Id ? | The video content source ID. |
video Content Id ? | The video content ID. |
- همچنین ببینید
خواص
enableVideoAds
enableVideoAds : boolean
When set to
true
, this enables content exclusion constraints on display and video ads.If the video content is known, set videoContentId and videoCmsId to the values provided to the Google Ad Manager content ingestion service to utilize content exclusion for display ads.
Optional
videoCmsId
videoCmsId ?: string
This is a unique value assigned by the Google Ad Manager content ingestion service to identify the source of video content specified by videoContentId .
- همچنین ببینید
Optional
videoContentId
videoContentId ?: string
This is a unique value that identifies a particular video from the content source specified by videoCmsId . This value is assigned by the CMS that hosts your video content.
- همچنین ببینید
googletag.enums
شمارش ها | |
---|---|
Out Of Page Format | Out-of-page formats supported by GPT. |
Traffic Source | Traffic sources supported by GPT. |
شمارش ها
OutOfPageFormat
OutOfPageFormat
- همچنین ببینید
TrafficSource
TrafficSource
- همچنین ببینید
Enumeration Members | |
---|---|
ORGANIC | Direct URL entry, site search, or app download. |
PURCHASED | Traffic redirected from properties other than owned (acquired or otherwise incentivized activity). |
googletag.events
رابط ها | |
---|---|
Event | Base Interface for all GPT events. |
Event Type Map | This is a pseudo-type that maps an event name to its corresponding event object type for Service.addEventListener and Service.removeEventListener . |
Game Manual Interstitial Slot Closed Event | This event is fired when a game manual interstitial slot has been closed by the user. |
Game Manual Interstitial Slot Ready Event | This event is fired when a game manual interstitial slot is ready to be shown to the user. |
Impression Viewable Event | This event is fired when an impression becomes viewable, according to the Active View criteria . |
Rewarded Slot Closed Event | This event is fired when a rewarded ad slot is closed by the user. |
Rewarded Slot Granted Event | This event is fired when a reward is granted for viewing a rewarded ad . |
Rewarded Slot Ready Event | This event is fired when a rewarded ad is ready to be displayed. |
Slot Onload Event | This event is fired when the creative's iframe fires its load event. |
Slot Render Ended Event | This event is fired when the creative code is injected into a slot. |
Slot Requested Event | This event is fired when an ad has been requested for a particular slot. |
Slot Response Received | This event is fired when an ad response has been received for a particular slot. |
Slot Visibility Changed Event | This event is fired whenever the on-screen percentage of an ad slot's area changes. |
googletag.events.Event
خواص | |
---|---|
service Name | Name of the service that triggered the event. |
slot | The slot that triggered the event. |
- همچنین ببینید
خواص
serviceName
serviceName : string
شکاف
slot : Slot
googletag.events.EventTypeMap
خواص | |
---|---|
game Manual Interstitial Slot Closed | Alias for events.GameManualInterstitialSlotClosedEvent . |
game Manual Interstitial Slot Ready | Alias for events.GameManualInterstitialSlotReadyEvent . |
impression Viewable | Alias for events.ImpressionViewableEvent . |
rewarded Slot Closed | Alias for events.RewardedSlotClosedEvent . |
rewarded Slot Granted | Alias for events.RewardedSlotGrantedEvent . |
rewarded Slot Ready | Alias for events.RewardedSlotReadyEvent . |
slot Onload | Alias for events.SlotOnloadEvent . |
slot Render Ended | Alias for events.SlotRenderEndedEvent . |
slot Requested | Alias for events.SlotRequestedEvent . |
slot Response Received | Alias for events.SlotResponseReceived . |
slot Visibility Changed | Alias for events.SlotVisibilityChangedEvent . |
خواص
gameManualInterstitialSlotClosed
gameManualInterstitialSlotClosed : GameManualInterstitialSlotClosedEvent
gameManualInterstitialSlotReady
gameManualInterstitialSlotReady : GameManualInterstitialSlotReadyEvent
impressionViewable
impressionViewable : ImpressionViewableEvent
rewardedSlotClosed
rewardedSlotClosed : RewardedSlotClosedEvent
rewardedSlotGranted
rewardedSlotGranted : RewardedSlotGrantedEvent
rewardedSlotReady
rewardedSlotReady : RewardedSlotReadyEvent
slotOnload
slotOnload : SlotOnloadEvent
slotRenderEnded
slotRenderEnded : SlotRenderEndedEvent
slotRequested
slotRequested : SlotRequestedEvent
slotResponseReceived
slotResponseReceived : SlotResponseReceived
slotVisibilityChanged
slotVisibilityChanged : SlotVisibilityChangedEvent
googletag.events.GameManualInterstitialSlotClosedEvent
ExtendsNote: Game manual interstitial is a limited-access format.
خواص | |
---|---|
service Name | Name of the service that triggered the event. Inherited from |
slot | The slot that triggered the event. Inherited from |
- مثال
جاوا اسکریپت
// This listener is called when a game manual interstitial slot is closed. const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL, ); // Slot returns null if the page or device does not support game manual interstitial ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); googletag.pubads().addEventListener("gameManualInterstitialSlotClosed", (event) => { const slot = event.slot; console.log("Game manual interstital slot", slot.getSlotElementId(), "is closed."); if (slot === targetSlot) { // Slot specific logic. } }); }
JavaScript (legacy)
// This listener is called when a game manual interstitial slot is closed. var targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL, ); // Slot returns null if the page or device does not support game manual interstitial ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); googletag.pubads().addEventListener("gameManualInterstitialSlotClosed", function (event) { var slot = event.slot; console.log("Game manual interstital slot", slot.getSlotElementId(), "is closed."); if (slot === targetSlot) { // Slot specific logic. } }); }
TypeScript
// This listener is called when a game manual interstitial slot is closed. const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL, ); // Slot returns null if the page or device does not support game manual interstitial ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); googletag.pubads().addEventListener("gameManualInterstitialSlotClosed", (event) => { const slot = event.slot; console.log("Game manual interstital slot", slot.getSlotElementId(), "is closed."); if (slot === targetSlot) { // Slot specific logic. } }); }
- همچنین ببینید
googletag.events.GameManualInterstitialSlotReadyEvent
ExtendsNote: Game manual interstitial is a limited-access format.
خواص | |
---|---|
service Name | Name of the service that triggered the event. Inherited from |
slot | The slot that triggered the event. Inherited from |
روش ها | |
---|---|
make Game Manual Interstitial Visible | Displays the game manual interstitial ad to the user. |
- مثال
جاوا اسکریپت
// This listener is called when a game manual interstitial slot is ready to // be displayed. const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL, ); // Slot returns null if the page or device does not support game manual interstitial ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); googletag.pubads().addEventListener("gameManualInterstitialSlotReady", (event) => { const slot = event.slot; console.log( "Game manual interstital slot", slot.getSlotElementId(), "is ready to be displayed.", ); // Replace with custom logic. const displayGmiAd = true; if (displayGmiAd) { event.makeGameManualInterstitialVisible(); } if (slot === targetSlot) { // Slot specific logic. } }); }
JavaScript (legacy)
// This listener is called when a game manual interstitial slot is ready to // be displayed. var targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL, ); // Slot returns null if the page or device does not support game manual interstitial ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); googletag.pubads().addEventListener("gameManualInterstitialSlotReady", function (event) { var slot = event.slot; console.log( "Game manual interstital slot", slot.getSlotElementId(), "is ready to be displayed.", ); // Replace with custom logic. var displayGmiAd = true; if (displayGmiAd) { event.makeGameManualInterstitialVisible(); } if (slot === targetSlot) { // Slot specific logic. } }); }
TypeScript
// This listener is called when a game manual interstitial slot is ready to // be displayed. const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL, ); // Slot returns null if the page or device does not support game manual interstitial ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); googletag.pubads().addEventListener("gameManualInterstitialSlotReady", (event) => { const slot = event.slot; console.log( "Game manual interstital slot", slot.getSlotElementId(), "is ready to be displayed.", ); // Replace with custom logic. const displayGmiAd = true; if (displayGmiAd) { event.makeGameManualInterstitialVisible(); } if (slot === targetSlot) { // Slot specific logic. } }); }
- همچنین ببینید
روش ها
makeGameManualInterstitialVisible
makeGameManualInterstitialVisible ( ) : void
googletag.events.ImpressionViewableEvent
Extendsخواص | |
---|---|
service Name | Name of the service that triggered the event. Inherited from |
slot | The slot that triggered the event. Inherited from |
- مثال
جاوا اسکریپت
// This listener is called when an impression becomes viewable. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("impressionViewable", (event) => { const slot = event.slot; console.log("Impression for slot", slot.getSlotElementId(), "became viewable."); if (slot === targetSlot) { // Slot specific logic. } });
JavaScript (legacy)
// This listener is called when an impression becomes viewable. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("impressionViewable", function (event) { var slot = event.slot; console.log("Impression for slot", slot.getSlotElementId(), "became viewable."); if (slot === targetSlot) { // Slot specific logic. } });
TypeScript
// This listener is called when an impression becomes viewable. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("impressionViewable", (event) => { const slot = event.slot; console.log("Impression for slot", slot.getSlotElementId(), "became viewable."); if (slot === targetSlot) { // Slot specific logic. } });
- همچنین ببینید
googletag.events.RewardedSlotClosedEvent
Extendsخواص | |
---|---|
service Name | Name of the service that triggered the event. Inherited from |
slot | The slot that triggered the event. Inherited from |
- مثال
جاوا اسکریپت
const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called when the user closes a rewarded ad slot. googletag.pubads().addEventListener("rewardedSlotClosed", (event) => { const slot = event.slot; console.log("Rewarded ad slot", slot.getSlotElementId(), "has been closed."); if (slot === targetSlot) { // Slot specific logic. } }); }
JavaScript (legacy)
var targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called when the user closes a rewarded ad slot. googletag.pubads().addEventListener("rewardedSlotClosed", function (event) { var slot = event.slot; console.log("Rewarded ad slot", slot.getSlotElementId(), "has been closed."); if (slot === targetSlot) { // Slot specific logic. } }); }
TypeScript
const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called when the user closes a rewarded ad slot. googletag.pubads().addEventListener("rewardedSlotClosed", (event) => { const slot = event.slot; console.log("Rewarded ad slot", slot.getSlotElementId(), "has been closed."); if (slot === targetSlot) { // Slot specific logic. } }); }
- همچنین ببینید
googletag.events.RewardedSlotGrantedEvent
Extendsخواص | |
---|---|
payload | An object containing information about the reward that was granted. |
service Name | Name of the service that triggered the event. Inherited from |
slot | The slot that triggered the event. Inherited from |
- مثال
جاوا اسکریپت
const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called whenever a reward is granted for a // rewarded ad. googletag.pubads().addEventListener("rewardedSlotGranted", (event) => { const slot = event.slot; console.group("Reward granted for slot", slot.getSlotElementId(), "."); // Log details of the reward. console.log("Reward type:", event.payload?.type); console.log("Reward amount:", event.payload?.amount); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } }); }
JavaScript (legacy)
var targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called whenever a reward is granted for a // rewarded ad. googletag.pubads().addEventListener("rewardedSlotGranted", function (event) { var _a, _b; var slot = event.slot; console.group("Reward granted for slot", slot.getSlotElementId(), "."); // Log details of the reward. console.log("Reward type:", (_a = event.payload) === null || _a === void 0 ? void 0 : _a.type); console.log( "Reward amount:", (_b = event.payload) === null || _b === void 0 ? void 0 : _b.amount, ); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } }); }
TypeScript
const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called whenever a reward is granted for a // rewarded ad. googletag.pubads().addEventListener("rewardedSlotGranted", (event) => { const slot = event.slot; console.group("Reward granted for slot", slot.getSlotElementId(), "."); // Log details of the reward. console.log("Reward type:", event.payload?.type); console.log("Reward amount:", event.payload?.amount); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } }); }
- همچنین ببینید
خواص
محموله
payload : RewardedPayload
googletag.events.RewardedSlotReadyEvent
Extendsخواص | |
---|---|
service Name | Name of the service that triggered the event. Inherited from |
slot | The slot that triggered the event. Inherited from |
روش ها | |
---|---|
make Rewarded Visible | Displays the rewarded ad. |
- مثال
جاوا اسکریپت
// This listener is called when a rewarded ad slot becomes ready to be // displayed. const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called whenever a reward is granted for a // rewarded ad. googletag.pubads().addEventListener("rewardedSlotReady", (event) => { const slot = event.slot; console.log("Rewarded ad slot", slot.getSlotElementId(), "is ready to be displayed."); // Replace with custom logic. const userHasConsented = true; if (userHasConsented) { event.makeRewardedVisible(); } if (slot === targetSlot) { // Slot specific logic. } }); }
JavaScript (legacy)
// This listener is called when a rewarded ad slot becomes ready to be // displayed. var targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called whenever a reward is granted for a // rewarded ad. googletag.pubads().addEventListener("rewardedSlotReady", function (event) { var slot = event.slot; console.log("Rewarded ad slot", slot.getSlotElementId(), "is ready to be displayed."); // Replace with custom logic. var userHasConsented = true; if (userHasConsented) { event.makeRewardedVisible(); } if (slot === targetSlot) { // Slot specific logic. } }); }
TypeScript
// This listener is called when a rewarded ad slot becomes ready to be // displayed. const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called whenever a reward is granted for a // rewarded ad. googletag.pubads().addEventListener("rewardedSlotReady", (event) => { const slot = event.slot; console.log("Rewarded ad slot", slot.getSlotElementId(), "is ready to be displayed."); // Replace with custom logic. const userHasConsented = true; if (userHasConsented) { event.makeRewardedVisible(); } if (slot === targetSlot) { // Slot specific logic. } }); }
- همچنین ببینید
روش ها
makeRewardedVisible
makeRewardedVisible ( ) : void
googletag.events.SlotOnloadEvent
ExtendsSlotOnloadEvent
will be fired. خواص | |
---|---|
service Name | Name of the service that triggered the event. Inherited from |
slot | The slot that triggered the event. Inherited from |
- مثال
جاوا اسکریپت
// This listener is called when a creative iframe load event fires. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotOnload", (event) => { const slot = event.slot; console.log("Creative iframe for slot", slot.getSlotElementId(), "has loaded."); if (slot === targetSlot) { // Slot specific logic. } });
JavaScript (legacy)
// This listener is called when a creative iframe load event fires. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotOnload", function (event) { var slot = event.slot; console.log("Creative iframe for slot", slot.getSlotElementId(), "has loaded."); if (slot === targetSlot) { // Slot specific logic. } });
TypeScript
// This listener is called when a creative iframe load event fires. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotOnload", (event) => { const slot = event.slot; console.log("Creative iframe for slot", slot.getSlotElementId(), "has loaded."); if (slot === targetSlot) { // Slot specific logic. } });
- همچنین ببینید
googletag.events.SlotRenderEndedEvent
Extendsخواص | |
---|---|
advertiser Id | Advertiser ID of the rendered ad. |
campaign Id | Campaign ID of the rendered ad. |
company Ids | IDs of the companies that bid on the rendered backfill ad. |
creative Id | Creative ID of the rendered reservation ad. |
creative Template Id | Creative template ID of the rendered reservation ad. |
is Backfill | Whether an ad was a backfill ad. |
is Empty | Whether an ad was returned for the slot. |
label Ids | منسوخ شده است. |
line Item Id | Line item ID of the rendered reservation ad. |
response Identifier | The response identifier is a unique identifier for the ad response. |
service Name | Name of the service that triggered the event. Inherited from |
size | Indicates the pixel size of the rendered creative. |
slot | The slot that triggered the event. Inherited from |
slot Content Changed | Whether the slot content was changed with the rendered ad. |
source Agnostic Creative Id | Creative ID of the rendered reservation or backfill ad. |
source Agnostic Line Item Id | Line item ID of the rendered reservation or backfill ad. |
yield Group Ids | IDs of the yield groups for the rendered backfill ad. |
- مثال
جاوا اسکریپت
// This listener is called when a slot has finished rendering. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotRenderEnded", (event) => { const slot = event.slot; console.group("Slot", slot.getSlotElementId(), "finished rendering."); // Log details of the rendered ad. console.log("Advertiser ID:", event.advertiserId); console.log("Campaign ID:", event.campaignId); console.log("Company IDs:", event.companyIds); console.log("Creative ID:", event.creativeId); console.log("Creative Template ID:", event.creativeTemplateId); console.log("Is backfill?:", event.isBackfill); console.log("Is empty?:", event.isEmpty); console.log("Line Item ID:", event.lineItemId); console.log("Size:", event.size); console.log("Slot content changed?", event.slotContentChanged); console.log("Source Agnostic Creative ID:", event.sourceAgnosticCreativeId); console.log("Source Agnostic Line Item ID:", event.sourceAgnosticLineItemId); console.log("Yield Group IDs:", event.yieldGroupIds); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } });
JavaScript (legacy)
// This listener is called when a slot has finished rendering. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotRenderEnded", function (event) { var slot = event.slot; console.group("Slot", slot.getSlotElementId(), "finished rendering."); // Log details of the rendered ad. console.log("Advertiser ID:", event.advertiserId); console.log("Campaign ID:", event.campaignId); console.log("Company IDs:", event.companyIds); console.log("Creative ID:", event.creativeId); console.log("Creative Template ID:", event.creativeTemplateId); console.log("Is backfill?:", event.isBackfill); console.log("Is empty?:", event.isEmpty); console.log("Line Item ID:", event.lineItemId); console.log("Size:", event.size); console.log("Slot content changed?", event.slotContentChanged); console.log("Source Agnostic Creative ID:", event.sourceAgnosticCreativeId); console.log("Source Agnostic Line Item ID:", event.sourceAgnosticLineItemId); console.log("Yield Group IDs:", event.yieldGroupIds); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } });
TypeScript
// This listener is called when a slot has finished rendering. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotRenderEnded", (event) => { const slot = event.slot; console.group("Slot", slot.getSlotElementId(), "finished rendering."); // Log details of the rendered ad. console.log("Advertiser ID:", event.advertiserId); console.log("Campaign ID:", event.campaignId); console.log("Company IDs:", event.companyIds); console.log("Creative ID:", event.creativeId); console.log("Creative Template ID:", event.creativeTemplateId); console.log("Is backfill?:", event.isBackfill); console.log("Is empty?:", event.isEmpty); console.log("Line Item ID:", event.lineItemId); console.log("Size:", event.size); console.log("Slot content changed?", event.slotContentChanged); console.log("Source Agnostic Creative ID:", event.sourceAgnosticCreativeId); console.log("Source Agnostic Line Item ID:", event.sourceAgnosticLineItemId); console.log("Yield Group IDs:", event.yieldGroupIds); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } });
- همچنین ببینید
خواص
advertiserId
advertiserId : number
null
for empty slots, backfill ads, and creatives rendered by services other than PubAdsService . شناسه کمپین
campaignId : number
null
for empty slots, backfill ads, and creatives rendered by services other than PubAdsService . companyIds
companyIds : number []
null
for empty slots, reservation ads, and creatives rendered by services other than PubAdsService . creativeId
creativeId : number
null
for empty slots, backfill ads, and creatives rendered by services other than PubAdsService . creativeTemplateId
creativeTemplateId : number
null
for empty slots, backfill ads, and creatives rendered by services other than PubAdsService . isBackfill
isBackfill : boolean
true
if the ad was a backfill ad, false
otherwise. خالی است
isEmpty : boolean
true
if no ad was returned, false
otherwise. labelIds
labelIds : number []
lineItemId
lineItemId : number
null
for empty slots, backfill ads, and creatives rendered by services other than PubAdsService . responseIdentifier
responseIdentifier : string
اندازه
size : string | number []
[728, 90]
. Value is null
for empty ad slots. slotContentChanged
slotContentChanged : boolean
true
if the content was changed, false
otherwise. sourceAgnosticCreativeId
sourceAgnosticCreativeId : number
null
if the ad is not a reservation or line item backfill, or the creative is rendered by services other than PubAdsService . sourceAgnosticLineItemId
sourceAgnosticLineItemId : number
null
if the ad is not a reservation or line item backfill, or the creative is rendered by services other than PubAdsService . yieldGroupIds
yieldGroupIds : number []
null
for empty slots, reservation ads, and creatives rendered by services other than PubAdsService . googletag.events.SlotRequestedEvent
Extendsخواص | |
---|---|
service Name | Name of the service that triggered the event. Inherited from |
slot | The slot that triggered the event. Inherited from |
- مثال
جاوا اسکریپت
// This listener is called when the specified service issues an ad // request for a slot. Each slot will fire this event, even though they // may be batched together in a single request if single request // architecture (SRA) is enabled. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotRequested", (event) => { const slot = event.slot; console.log("Slot", slot.getSlotElementId(), "has been requested."); if (slot === targetSlot) { // Slot specific logic. } });
JavaScript (legacy)
// This listener is called when the specified service issues an ad // request for a slot. Each slot will fire this event, even though they // may be batched together in a single request if single request // architecture (SRA) is enabled. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotRequested", function (event) { var slot = event.slot; console.log("Slot", slot.getSlotElementId(), "has been requested."); if (slot === targetSlot) { // Slot specific logic. } });
TypeScript
// This listener is called when the specified service issues an ad // request for a slot. Each slot will fire this event, even though they // may be batched together in a single request if single request // architecture (SRA) is enabled. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotRequested", (event) => { const slot = event.slot; console.log("Slot", slot.getSlotElementId(), "has been requested."); if (slot === targetSlot) { // Slot specific logic. } });
- همچنین ببینید
googletag.events.SlotResponseReceived
Extendsخواص | |
---|---|
service Name | Name of the service that triggered the event. Inherited from |
slot | The slot that triggered the event. Inherited from |
- مثال
جاوا اسکریپت
// This listener is called when an ad response has been received // for a slot. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotResponseReceived", (event) => { const slot = event.slot; console.log("Ad response for slot", slot.getSlotElementId(), "received."); if (slot === targetSlot) { // Slot specific logic. } });
JavaScript (legacy)
// This listener is called when an ad response has been received // for a slot. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotResponseReceived", function (event) { var slot = event.slot; console.log("Ad response for slot", slot.getSlotElementId(), "received."); if (slot === targetSlot) { // Slot specific logic. } });
TypeScript
// This listener is called when an ad response has been received // for a slot. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotResponseReceived", (event) => { const slot = event.slot; console.log("Ad response for slot", slot.getSlotElementId(), "received."); if (slot === targetSlot) { // Slot specific logic. } });
- همچنین ببینید
googletag.events.SlotVisibilityChangedEvent
Extendsخواص | |
---|---|
in View Percentage | The percentage of the ad's area that is visible. |
service Name | Name of the service that triggered the event. Inherited from |
slot | The slot that triggered the event. Inherited from |
- مثال
جاوا اسکریپت
// This listener is called whenever the on-screen percentage of an // ad slot's area changes. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotVisibilityChanged", (event) => { const slot = event.slot; console.group("Visibility of slot", slot.getSlotElementId(), "changed."); // Log details of the event. console.log("Visible area:", `${event.inViewPercentage}%`); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } });
JavaScript (legacy)
// This listener is called whenever the on-screen percentage of an // ad slot's area changes. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotVisibilityChanged", function (event) { var slot = event.slot; console.group("Visibility of slot", slot.getSlotElementId(), "changed."); // Log details of the event. console.log("Visible area:", "".concat(event.inViewPercentage, "%")); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } });
TypeScript
// This listener is called whenever the on-screen percentage of an // ad slot's area changes. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotVisibilityChanged", (event) => { const slot = event.slot; console.group("Visibility of slot", slot.getSlotElementId(), "changed."); // Log details of the event. console.log("Visible area:", `${event.inViewPercentage}%`); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } });
- همچنین ببینید
خواص
inViewPercentage
inViewPercentage : number
googletag.secureSignals
رابط ها | |
---|---|
Bidder Signal Provider | Returns a secure signal for a specific bidder. |
Publisher Signal Provider | Returns a secure signal for a specific publisher. |
Secure Signal Providers Array | An interface for managing secure signals. |
Type Aliases | |
---|---|
Secure Signal Provider | Interface for returning a secure signal for a specific bidder or provider. |
Type Aliases
SecureSignalProvider
SecureSignalProvider : BidderSignalProvider | PublisherSignalProvider
id
or networkCode
must be provided, but not both. googletag.secureSignals.BidderSignalProvider
A bidder secure signal provider consists of 2 parts:
- A collector function, which returns a
Promise
that resolves to a secure signal. - An
id
which identifies the bidder associated with the signal.
خواص | |
---|---|
collector Function | A function which returns a Promise that resolves to a secure signal. |
id | A unique identifier for the collector associated with this secure signal, as registered in Google Ad Manager. |
- مثال
جاوا اسکریپت
// id is provided googletag.secureSignalProviders.push({ id: "collector123", collectorFunction: () => { // ...custom signal generation logic... return Promise.resolve("signal"); }, });
JavaScript (legacy)
// id is provided googletag.secureSignalProviders.push({ id: "collector123", collectorFunction: function () { // ...custom signal generation logic... return Promise.resolve("signal"); }, });
TypeScript
// id is provided googletag.secureSignalProviders!.push({ id: "collector123", collectorFunction: () => { // ...custom signal generation logic... return Promise.resolve("signal"); }, });
- همچنین ببینید
خواص
collectorFunction
collectorFunction : ( ( ) => Promise < string > )
Promise
that resolves to a secure signal. شناسه
id : string
googletag.secureSignals.PublisherSignalProvider
A publisher signal provider consists of 2 parts:
- A collector function, which returns a
Promise
that resolves to a secure signal. - A
networkCode
which identifies the publisher associated with the signal.
خواص | |
---|---|
collector Function | A function which returns a Promise that resolves to a secure signal. |
network Code | The network code (as seen in the ad unit path) for the publisher associated with this secure signal. |
- مثال
جاوا اسکریپت
// networkCode is provided googletag.secureSignalProviders.push({ networkCode: "123456", collectorFunction: () => { // ...custom signal generation logic... return Promise.resolve("signal"); }, });
JavaScript (legacy)
// networkCode is provided googletag.secureSignalProviders.push({ networkCode: "123456", collectorFunction: function () { // ...custom signal generation logic... return Promise.resolve("signal"); }, });
TypeScript
// networkCode is provided googletag.secureSignalProviders!.push({ networkCode: "123456", collectorFunction: () => { // ...custom signal generation logic... return Promise.resolve("signal"); }, });
- همچنین ببینید
خواص
collectorFunction
collectorFunction : ( ( ) => Promise < string > )
Promise
that resolves to a secure signal. networkCode
networkCode : string
googletag.secureSignals.SecureSignalProvidersArray
روش ها | |
---|---|
clear All Cache | Clears all signals for all collectors from cache. |
push | Adds a new secureSignals.SecureSignalProvider to the signal provider array and begins the signal generation process. |
روش ها
clearAllCache
clearAllCache ( ) : void
Calling this method may reduce the likelihood of signals being included in ad requests for the current and potentially later page views. Due to this, it should only be called when meaningful state changes occur, such as events that indicate a new user (log in, log out, sign up, etc.).
فشار دهید
push ( provider : SecureSignalProvider ) : void
پارامترها | |
---|---|
provider : SecureSignalProvider | The secureSignals.SecureSignalProvider object to be added to the array. |