این مرجع از نماد 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 ( 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 | تنظیمات برای پیکربندی تنظیمات مربوط به آگهی ویدیویی. |
نام مستعار را تایپ کنید | |
---|---|
Collapse Div Behavior | مقادیر پشتیبانی شده برای کنترل رفتار فروپاشی شکافهای AD. |
Interstitial Trigger | محرکهای تبلیغاتی بینابینی پشتیبانی می کنند. |
Privacy Treatment | از درمان های حریم خصوصی ناشر پشتیبانی می شود. |
Taxonomy | طبقه بندی های پشتیبانی شده برای ناشر سیگنال ها (PPS) ارائه می دهند . |
نام مستعار را تایپ کنید
فرو ریختگان
CollapseDivBehavior : "DISABLED" | "BEFORE_FETCH" | "ON_NO_FILL"
- همچنین ببینید
بینابین
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 ?: CollapseDivBehavior
یک شکاف تبلیغاتی فروپاشی هیچ فضایی در صفحه نمی گیرد.
مقادیر پشتیبانی شده:
-
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 ?: CollapseDivBehavior
یک شکاف تبلیغاتی فروپاشی هیچ فضایی در صفحه نمی گیرد.
مقادیر پشتیبانی شده:
-
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 | 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. |
Rewarded Slot Video Completed Event | This event is fired when a rewarded video ad has finished playing. |
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 . |
rewarded Slot Video Completed | Alias for events.RewardedSlotVideoCompletedEvent . |
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
rewardedSlotVideoCompleted
rewardedSlotVideoCompleted : RewardedSlotVideoCompletedEvent
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.RewardedSlotVideoCompletedEvent
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 video in a rewarded ad slot has // finished playing. googletag.pubads().addEventListener("rewardedSlotVideoCompleted", (event) => { const slot = event.slot; console.log("Video in rewarded ad slot", slot.getSlotElementId(), "has finished playing."); 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 video in a rewarded ad slot has // finished playing. googletag.pubads().addEventListener("rewardedSlotVideoCompleted", function (event) { var slot = event.slot; console.log("Video in rewarded ad slot", slot.getSlotElementId(), "has finished playing."); 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 video in a rewarded ad slot has // finished playing. googletag.pubads().addEventListener("rewardedSlotVideoCompleted", (event) => { const slot = event.slot; console.log("Video in rewarded ad slot", slot.getSlotElementId(), "has finished playing."); if (slot === targetSlot) { // Slot specific logic. } }); }
- همچنین ببینید
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. |
نام مستعار را تایپ کنید | |
---|---|
Secure Signal Provider | Interface for returning a secure signal for a specific bidder or provider. |
نام مستعار را تایپ کنید
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. |