يستخدم هذا المرجع تدوين 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 هي
معلَمة راحة
تقبل الدوال. تقبل المَعلمات المتبقية عددًا غير محدود من قيم النوع المحدّد.
|
تعريفات الأنواع
الأنواع | |
---|---|
|
SingleSize | MultiSize
|
إعداد حجم صالح للخانة، التي يمكن أن تكون بحجم واحد أو أحجام متعددة. |
|
|
SingleSize[]
|
قائمة بالمقاسات الفردية الصالحة. |
|
|
"fluid" | ["fluid"]
|
أحجام الأسماء التي يمكن أن تحملها الخانة في معظم الحالات، يكون الحجم مستطيلاً بحجم ثابتًا ولكن هناك بعض الحالات التي نحتاج فيها إلى أنواع أخرى من مواصفات الحجم. في ما يلي فقط مقاسات الأسماء الصالحة:
|
|
|
SingleSizeArray | NamedSize
|
حجم واحد صالح للخانة |
|
|
[number, number]
|
مصفوفة من رقمين يمثلان [width, height]. |
|
|
[SingleSizeArray, GeneralSize]
|
تعيين حجم إطار العرض لأحجام الإعلانات. تُستخدَم للإعلانات المتجاوبة. |
|
|
SizeMapping[]
|
قائمة بتعيينات الحجم. |
|
|
"unhideWindow" | "navBar"
|
عوامل تشغيل الإعلانات البينية المتاحة |
|
|
"disablePersonalization"
|
التعاملات المتوافقة مع خصوصية الناشرين |
|
|
"IAB_AUDIENCE_1_1" | "IAB_CONTENT_2_2"
|
التصنيفات المتوافقة للإشارات المقدَّمة من الناشر (PPS) |
|
|
BidderSignalProvider | PublisherSignalProvider
|
واجهة لعرض إشارة آمنة لمقدّم عروض أسعار أو مقدّم خدمة محدّدَين يجب تقديم أحد |
أنواع التعداد
عمليات التعداد | |
---|---|
googletag.enums.OutOfPageFormat
|
تنسيقات الإعلانات خارج الصفحة المتوافقة مع GPT.
|
googletag.enums.TrafficSource
|
مصادر الزيارات المتوافقة مع علامة GPT
|
googletag.enums.OutOfPageFormat
-
تنسيقات الإعلانات خارج الصفحة المتوافقة مع GPT.
-
- يمكن أيضًا مراجعة
googletag.enums.TrafficSource
-
مصادر الزيارات المتوافقة مع علامة GPT
-
- يمكن أيضًا مراجعة
-
القيم ORGANIC
إدخال عنوان URL مباشر أو بحث في الموقع أو تنزيل تطبيقPURCHASED
الزيارات المُعاد توجيهها من ممتلكات غير المملوكة (النشاط المكتسب أو المحفَّز بأي طريقة أخرى)
googletag
هي مساحة الاسم العامة التي تستخدمها علامة "ناشر Google" لواجهة برمجة التطبيقات الخاصة بها.
ملخّص المتغير | |
---|---|
apiReady
|
علامة تشير إلى أنّ واجهة برمجة تطبيقات GPT تم تحميلها وأنّها جاهزة للاستدعاء.
|
cmd
|
الإشارة إلى قائمة انتظار الأوامر العامة للتنفيذ غير المتزامن للمكالمات المتعلقة بعلامة GPT
|
pubadsReady
|
علامة تشير إلى أنّ
PubAdsService مفعَّلة وتم تحميلها وتعمل بالكامل.
|
secureSignalProviders
|
الرجوع إلى مصفوفة مزوّدي الإشارات الآمنة
|
ملخّص الدالة | |
---|---|
companionAds
|
لعرض مرجع إلى
CompanionAdsService .
|
defineOutOfPageSlot
|
تُنشئ شريحة إعلانية خارج الصفحة باستخدام مسار الوحدة الإعلانية المحدّد.
|
defineSlot
|
تنشئ شريحة إعلانية بمسار وحجم وحدة إعلانية محدّدَين وربطها بمعرّف عنصر div على الصفحة التي ستحتوي على الإعلان.
|
destroySlots
|
محو الخانات المحددة، وإزالة جميع الكائنات والمراجع ذات الصلة بهذه الخانات من GPT.
|
disablePublisherConsole
|
لإيقاف "وحدة تحكّم الناشرين في Google".
|
display
|
توجيه خدمات الخانة لعرض الخانة
|
enableServices
|
يؤدي هذا الخيار إلى تفعيل جميع خدمات GPT التي تم تحديدها للخانات الإعلانية على الصفحة.
|
getVersion
|
لعرض الإصدار الحالي من GPT.
|
openConsole
|
لفتح وحدة تحكّم الناشرين في Google.
|
pubads
|
لعرض مرجع إلى
PubAdsService .
|
setAdIframeTitle
|
لضبط عنوان جميع إطارات iframe في حاويات الإعلانات التي تم إنشاؤها بواسطة
PubAdsService ، بدءًا من هذه النقطة فصاعدًا.
|
setConfig
|
لضبط خيارات الضبط العامة للصفحة.
|
sizeMapping
|
لإنشاء
SizeMappingBuilder جديد.
|
googletag.apiReady
-
apiReady: boolean | undefined
-
علامة تشير إلى أنّ واجهة برمجة تطبيقات GPT تم تحميلها وأنّها جاهزة للاستدعاء. سيظلّ هذا الموقع هو
undefined
ببساطة إلى أن تصبح واجهة برمجة التطبيقات جاهزة.
تجدر الإشارة إلى أن الطريقة المُقترَحة للتعامل مع المزامنة غير المتزامنة هي استخدام googletag.cmd لوضع طلبات معاودة الاتصال في قائمة انتظار عندما تكون علامة GPT جاهزة. لا يجب أن تتحقّق عمليات الاستدعاء هذه من التحقّق من googletag.apiready لأنّه يمكن تنفيذه بعد إعداد واجهة برمجة التطبيقات. -
- مثال
-
JavaScript
if (window.googletag && googletag.apiReady) { // GPT API can be called safely. }
JavaScript (قديمة)
if (window.googletag && googletag.apiReady) { // GPT API can be called safely. }
TypeScript
if (window.googletag && googletag.apiReady) { // GPT API can be called safely. }
googletag.cmd
-
cmd: Array<(this: typeof globalThis) => void> | CommandArray
-
الإشارة إلى قائمة انتظار الأوامر العامة للتنفيذ غير المتزامن لطلبات البيانات المرتبطة بعلامة GPT.
يتم إعداد المتغيّرgoogletag.cmd
على مصفوفة JavaScript فارغة من خلال بنية علامة GPT على الصفحة، مع العلم أنّcmd.push
هي طريقةArray.push
العادية التي تضيف عنصرًا إلى نهاية المصفوفة. عند تحميل JavaScript GPT، تفحص الصفيفة جميع الدوال بالترتيب. بعد ذلك، يستبدل النص البرمجيcmd
بكائنCommandArray
تم تحديد طريقة الدفع الخاصة به لتنفيذ وسيطة الدالة التي تم تمريرها إليه. تسمح هذه الآلية لعلامات GPT بتقليل وقت الاستجابة الملاحظ عن طريق جلب JavaScript بشكل غير متزامن مع السماح للمتصفح بمواصلة عرض الصفحة. -
- مثال
-
JavaScript
googletag.cmd.push(() => { googletag.defineSlot("/1234567/sports", [160, 600]).addService(googletag.pubads()); });
JavaScript (قديمة)
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()); });
googletag.pubadsReady
-
pubadsReady: boolean | undefined
-
علامة تشير إلى أنّ
PubAdsService
مفعَّلة وتم تحميلها وتعمل بالكامل. سيتم استخدام هذه السمةundefined
حتى يتم استدعاءenableServices
وتحميلPubAdsService
وإعداده. -
googletag.secureSignalProviders
-
secureSignalProviders: SecureSignalProvider[] | SecureSignalProvidersArray | undefined
-
ارجع إلى مصفوفة مزوّدي الإشارات الآمنة.
تقبل مصفوفة مزوّدي الإشارات الآمنة سلسلة من دوال إنشاء الإشارات وتستدعيها بالترتيب. الغرض منه استبدال الصفيفة العادية التي تُستخدم لإدراج دوال إنشاء الإشارات في قائمة الانتظار ليتم استدعاؤها بعد تحميل علامة GPT. -
- مثال
-
JavaScript
window.googletag = window.googletag || { cmd: [] }; googletag.secureSignalProviders = googletag.secureSignalProviders || []; googletag.secureSignalProviders.push({ id: "collector123", collectorFunction: () => { return Promise.resolve("signal"); }, });
JavaScript (قديمة)
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"); }, });
- يمكن أيضًا مراجعة
googletag.companionAds
-
companionAds(): CompanionAdsService
-
لعرض مرجع إلى
CompanionAdsService
. -
-
المرتجعات CompanionAdsService
خدمة "الإعلانات المصاحبة".
googletag.defineOutOfPageSlot
-
defineOutOfPageSlot(adUnitPath: string, div?: string | OutOfPageFormat): Slot | null
-
تُنشئ شريحة إعلانية خارج الصفحة باستخدام مسار الوحدة الإعلانية المحدّد.
بالنسبة إلى الإعلانات المخصّصة خارج الصفحة، يكونdiv
هو رقم تعريف عنصر div الذي سيحتوي على الإعلان. يمكنك الاطّلاع على المقالة حول تصميمات الإعلانات خارج الصفحة للحصول على مزيد من التفاصيل.
بالنسبة إلى الإعلانات خارج الصفحة المُدارة في GPT، تتوافق لغةdiv
مع OutOfPageFormat. -
- مثال
-
JavaScript
// Define a custom out-of-page ad slot. googletag.defineOutOfPageSlot("/1234567/sports", "div-1"); // Define a GPT managed web interstitial ad slot. googletag.defineOutOfPageSlot("/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL);
JavaScript (قديمة)
// 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?: string | OutOfPageFormat
رقم تعريف عنصر div الذي سيحتوي على هذه الوحدة الإعلانية أو OutOfPageFormat. -
المرتجعات Slot | null
الخانة التي تم إنشاؤها حديثًا، أوnull
في حال تعذّر إنشاء خانة
googletag.defineSlot
-
defineSlot(adUnitPath: string, size: GeneralSize, div?: string): Slot | null
-
تنشئ شريحة إعلانية بمسار وحجم وحدة إعلانية محدّدَين وربطها بمعرّف عنصر div على الصفحة التي ستحتوي على الإعلان.
-
- مثال
-
JavaScript
googletag.defineSlot("/1234567/sports", [728, 90], "div-1");
JavaScript (قديمة)
googletag.defineSlot("/1234567/sports", [728, 90], "div-1");
TypeScript
googletag.defineSlot("/1234567/sports", [728, 90], "div-1");
- يمكن أيضًا مراجعة
-
المَعلمات adUnitPath: string
مسار الوحدة الإعلانية الكامل مع رمز الشبكة ورمز الوحدة.size: GeneralSize
عرض الخانة المُضافة وارتفاعها هذا هو الحجم الذي يتم استخدامه في طلب الإعلان في حال عدم توفير تعيين للحجم المتجاوب، أو في حال كان حجم إطار العرض أصغر من أصغر حجم تم توفيره في عملية الربط.div?: string
رقم تعريف القسم الذي سيحتوي على هذه الوحدة الإعلانية. -
المرتجعات Slot | null
الخانة التي تم إنشاؤها حديثًا، أوnull
في حال تعذّر إنشاء خانة
googletag.destroySlots
-
destroySlots(slots?: Slot[]): boolean
-
محو الخانات المحددة، وإزالة جميع الكائنات والمراجع ذات الصلة بهذه الخانات من GPT. لا تتيح واجهة برمجة التطبيقات هذه استخدام خانات التراجع عن الظهور والخانات المصاحبة.
يؤدي استدعاء واجهة برمجة التطبيقات هذه في إحدى الخانات إلى محو الإعلان وإزالة كائن الخانة من الحالة الداخلية التي يحتفظ بها جدول تقسيم المعرّف الفريد العمومي. سيؤدي استدعاء أي دوال أخرى في كائن الشريحة إلى سلوك غير محدد. لاحظ أن المتصفح قد لا يزال لا يحرر الذاكرة المرتبطة بهذه الخانة إذا تم الاحتفاظ بمرجع إليها في صفحة الناشر. يؤدي استدعاء واجهة برمجة التطبيقات هذه إلى إتاحة إعادة استخدام القسم div المرتبط بهذه الخانة.
وبالتحديد، يؤدي إتلاف الخانة إلى إزالة الإعلان من مشاهدة الصفحة طويلة الأجل في GPT، لذلك لن تتأثر الطلبات المستقبلية بالعوائق أو الاستثناءات التنافسية التي تشمل هذا الإعلان. سيؤدي عدم استدعاء هذه الدالة قبل إزالة علامة div الخاصة بالخانة من الصفحة إلى سلوك غير محدّد. -
- مثال
-
JavaScript
// The calls to construct an ad and display contents. const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1"); googletag.display("div-1"); const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2"); googletag.display("div-2"); // This call to destroy only slot1. googletag.destroySlots([slot1]); // This call to destroy both slot1 and slot2. googletag.destroySlots([slot1, slot2]); // This call to destroy all slots. googletag.destroySlots();
JavaScript (قديمة)
// 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();
-
المَعلمات slots?: Slot[]
مجموعة الخانات المطلوب تدميرها المصفوفة اختيارية، وسيتم إتلاف كل الفتحات إذا لم يتم تحديدها. -
المرتجعات boolean
true
إذا تم إتلاف الخانات،false
في الحالات الأخرى.
googletag.disablePublisherConsole
-
disablePublisherConsole(): void
-
لإيقاف "وحدة تحكّم الناشرين في Google".
-
- يمكن أيضًا مراجعة
googletag.display
-
display(divOrSlot: string | Element | Slot): void
-
توجيه خدمات الخانة لعرض الخانة يجب عرض كل خانة إعلانية مرة واحدة فقط في كل صفحة. يجب تحديد كل الخانات وأن يتم ربط خدمة بها قبل عرضها. يجب ألا يتم طلب العرض إلى أن يتوفّر العنصر في DOM. تتمثل الطريقة المعتادة لتحقيق ذلك في وضع الإعلان ضمن كتلة نص برمجي داخل عنصر div المسمى في استدعاء الطريقة.
في حال استخدام بنية طلب واحد (SRA)، سيتم جلب جميع الخانات الإعلانية غير المجلبة في وقت استدعاء هذه الطريقة دفعة واحدة. لفرض عدم عرض خانة إعلانية، يجب إزالة علامة div بالكامل. -
- مثال
-
JavaScript
googletag.cmd.push(() => { googletag.display("div-1"); });
JavaScript (قديمة)
googletag.cmd.push(function () { googletag.display("div-1"); });
TypeScript
googletag.cmd.push(() => { googletag.display("div-1"); });
- يمكن أيضًا مراجعة
-
المَعلمات divOrSlot: string | Element | Slot
رقم تعريف عنصر div الذي يحتوي على الشريحة الإعلانية أو عنصر div أو كائن الشريحة. في حال توفير عنصر div، يجب أن يحتوي هذا العنصر على سمة "id" (المعرّف) التي تطابق المعرّف الذي تم تمريره إلىdefineSlot
.
googletag.enableServices
-
enableServices(): void
-
يؤدي هذا الخيار إلى تفعيل جميع خدمات GPT التي تم تحديدها للخانات الإعلانية على الصفحة.
-
googletag.getVersion
-
getVersion(): string
-
لعرض الإصدار الحالي من GPT.
-
- يمكن أيضًا مراجعة
-
المرتجعات string
سلسلة إصدار علامة GPT المنفّذة حاليًا.
googletag.openConsole
-
openConsole(div?: string): void
-
لفتح وحدة تحكّم الناشرين في Google.
-
- مثال
-
JavaScript
// Calling with div ID. googletag.openConsole("div-1"); // Calling without div ID. googletag.openConsole();
JavaScript (قديمة)
// 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?: string
رقم تعريف قسم الشريحة الإعلانية هذه القيمة اختيارية. وعند توفيرها، ستحاول "وحدة تحكُّم الناشر" الفتح مع عرض تفاصيل الشريحة الإعلانية المحدّدة.
googletag.pubads
-
pubads(): PubAdsService
-
لعرض مرجع إلى
PubAdsService
. -
-
المرتجعات PubAdsService
خدمة "إعلانات الناشر":
googletag.setAdIframeTitle
-
setAdIframeTitle(title: string): void
-
لضبط عنوان جميع إطارات iframe في حاويات الإعلانات التي تم إنشاؤها بواسطة
PubAdsService
، بدءًا من هذه النقطة فصاعدًا. -
- مثال
-
JavaScript
googletag.setAdIframeTitle("title");
JavaScript (قديمة)
googletag.setAdIframeTitle("title");
TypeScript
googletag.setAdIframeTitle("title");
-
المَعلمات title: string
العنوان الجديد لجميع إطارات iframe في حاويات الإعلانات.
googletag.setConfig
-
setConfig(config: PageSettingsConfig): void
-
لضبط خيارات الضبط العامة للصفحة.
-
-
المَعلمات config: PageSettingsConfig
googletag.sizeMapping
-
sizeMapping(): SizeMappingBuilder
-
لإنشاء
SizeMappingBuilder
جديد. -
- يمكن أيضًا مراجعة
-
المرتجعات SizeMappingBuilder
أداة إنشاء جديدة.
googletag.CommandArray
تقبل صفيفة الأوامر سلسلة من الدوال ويستدعيها بالترتيب. الغرض منه استبدال صفيف قياسي يُستخدم لإدراج الدوال التي سيتم استدعاءها عند تحميل GPT.
ملخّص الطريقة | |
---|---|
push
|
ينفِّذ تسلسل الدوال المحددة في الوسيطات بالترتيب.
|
push
-
push(...f: Array<(this: typeof globalThis) => void>): number
-
ينفِّذ تسلسل الدوال المحددة في الوسيطات بالترتيب.
-
- مثال
-
JavaScript
googletag.cmd.push(() => { googletag.defineSlot("/1234567/sports", [160, 600]).addService(googletag.pubads()); });
JavaScript (قديمة)
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()); });
-
المَعلمات ...f: Array<(this: typeof globalThis) => void>
يشير ذلك المصطلح إلى دالة JavaScript سيتم تنفيذها. سيكون ربط وقت التشغيل دائمًاglobalThis
. يمكنك تمرير دالة سهمية للاحتفاظ بالقيمةthis
للسياق المعجمي المتضمّن. -
المرتجعات number
عدد الأوامر التي تمت معالجتها حتى الآن. يتوافق هذا مع قيمةArray.push
المعروضة (الطول الحالي للمصفوفة).
googletag.CompanionAdsService
يمتد
خدمة الإعلانات المصاحبة. يتم استخدام هذه الخدمة من خلال إعلانات الفيديو لعرض الإعلانات المصاحبة.
ملخّص الطريقة | |
---|---|
addEventListener
|
يعمل هذا الإعداد على تسجيل أداة معالجة تتيح لك إعداد دالة JavaScript وطلبها عند وقوع حدث GPT معيّن على الصفحة.
تم الاكتساب من
|
getSlots
|
احصل على قائمة الخانات المرتبطة بهذه الخدمة.
تم الاكتساب من
|
removeEventListener
|
يزيل هذا الخيار مستمعًا سبق تسجيله.
تم الاكتساب من
|
setRefreshUnfilledSlots
|
تحدِّد هذه السياسة ما إذا كان ستتم تلقائيًا إعادة تعبئة الخانات المصاحبة التي لم يتم ملؤها.
|
- يمكن أيضًا مراجعة
setRefreshUnfilledSlots
-
setRefreshUnfilledSlots(value: boolean): void
-
تحدِّد هذه السياسة ما إذا كان ستتم تلقائيًا إعادة تعبئة الخانات المصاحبة التي لم يتم ملؤها.
يمكن طلب هذه الطريقة عدة مرات أثناء عمر الصفحة لتفعيل إعادة التعبئة وإيقافها. ولن تتم إضافة البيانات السابقة إلا إلى الخانات المسجّلة أيضًا باستخدامPubAdsService
. نظرًا لقيود السياسة، لم يتم تصميم هذه الطريقة لملء الخانات المصاحبة الفارغة عند عرض فيديو Ad Exchange. -
- مثال
-
JavaScript
googletag.companionAds().setRefreshUnfilledSlots(true);
JavaScript (قديمة)
googletag.companionAds().setRefreshUnfilledSlots(true);
TypeScript
googletag.companionAds().setRefreshUnfilledSlots(true);
-
المَعلمات value: boolean
true
لملء الخانات غير المعبأة تلقائيًا،false
لتركها بدون تغيير.
googletag.PrivacySettingsConfig
كائن إعداد لإعدادات الخصوصية.
ملخّص الملكية | |
---|---|
childDirectedTreatment
|
يشير هذا الحقل إلى ما إذا كان يجب التعامل مع الصفحة على أنّها موجّهة إلى الأطفال.
|
limitedAds
|
تعمل على تفعيل عرض الإعلانات في وضع إعلانات محدودة للمساعدة في تلبية متطلبات الامتثال التنظيمي للناشرين.
|
nonPersonalizedAds
|
تعمل على تفعيل عرض الإعلانات في وضع الإعلانات غير المخصّصة للمساعدة في تلبية احتياجات الامتثال التنظيمية للناشرين.
|
restrictDataProcessing
|
تعمل على تفعيل العرض للتشغيل في وضع المعالجة المحدودة للمساعدة في تلبية احتياجات الامتثال التنظيمي للناشرين.
|
trafficSource
|
يشير هذا العمود إلى ما إذا كانت الطلبات تمثّل زيارات تم شراؤها أو الزيارات الواردة من نتائج البحث المجانية.
|
underAgeOfConsent
|
يشير إلى ما إذا كان يجب وضع علامة على طلبات الإعلان على أنّها واردة من مستخدِمين تحت سن الرشد.
|
- يمكن أيضًا مراجعة
childDirectedTreatment
-
childDirectedTreatment: null | boolean
-
يشير هذا الحقل إلى ما إذا كان يجب التعامل مع الصفحة على أنّها موجّهة إلى الأطفال. اضبط القيمة على
null
لمحو الإعدادات. -
limitedAds
-
limitedAds: boolean
-
تعمل على تفعيل عرض الإعلانات في وضع إعلانات محدودة للمساعدة في تلبية متطلبات الامتثال التنظيمي للناشرين. عند تفعيل هذه الميزة، قد يتم طلب مكتبة GPT نفسها اختياريًا من عنوان URL لعرض إعلانات محدودة بدون ملفات تعريف الارتباط.
-
- يمكن أيضًا مراجعة
nonPersonalizedAds
-
nonPersonalizedAds: boolean
-
تعمل على تفعيل عرض الإعلانات في وضع الإعلانات غير المخصّصة للمساعدة في تلبية احتياجات الامتثال التنظيمية للناشرين.
-
restrictDataProcessing
-
restrictDataProcessing: boolean
-
تعمل على تفعيل العرض للتشغيل في وضع المعالجة المحدودة للمساعدة في تلبية احتياجات الامتثال التنظيمي للناشرين.
-
trafficSource
-
trafficSource: TrafficSource
-
يشير هذا العمود إلى ما إذا كانت الطلبات تمثّل زيارات تم شراؤها أو الزيارات الواردة من نتائج البحث المجانية. تعمل هذه القيمة على تعبئة سمة مصدر الزيارات في تقارير "مدير إعلانات Google". وفي حال ترك هذه السياسة بدون ضبط، يتم ضبط مصدر الزيارات تلقائيًا على
undefined
في إعداد التقارير. -
- مثال
-
JavaScript
// Indicate requests represent organic traffic. googletag.pubads().setPrivacySettings({ trafficSource: googletag.enums.TrafficSource.ORGANIC, }); // Indicate requests represent purchased traffic. googletag.pubads().setPrivacySettings({ trafficSource: googletag.enums.TrafficSource.PURCHASED, });
JavaScript (قديمة)
// 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, });
underAgeOfConsent
-
underAgeOfConsent: null | boolean
-
يشير إلى ما إذا كان يجب وضع علامة على طلبات الإعلان على أنّها واردة من مستخدِمين تحت سن الرشد. اضبط القيمة على
null
لمحو الإعدادات. -
googletag.PubAdsService
يمتد
خدمة إعلانات الناشرين. وتُستخدم هذه الخدمة لجلب الإعلانات وعرضها من حسابك على "مدير إعلانات Google".
ملخّص الطريقة | |
---|---|
addEventListener
|
يعمل هذا الإعداد على تسجيل أداة معالجة تتيح لك إعداد دالة JavaScript وطلبها عند وقوع حدث GPT معيّن على الصفحة.
تم الاكتساب من
|
clear
|
يعمل هذا الإجراء على إزالة الإعلانات من الخانات المحدّدة واستبدالها بمحتوى فارغ.
|
clearCategoryExclusions
|
يؤدي إلى محو كل تصنيفات استبعاد فئات الإعلانات على مستوى الصفحة.
|
clearTargeting
|
يؤدي هذا الإجراء إلى محو مَعلمات الاستهداف المخصّصة لمفتاح معيّن أو لجميع المفاتيح.
|
collapseEmptyDivs
|
تعمل هذه السياسة على تفعيل تصغير عناصر div المضمّنة بحيث لا تشغل أي مساحة على الصفحة في حال عدم توفّر محتوى إعلاني لعرضه.
|
disableInitialLoad
|
لإيقاف طلبات الإعلانات عند تحميل الصفحة، مع السماح بطلب الإعلانات من خلال استدعاء
PubAdsService.refresh .
|
display
|
لإنشاء شريحة إعلانية وعرضها بمسار الوحدة الإعلانية وحجمها.
|
enableLazyLoad
|
تعمل هذه السياسة على تفعيل طريقة "التحميل الكسول" في علامة GPT على النحو المحدّد في عنصر الضبط.
|
enableSingleRequest
|
تُفعِّل وضع الطلب الفردي لجلب إعلانات متعددة في الوقت نفسه.
|
enableVideoAds
|
إشارات إلى علامة GPT تشير إلى ظهور إعلانات الفيديو على الصفحة.
|
get
|
تعرض قيمة سمة AdSense المرتبطة بالمفتاح المحدّد.
|
getAttributeKeys
|
تعرض مفاتيح السمات التي تم ضبطها في هذه الخدمة.
|
getSlots
|
احصل على قائمة الخانات المرتبطة بهذه الخدمة.
تم الاكتساب من
|
getTargeting
|
عرض مَعلمة استهداف مخصّصة على مستوى الخدمة تم ضبطها.
|
getTargetingKeys
|
تعرض قائمة بجميع مفاتيح الاستهداف المخصّصة على مستوى الخدمة التي تم ضبطها.
|
isInitialLoadDisabled
|
تعرض ما إذا كان قد تم إيقاف الطلبات الأولية للإعلانات بنجاح من خلال مكالمة سابقة على
PubAdsService.disableInitialLoad أم لا.
|
refresh
|
يجلب ويعرض إعلانات جديدة لخانات محدّدة أو كلها على الصفحة.
|
removeEventListener
|
يزيل هذا الخيار مستمعًا سبق تسجيله.
تم الاكتساب من
|
set
|
تحدِّد هذه السياسة قيم سمات AdSense التي تنطبق على جميع الخانات الإعلانية ضمن خدمة "إعلانات الناشر".
|
setCategoryExclusion
|
لضبط استبعاد فئة إعلان على مستوى الصفحة لاسم التصنيف المحدّد.
|
setCentering
|
تعمل هذه السياسة على تفعيل التوسيط الأفقي للإعلانات وإيقافها.
|
setForceSafeFrame
|
تحدِّد هذه السياسة ما إذا كان يجب فرض عرض جميع الإعلانات في الصفحة باستخدام حاوية SafeFrame.
|
setLocation
|
تمرير معلومات الموقع الجغرافي من المواقع الإلكترونية حتى تتمكّن من استهداف العناصر جغرافيًا لمواقع جغرافية معيّنة
|
setPrivacySettings
|
يسمح هذا الإعداد بضبط جميع إعدادات الخصوصية من واجهة برمجة تطبيقات واحدة باستخدام عنصر ضبط.
|
setPublisherProvidedId
|
تحدِّد قيمة رقم التعريف الذي يقدّمه الناشر.
|
setSafeFrameConfig
|
تحدِّد هذه السياسة الإعدادات المفضّلة على مستوى الصفحة لإعداد SafeFrame.
|
setTargeting
|
تضبط هذه الإعدادات مَعلمات استهداف مخصّصة لمفتاح معيّن ينطبق على جميع الخانات الإعلانية لخدمة إعلانات الناشر.
|
setVideoContent
|
تحدِّد هذه السياسة معلومات محتوى الفيديو التي سيتم إرسالها مع طلبات الإعلان، وذلك لأغراض الاستهداف واستبعاد المحتوى.
|
updateCorrelator
|
تعمل هذه السياسة على تغيير الارتباط الذي يتم إرساله مع طلبات الإعلان، ما يؤدي إلى بدء مشاهدة صفحة جديدة بفعالية.
|
clear
-
clear(slots?: Slot[]): boolean
-
يعمل هذا الإجراء على إزالة الإعلانات من الخانات المحدّدة واستبدالها بمحتوى فارغ. سيتم وضع علامة على الخانات بأنّها لم يتم جلبها.
وبالتحديد، يؤدي محو الخانة إلى إزالة الإعلان من مشاهدة الصفحة طويلة الأجل في GPT، لذلك لن تتأثر الطلبات المستقبلية بالعوائق أو الاستثناءات التنافسية التي تتضمّن هذا الإعلان. -
- مثال
-
JavaScript
const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1"); googletag.display("div-1"); const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2"); googletag.display("div-2"); // This call to clear only slot1. googletag.pubads().clear([slot1]); // This call to clear both slot1 and slot2. googletag.pubads().clear([slot1, slot2]); // This call to clear all slots. googletag.pubads().clear();
JavaScript (قديمة)
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();
-
المَعلمات slots?: Slot[]
مجموعة الخانات المطلوب محوها المصفوفة اختيارية، وسيتم محو جميع الفتحات إذا لم يتم تحديدها. -
المرتجعات boolean
تعرض القيمةtrue
إذا تم محو الخانات، أو تعرضfalse
في الحالات الأخرى.
clearCategoryExclusions
-
clearCategoryExclusions(): PubAdsService
-
يؤدي إلى محو كل تصنيفات استبعاد فئات الإعلانات على مستوى الصفحة. ويكون هذا مفيدًا إذا كنت تريد إعادة تحميل الخانة.
-
- مثال
-
JavaScript
// Set category exclusion to exclude ads with 'AirlineAd' labels. googletag.pubads().setCategoryExclusion("AirlineAd"); // Make ad requests. No ad with 'AirlineAd' label will be returned. // Clear category exclusions so all ads can be returned. googletag.pubads().clearCategoryExclusions(); // Make ad requests. Any ad can be returned.
JavaScript (قديمة)
// 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
-
clearTargeting(key?: string): PubAdsService
-
يؤدي هذا الإجراء إلى محو مَعلمات الاستهداف المخصّصة لمفتاح معيّن أو لجميع المفاتيح.
-
- مثال
-
JavaScript
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().setTargeting("colors", "blue"); googletag.pubads().setTargeting("fruits", "apple"); googletag.pubads().clearTargeting("interests"); // Targeting 'colors' and 'fruits' are still present, while 'interests' // was cleared. googletag.pubads().clearTargeting(); // All targeting has been cleared.
JavaScript (قديمة)
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.
- يمكن أيضًا مراجعة
-
المَعلمات key?: string
مفتاح مَعلمة الاستهداف المفتاح اختياري، وسيتم محو جميع معلمات الاستهداف في حال عدم تحديدها. -
المرتجعات PubAdsService
عنصر الخدمة الذي تم استدعاء الطريقة عليه.
collapseEmptyDivs
-
collapseEmptyDivs(collapseBeforeAdFetch?: boolean): boolean
-
تعمل هذه السياسة على تفعيل تصغير عناصر div المضمّنة بحيث لا تشغل أي مساحة على الصفحة في حال عدم توفّر محتوى إعلاني لعرضه. يجب ضبط هذا الوضع قبل تفعيل الخدمة.
-
- يمكن أيضًا مراجعة
-
المَعلمات collapseBeforeAdFetch?: boolean
ما إذا كان يمكن تصغير الخانات حتى قبل استرجاع الإعلانات هذه المَعلمة اختيارية، وفي حال عدم توفيرها، سيتم استخدامfalse
كقيمة تلقائية. -
المرتجعات boolean
تعرض القيمةtrue
في حال تفعيل وضع تصغير القسم "div" وعرض القيمةfalse
إذا كان من المستحيل تفعيل وضع التصغير بسبب استدعاء الطريقة بعد تفعيل الخدمة.
disableInitialLoad
-
disableInitialLoad(): void
-
لإيقاف طلبات الإعلانات عند تحميل الصفحة، مع السماح بطلب الإعلانات من خلال استدعاء
PubAdsService.refresh
. يجب ضبط هذا الخيار قبل تفعيل الخدمة. يجب استخدام وضع غير متزامن، وإلا فلن يكون من الممكن طلب الإعلانات التي تستخدمrefresh
. -
- يمكن أيضًا مراجعة
display
-
display(adUnitPath: string, size: GeneralSize, div?: string | Element, clickUrl?: string): void
-
لإنشاء شريحة إعلانية وعرضها بمسار الوحدة الإعلانية وحجمها. لا تعمل هذه الطريقة مع وضع الطلب الفردي.
ملاحظة: عند استدعاء هذه الطريقة، يتم إنشاء نبذة عن الخانة وحالة الصفحة لضمان الاتساق عند إرسال طلب الإعلان وعرض الاستجابة. أي تغييرات يتم إجراؤها على حالة الخانة أو الصفحة بعد طلب هذه الطريقة (بما في ذلك الاستهداف وإعدادات الخصوصية وفرض SafeFrame، وغيرها) لن تسري إلا على طلباتdisplay()
أوrefresh()
اللاحقة. -
- مثال
-
JavaScript
googletag.pubads().display("/1234567/sports", [728, 90], "div-1");
JavaScript (قديمة)
googletag.pubads().display("/1234567/sports", [728, 90], "div-1");
TypeScript
googletag.pubads().display("/1234567/sports", [728, 90], "div-1");
- يمكن أيضًا مراجعة
-
المَعلمات adUnitPath: string
مسار الوحدة الإعلانية الخاص بالخانة المطلوب عرضها.size: GeneralSize
عرض الخانة وارتفاعهاdiv?: string | Element
معرّف عنصر div الذي يحتوي على الفتحة أو عنصر div نفسه.clickUrl?: string
عنوان URL للنقر لاستخدامه في هذه الشريحة
enableLazyLoad
-
enableLazyLoad(config?: { fetchMarginPercent: number, mobileScaling: number, renderMarginPercent: number }): void
-
تعمل هذه السياسة على تفعيل طريقة "التحميل الكسول" في علامة GPT على النحو المحدّد في عنصر الضبط. للاطّلاع على أمثلة أكثر تفصيلاً، يمكنك الاطّلاع على نموذج التحميل الكسول.
ملاحظة: لا تعمل طريقة الجلب الكسول في SRA إلا إذا كانت جميع الخانات خارج هامش الجلب. -
- مثال
-
JavaScript
googletag.pubads().enableLazyLoad({ // Fetch slots within 5 viewports. fetchMarginPercent: 500, // Render slots within 2 viewports. renderMarginPercent: 200, // Double the above values on mobile. mobileScaling: 2.0, });
JavaScript (قديمة)
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, });
- يمكن أيضًا مراجعة
-
المَعلمات config?: { fetchMarginPercent: number, mobileScaling: number, renderMarginPercent: number }
يسمح كائن الإعدادات بتخصيص السلوك الكسول. ستستخدم أي عمليات ضبط تم حذفها إعدادات تلقائية من قِبل Google سيتم ضبطها بمرور الوقت. لإيقاف إعداد معيّن، مثل استرجاع هامش، اضبط القيمة على-1
.fetchMarginPercent
أدنى مسافة من إطار العرض الحالي يجب أن تكون الخانة قبل أن نسترجع الإعلان كنسبة مئوية من حجم إطار العرض. تعني القيمة 0 "عندما تدخل الشريحة إلى إطار العرض"، تعني القيمة 100 "عندما يكون الإعلان على بعد 1 إطار عرض"، وهكذا.renderMarginPercent
يجب أن تكون الخانة أدنى مسافة من إطار العرض الحالي قبل عرض الإعلان. ويسمح ذلك بجلب الإعلان مسبقًا، ولكن مع انتظار عرض الموارد الفرعية الأخرى وتنزيلها. تعمل القيمة تمامًا مثلfetchMarginPercent
كنسبة مئوية من إطار العرض.mobileScaling
مُضاعِف يتم تطبيقه على الهوامش على الأجهزة الجوّالة. ويسمح ذلك بهوامش متفاوتة على الأجهزة الجوّالة مقارنةً بالكمبيوتر المكتبي. على سبيل المثال، ستؤدي القيمة 2.0 إلى ضرب جميع الهوامش في 2 على الأجهزة الجوّالة، ما يؤدي إلى زيادة الحد الأدنى للمسافة التي يمكن أن تستغرقها الخانة قبل الجلب والعرض.
enableSingleRequest
-
enableSingleRequest(): boolean
-
تُفعِّل وضع الطلب الفردي لجلب إعلانات متعددة في الوقت نفسه. يتطلّب هذا الإجراء تحديد جميع خانات إعلانات الناشرين وإضافتها إلى PubAdsService قبل تفعيل الخدمة. يجب ضبط وضع الطلب الفردي قبل تفعيل الخدمة.
-
المرتجعات boolean
تعرض القيمةtrue
في حال تفعيل وضع الطلب الفردي، وعرضfalse
إذا كان من المستحيل تفعيل وضع الطلب الفردي بسبب استدعاء الطريقة بعد تفعيل الخدمة.
enableVideoAds
-
enableVideoAds(): void
-
إشارات إلى علامة GPT تشير إلى ظهور إعلانات الفيديو على الصفحة. ويتيح ذلك فرض قيود على الاستثناء التنافسي للإعلانات الصورية وإعلانات الفيديو. إذا كان محتوى الفيديو معروفًا، اتصل بـ
PubAdsService.setVideoContent
لتتمكن من استخدام استبعاد المحتوى للإعلانات الصورية. -
get
-
get(key: string): null | string
-
تعرض قيمة سمة AdSense المرتبطة بالمفتاح المحدّد.
-
- مثال
-
JavaScript
googletag.pubads().set("adsense_background_color", "#FFFFFF"); googletag.pubads().get("adsense_background_color"); // Returns '#FFFFFF'.
JavaScript (قديمة)
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
اسم السمة المطلوب البحث عنها. -
المرتجعات null | string
القيمة الحالية لمفتاح السمة أوnull
إذا لم يكن المفتاح متوفّرًا
getAttributeKeys
-
getAttributeKeys(): string[]
-
تعرض مفاتيح السمات التي تم ضبطها في هذه الخدمة.
-
- مثال
-
JavaScript
googletag.pubads().set("adsense_background_color", "#FFFFFF"); googletag.pubads().set("adsense_border_color", "#AABBCC"); googletag.pubads().getAttributeKeys(); // Returns ['adsense_background_color', 'adsense_border_color'].
JavaScript (قديمة)
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[]
-
عرض مَعلمة استهداف مخصّصة على مستوى الخدمة تم ضبطها.
-
- مثال
-
JavaScript
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().getTargeting("interests"); // Returns ['sports']. googletag.pubads().getTargeting("age"); // Returns [] (empty array).
JavaScript (قديمة)
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[]
-
تعرض قائمة بجميع مفاتيح الاستهداف المخصّصة على مستوى الخدمة التي تم ضبطها.
-
- مثال
-
JavaScript
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().setTargeting("colors", "blue"); googletag.pubads().getTargetingKeys(); // Returns ['interests', 'colors'].
JavaScript (قديمة)
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
-
تعرض ما إذا كان قد تم إيقاف الطلبات الأولية للإعلانات بنجاح من خلال مكالمة سابقة على
PubAdsService.disableInitialLoad
أم لا. -
-
المرتجعات boolean
يتم عرضtrue
إذا كانت المكالمة السابقة معPubAdsService.disableInitialLoad
ناجحة، أو عرضfalse
في الحالات الأخرى.
refresh
-
refresh(slots?: null | Slot[], options?: { changeCorrelator: boolean }): void
-
يجلب ويعرض إعلانات جديدة لخانات محدّدة أو كلها على الصفحة. يعمل فقط في وضع العرض غير المتزامن.
لتحقيق السلوك الصحيح على جميع المتصفحات، يجب أن يسبق استدعاءrefresh
طلبdisplay
للخانة الإعلانية. إذا تم حذف الطلب إلى "display
"، قد تعمل عملية إعادة التحميل بشكل غير متوقَّع. يمكن استخدام طريقةPubAdsService.disableInitialLoad
لمنعdisplay
من جلب الإعلانات.
تؤدي إعادة تحميل إحدى الخانات إلى إزالة الإعلان القديم من مشاهدة الصفحة طويلة الأجل في GPT، وبذلك لن تتأثر الطلبات المستقبلية بالعوائق أو الاستثناءات التنافسية التي تتضمّن هذا الإعلان. -
- مثال
-
JavaScript
const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1"); googletag.display("div-1"); const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2"); googletag.display("div-2"); // This call to refresh fetches a new ad for slot1 only. googletag.pubads().refresh([slot1]); // This call to refresh fetches a new ad for both slot1 and slot2. googletag.pubads().refresh([slot1, slot2]); // This call to refresh fetches a new ad for each slot. googletag.pubads().refresh(); // This call to refresh fetches a new ad for slot1, without changing // the correlator. googletag.pubads().refresh([slot1], { changeCorrelator: false }); // This call to refresh fetches a new ad for each slot, without // changing the correlator. googletag.pubads().refresh(null, { changeCorrelator: false });
JavaScript (قديمة)
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 });
- يمكن أيضًا مراجعة
-
المَعلمات slots?: null | Slot[]
الخانات المطلوب إعادة تحميلها المصفوفة اختيارية؛ وسيتم تحديث جميع الشرائح إذا لم يتم تحديدها.options?: { changeCorrelator: boolean }
خيارات التهيئة المرتبطة بطلب التحديث هذا.changeCorrelator
تحدِّد ما إذا كان سيتم إنشاء أداة ربط جديدة لاسترجاع الإعلانات أم لا. تحتفظ خوادم الإعلانات بقيمة المُطابق هذه لفترة وجيزة (حاليًا لمدة 30 ثانية، ولكن تخضع للتغيير)، ولذلك سيتم اعتبار الطلبات التي لها المُطابق نفسه والتي يتم تلقّيها على مقربة منك بمثابة مشاهدة واحدة للصفحة. يتم تلقائيًا إنشاء ارتباط جديد لكل عملية إعادة تحميل.
ملاحظة: لا يؤثر هذا الخيار في مشاهدة الصفحة طويلة الأمد في علامة GPT، والتي تعكس تلقائيًا الإعلانات على الصفحة حاليًا وليس لها وقت انتهاء صلاحية.
set
-
set(key: string, value: string): PubAdsService
-
تحدِّد هذه السياسة قيم سمات AdSense التي تنطبق على جميع الخانات الإعلانية ضمن خدمة "إعلانات الناشر".
سيؤدي استدعاء هذا المفتاح أكثر من مرة للمفتاح نفسه إلى إلغاء القيم التي تم ضبطها سابقًا لهذا المفتاح. يجب ضبط جميع القيم قبل طلبdisplay
أوrefresh
. -
- مثال
-
JavaScript
googletag.pubads().set("adsense_background_color", "#FFFFFF");
JavaScript (قديمة)
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
-
لضبط استبعاد فئة إعلان على مستوى الصفحة لاسم التصنيف المحدّد.
-
- مثال
-
JavaScript
// Label = AirlineAd. googletag.pubads().setCategoryExclusion("AirlineAd");
JavaScript (قديمة)
// Label = AirlineAd. googletag.pubads().setCategoryExclusion("AirlineAd");
TypeScript
// Label = AirlineAd. googletag.pubads().setCategoryExclusion("AirlineAd");
- يمكن أيضًا مراجعة
-
المَعلمات categoryExclusion: string
تصنيف استبعاد فئة الإعلان المطلوب إضافته. -
المرتجعات PubAdsService
عنصر الخدمة الذي تم استدعاء الطريقة عليه.
setCentering
-
setCentering(centerAds: boolean): void
-
تعمل هذه السياسة على تفعيل التوسيط الأفقي للإعلانات وإيقافها. تكون ميزة التوسيط غير مفعّلة تلقائيًا. في gpt_mobile.js القديم، يتم تفعيل التوسيط تلقائيًا.
يجب استدعاء هذه الطريقة قبل استدعاءdisplay
أوrefresh
لأنه لن يتم توسيط سوى الإعلانات المطلوبة بعد استدعاء هذه الطريقة. -
- مثال
-
JavaScript
// Make ads centered. googletag.pubads().setCentering(true);
JavaScript (قديمة)
// Make ads centered. googletag.pubads().setCentering(true);
TypeScript
// Make ads centered. googletag.pubads().setCentering(true);
-
المَعلمات centerAds: boolean
true
للإعلانات في الوسط، وfalse
لمحاذاتها إلى اليسار.
setForceSafeFrame
-
setForceSafeFrame(forceSafeFrame: boolean): PubAdsService
-
تحدِّد هذه السياسة ما إذا كان يجب فرض عرض جميع الإعلانات في الصفحة باستخدام حاوية SafeFrame.
يُرجى وضع الأمور التالية في الاعتبار أثناء استخدام واجهة برمجة التطبيقات هذه:- لن يسري هذا الإعداد إلا على طلبات الإعلانات اللاحقة التي يتم إجراؤها في الخانات المعنية.
- سيؤدي دائمًا إعداد مستوى الخانة، في حال تحديده، إلى تجاوز الإعداد على مستوى الصفحة.
- في حال ضبط هذه السياسة على
true
(على مستوى الشريحة أو على مستوى الصفحة)، سيتم عرض الإعلان دائمًا باستخدام حاوية SafeFrame بشكل مستقل عن الخيار الذي تم تحديده في واجهة مستخدم "مدير إعلانات Google". - ومع ذلك، في حال ضبط الإعلان على
false
أو تركه بدون تحديد، سيتم عرض الإعلان باستخدام حاوية SafeFrame اعتمادًا على نوع تصميم الإعلان والاختيار الذي تم إجراؤه في واجهة مستخدم "مدير إعلانات Google". - ويجب استخدام واجهة برمجة التطبيقات هذه بحذر لأنها قد تؤثر في سلوك تصميمات الإعلانات التي تحاول الانفصال عن إطارات iframe أو التي تعتمد على عرضها مباشرةً في إحدى صفحات الناشرين.
-
- مثال
-
JavaScript
googletag.pubads().setForceSafeFrame(true); // The following slot will be opted-out of the page-level force // SafeFrame instruction. googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setForceSafeFrame(false) .addService(googletag.pubads()); // The following slot will have SafeFrame forced. googletag.defineSlot("/1234567/news", [160, 600], "div-2").addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
JavaScript (قديمة)
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
في حال عدم تحديدها في وقت سابق إلى إجراء أي تغيير. -
المرتجعات PubAdsService
عنصر الخدمة الذي تم استدعاء الدالة عليه.
setLocation
-
setLocation(address: string): PubAdsService
-
تمرير معلومات الموقع الجغرافي من المواقع الإلكترونية حتى تتمكّن من استهداف العناصر جغرافيًا لمواقع جغرافية معيّنة
-
- مثال
-
JavaScript
// Postal code: googletag.pubads().setLocation("10001,US");
JavaScript (قديمة)
// Postal code: googletag.pubads().setLocation("10001,US");
TypeScript
// Postal code: googletag.pubads().setLocation("10001,US");
-
المَعلمات address: string
العنوان بالتنسيق الحر. -
المرتجعات PubAdsService
عنصر الخدمة الذي تم استدعاء الطريقة عليه.
setPrivacySettings
-
setPrivacySettings(privacySettings: PrivacySettingsConfig): PubAdsService
-
يسمح هذا الإعداد بضبط جميع إعدادات الخصوصية من واجهة برمجة تطبيقات واحدة باستخدام عنصر ضبط.
-
- مثال
-
JavaScript
googletag.pubads().setPrivacySettings({ restrictDataProcessing: true, }); // Set multiple privacy settings at the same time. googletag.pubads().setPrivacySettings({ childDirectedTreatment: true, underAgeOfConsent: true, }); // Clear the configuration for childDirectedTreatment. googletag.pubads().setPrivacySettings({ childDirectedTreatment: null, });
JavaScript (قديمة)
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
-
تحدِّد قيمة رقم التعريف الذي يقدّمه الناشر.
-
- مثال
-
JavaScript
googletag.pubads().setPublisherProvidedId("12JD92JD8078S8J29SDOAKC0EF230337");
JavaScript (قديمة)
googletag.pubads().setPublisherProvidedId("12JD92JD8078S8J29SDOAKC0EF230337");
TypeScript
googletag.pubads().setPublisherProvidedId("12JD92JD8078S8J29SDOAKC0EF230337");
- يمكن أيضًا مراجعة
-
المَعلمات ppid: string
معرّف أبجدي رقمي يقدّمه الناشر. يجب أن يتراوح عدد الأحرف بين 32 و150 حرفًا. -
المرتجعات PubAdsService
عنصر الخدمة الذي تم استدعاء الطريقة عليه.
setSafeFrameConfig
-
setSafeFrameConfig(config: SafeFrameConfig): PubAdsService
-
تحدِّد هذه السياسة الإعدادات المفضّلة على مستوى الصفحة لإعداد SafeFrame. وسيتم تجاهل أي مفاتيح غير معروفة في عنصر الضبط. سيتم تجاهل الإعدادات بالكامل في حال ضبط قيمة غير صالحة لمفتاح تم التعرّف عليه.
سيتم إلغاء هذه الإعدادات المفضّلة على مستوى الصفحة من خلال الإعدادات المفضّلة على مستوى الخانة، في حال تحديدها. -
- مثال
-
JavaScript
googletag.pubads().setForceSafeFrame(true); const pageConfig = { allowOverlayExpansion: true, allowPushExpansion: true, sandbox: true, }; const slotConfig = { allowOverlayExpansion: false }; googletag.pubads().setSafeFrameConfig(pageConfig); // The following slot will not allow for expansion by overlay. googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setSafeFrameConfig(slotConfig) .addService(googletag.pubads()); // The following slot will inherit the page level settings, and hence // would allow for expansion by overlay. googletag.defineSlot("/1234567/news", [160, 600], "div-2").addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
JavaScript (قديمة)
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
-
تضبط هذه الإعدادات مَعلمات استهداف مخصّصة لمفتاح معيّن ينطبق على جميع الخانات الإعلانية لخدمة إعلانات الناشر. سيؤدي طلب إجراء ذلك عدة مرات للمفتاح نفسه إلى استبدال القيم القديمة. يتم تحديد هذه المفاتيح في حسابك على "مدير إعلانات Google".
-
- مثال
-
JavaScript
// Example with a single value for a key. googletag.pubads().setTargeting("interests", "sports"); // Example with multiple values for a key inside in an array. googletag.pubads().setTargeting("interests", ["sports", "music"]);
JavaScript (قديمة)
// 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". -
- يمكن أيضًا مراجعة
-
المَعلمات videoContentId: string
معرّف محتوى الفيديوvideoCmsId: string
معرّف نظام إدارة المحتوى (CMS) للفيديو
updateCorrelator
-
updateCorrelator(): PubAdsService
-
تعمل هذه السياسة على تغيير الارتباط الذي يتم إرساله مع طلبات الإعلان، ما يؤدي إلى بدء مشاهدة صفحة جديدة بفعالية. المُطابق هو نفسه لجميع طلبات الإعلان الواردة من مشاهدة واحدة للصفحة، وتكون فريدة عبر مشاهدات الصفحة. لا ينطبق ذلك إلا على وضع غير متزامن.
ملاحظة: لا يؤثر هذا على مشاهدة الصفحة طويلة الأجل في GPT، والتي تعكس تلقائيًا الإعلانات على الصفحة وليس لها وقت انتهاء صلاحية. -
- مثال
-
JavaScript
// Assume that the correlator is currently 12345. All ad requests made // by this page will currently use that value. // Replace the current correlator with a new correlator. googletag.pubads().updateCorrelator(); // The correlator will now be a new randomly selected value, different // from 12345. All subsequent ad requests made by this page will use // the new value.
JavaScript (قديمة)
// 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
يشير ذلك المصطلح إلى كائن يمثّل استجابة واحدة للإعلان.
ملخّص الملكية | |
---|---|
advertiserId
|
رقم تعريف المعلِن.
|
campaignId
|
رقم تعريف الحملة.
|
creativeId
|
رقم تعريف تصميم الإعلان.
|
creativeTemplateId
|
رقم تعريف نموذج الإعلان.
|
lineItemId
|
رقم تعريف العنصر.
|
- يمكن أيضًا مراجعة
advertiserId
-
advertiserId: null | number
-
رقم تعريف المعلِن.
-
campaignId
-
campaignId: null | number
-
رقم تعريف الحملة.
-
creativeId
-
creativeId: null | number
-
رقم تعريف تصميم الإعلان.
-
creativeTemplateId
-
creativeTemplateId: null | number
-
رقم تعريف نموذج الإعلان.
-
lineItemId
-
lineItemId: null | number
-
رقم تعريف العنصر.
-
googletag.RewardedPayload
كائن يمثل المكافأة المرتبطة بإعلان مكافأة
ملخّص الملكية | |
---|---|
amount
|
عدد العناصر في المكافأة.
|
type
|
نوع العنصر في المكافأة (على سبيل المثال، "عملة").
|
- يمكن أيضًا مراجعة
amount
-
amount: number
-
عدد العناصر في المكافأة.
-
type
-
type: string
-
نوع العنصر في المكافأة (على سبيل المثال، "عملة").
-
googletag.SafeFrameConfig
كائن الإعداد لحاويات SafeFrame.
ملخّص الملكية | |
---|---|
allowOverlayExpansion
|
ما إذا كان يجب أن يسمح إطار SafeFrame بتوسيع محتوى الإعلان عن طريق تراكب محتوى الصفحة
|
allowPushExpansion
|
ما إذا كان يجب أن يسمح إطار SafeFrame بتوسيع محتوى الإعلان عن طريق الدفع بمحتوى الصفحة
|
sandbox
|
ما إذا كان يجب على SafeFrame استخدام سمة وضع الحماية HTML5 لمنع التنقّل في المستوى الأعلى بدون تفاعل المستخدم.
|
useUniqueDomain
|
تمّت إزالة هذا العمود.
ما إذا كان يجب أن يستخدم SafeFrame نطاقات فرعية عشوائية لتصميمات الإعلانات المحجوزة.
|
- يمكن أيضًا مراجعة
allowOverlayExpansion
-
allowOverlayExpansion: boolean
-
ما إذا كان يجب أن يسمح إطار SafeFrame بتوسيع محتوى الإعلان عن طريق تراكب محتوى الصفحة
-
allowPushExpansion
-
allowPushExpansion: boolean
-
ما إذا كان يجب أن يسمح إطار SafeFrame بتوسيع محتوى الإعلان عن طريق الدفع بمحتوى الصفحة
-
sandbox
-
sandbox: boolean
-
ما إذا كان يجب على SafeFrame استخدام سمة وضع الحماية HTML5 لمنع التنقّل في المستوى الأعلى بدون تفاعل المستخدم. القيمة الوحيدة الصالحة هي
true
(لا يمكن فرضها علىfalse
). تجدر الإشارة إلى أن سمة وضع الحماية توقف المكوّنات الإضافية (مثل Flash). -
useUniqueDomain
-
useUniqueDomain: null | boolean
-
ما إذا كان يجب أن يستخدم SafeFrame نطاقات فرعية عشوائية لتصميمات الإعلانات المحجوزة. مرِّر
null
لمحو القيمة المخزَّنة.
ملاحظة: تكون هذه الميزة مفعَّلة تلقائيًا. -
- يمكن أيضًا مراجعة
googletag.Service
فئة الخدمة الأساسية التي تحتوي على الطرق الشائعة لجميع الخدمات.
ملخّص الطريقة | |
---|---|
addEventListener
|
يعمل هذا الإعداد على تسجيل أداة معالجة تتيح لك إعداد دالة JavaScript وطلبها عند وقوع حدث GPT معيّن على الصفحة.
|
getSlots
|
احصل على قائمة الخانات المرتبطة بهذه الخدمة.
|
removeEventListener
|
يزيل هذا الخيار مستمعًا سبق تسجيله.
|
addEventListener
-
addEventListener<K extends keyof EventTypeMap>(eventType: K, listener: (arg: EventTypeMap[K]) => void): Service
-
يعمل هذا الإعداد على تسجيل أداة معالجة تتيح لك إعداد دالة JavaScript وطلبها عند وقوع حدث GPT معيّن على الصفحة. تتوفّر الأحداث التالية:
يتم تمرير عنصر من نوع الحدث المناسب إلى المستمع عند استدعائه. -
- مثال
-
JavaScript
// 1. Adding an event listener for the PubAdsService. googletag.pubads().addEventListener("slotOnload", (event) => { console.log("Slot has been loaded:"); console.log(event); }); // 2. Adding an event listener with slot specific logic. // Listeners operate at service level, which means that you cannot add // a listener for an event for a specific slot only. You can, however, // programmatically filter a listener to respond only to a certain ad // slot, using this pattern: const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotOnload", (event) => { if (event.slot === targetSlot) { // Slot specific logic. } });
JavaScript (قديمة)
// 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
عنصر الخدمة الذي تم استدعاء الطريقة عليه.
getSlots
removeEventListener
-
removeEventListener<K extends keyof EventTypeMap>(eventType: K, listener: (event: EventTypeMap[K]) => void): void
-
يزيل هذا الخيار مستمعًا سبق تسجيله.
-
- مثال
-
JavaScript
googletag.cmd.push(() => { // Define a new ad slot. googletag.defineSlot("/6355419/Travel", [728, 90], "div-for-slot").addService(googletag.pubads()); // Define a new function that removes itself via removeEventListener // after the impressionViewable event fires. const onViewableListener = (event) => { googletag.pubads().removeEventListener("impressionViewable", onViewableListener); setTimeout(() => { googletag.pubads().refresh([event.slot]); }, 30000); }; // Add onViewableListener as a listener for impressionViewable events. googletag.pubads().addEventListener("impressionViewable", onViewableListener); googletag.enableServices(); });
JavaScript (قديمة)
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
أداة إنشاء لعناصر مواصفات تعيين الحجم تم توفير أداة الإنشاء هذه للمساعدة في إنشاء مواصفات الحجم بسهولة.
ملخّص الطريقة | |
---|---|
addSize
|
تتم إضافة تعيين من مصفوفة أحادية الحجم (تمثل إطار العرض) إلى مصفوفة أحادية الحجم أو متعددة الحجم تمثل الخانة.
|
build
|
تنشئ مواصفات خريطة الحجم من التعيينات التي تمت إضافتها إلى أداة الإنشاء هذه.
|
- يمكن أيضًا مراجعة
addSize
-
addSize(viewportSize: SingleSizeArray, slotSize: GeneralSize): SizeMappingBuilder
-
تتم إضافة تعيين من مصفوفة أحادية الحجم (تمثل إطار العرض) إلى مصفوفة أحادية الحجم أو متعددة الحجم تمثل الخانة.
-
- مثال
-
JavaScript
// Mapping 1 googletag .sizeMapping() .addSize([1024, 768], [970, 250]) .addSize([980, 690], [728, 90]) .addSize([640, 480], "fluid") .addSize([0, 0], [88, 31]) // All viewports < 640x480 .build(); // Mapping 2 googletag .sizeMapping() .addSize([1024, 768], [970, 250]) .addSize([980, 690], []) .addSize([640, 480], [120, 60]) .addSize([0, 0], []) .build(); // Mapping 2 will not show any ads for the following viewport sizes: // [1024, 768] > size >= [980, 690] and // [640, 480] > size >= [0, 0]
JavaScript (قديمة)
// 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
-
build(): null | SizeMappingArray
-
تنشئ مواصفات خريطة الحجم من التعيينات التي تمت إضافتها إلى أداة الإنشاء هذه.
إذا تم تقديم أي تعيينات غير صالحة، ستعرض هذه الطريقةnull
. بخلاف ذلك، تعرِض المواصفات بالتنسيق الصحيح المطلوب تمريرها إلىSlot.defineSizeMapping
.
ملاحظة: سلوك أداة الإنشاء بعد استدعاء هذه الطريقة غير محدّد. -
-
المرتجعات null | SizeMappingArray
النتيجة التي أنشأتها أداة الإنشاء هذه. يمكن أن يكون صفرًا إذا تم تقديم تعيينات حجم غير صالحة.
googletag.Slot
الشريحة هي كائن يمثل شريحة إعلانية واحدة على الصفحة.
ملخّص الطريقة | |
---|---|
addService
|
إضافة
Service إلى هذه الخانة
|
clearCategoryExclusions
|
يؤدي إلى محو كل تصنيفات استبعاد فئات الإعلانات على مستوى الخانة لهذه الخانة.
|
clearTargeting
|
يؤدي إلى محو معلمات استهداف معيّنة أو كلها على مستوى الشريحة في هذه الخانة.
|
defineSizeMapping
|
لضبط مصفوفة من عمليات الربط من حد أدنى لحجم إطار العرض إلى حجم الخانة لهذه الخانة.
|
get
|
تعرض قيمة سمة AdSense المرتبطة بالمفتاح المحدّد لهذه الخانة.
|
getAdUnitPath
|
تعرض المسار الكامل للوحدة الإعلانية مع رمز الشبكة ومسار الوحدة الإعلانية.
|
getAttributeKeys
|
لعرض قائمة مفاتيح السمات التي تم تعيينها في هذه الخانة.
|
getCategoryExclusions
|
تؤدي إلى عرض تصنيفات استبعاد فئات الإعلانات لهذه الخانة.
|
getResponseInformation
|
تعرِض معلومات استجابة الإعلان.
|
getSlotElementId
|
تعرض رقم تعريف الخانة
div المقدَّمة عند تحديد الخانة.
|
getTargeting
|
لعرض مَعلمة استهداف مخصّص معيّنة تم ضبطها في هذه الخانة.
|
getTargetingKeys
|
عرض قائمة بجميع مفاتيح الاستهداف المخصّص التي تم ضبطها في هذه الخانة
|
set
|
يضبط قيمة لسمة AdSense في هذه الشريحة الإعلانية.
|
setCategoryExclusion
|
لضبط تصنيف استبعاد فئة إعلان على مستوى الخانة في هذه الخانة.
|
setClickUrl
|
لضبط عنوان URL للنقرة الذي ستتم إعادة توجيه المستخدمين إليه بعد النقر على الإعلان.
|
setCollapseEmptyDiv
|
تحدِّد هذه السياسة ما إذا كان يجب إخفاء الخانة
div عند عدم توفُّر إعلان في هذه الشريحة.
|
setConfig
|
لضبط خيارات الضبط العامة لهذه الخانة
|
setForceSafeFrame
|
تحدِّد هذه السياسة ما إذا كان يجب فرض عرض الإعلانات في هذه الخانة باستخدام حاوية SafeFrame.
|
setSafeFrameConfig
|
لضبط الإعدادات المفضّلة على مستوى الخانة لإعدادات SafeFrame.
|
setTargeting
|
لضبط مَعلمة استهداف مخصّص لهذه الخانة.
|
updateTargetingFromMap
|
تحدِّد هذه السياسة مَعلمات استهداف مخصّصة لهذه الخانة، من خريطة المفتاح:القيمة في عنصر JSON.
|
addService
-
إضافة
Service
إلى هذه الخانة -
- مثال
-
JavaScript
googletag.defineSlot("/1234567/sports", [160, 600], "div").addService(googletag.pubads());
JavaScript (قديمة)
googletag.defineSlot("/1234567/sports", [160, 600], "div").addService(googletag.pubads());
TypeScript
googletag.defineSlot("/1234567/sports", [160, 600], "div")!.addService(googletag.pubads());
- يمكن أيضًا مراجعة
-
المَعلمات service: Service
الخدمة التي ستتم إضافتها. -
المرتجعات Slot
كائن الشريحة الذي تم استدعاء الطريقة عليه.
clearCategoryExclusions
-
clearCategoryExclusions(): Slot
-
يؤدي إلى محو كل تصنيفات استبعاد فئات الإعلانات على مستوى الخانة لهذه الخانة.
-
- مثال
-
JavaScript
// Set category exclusion to exclude ads with 'AirlineAd' labels. const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setCategoryExclusion("AirlineAd") .addService(googletag.pubads()); // Make an ad request. No ad with 'AirlineAd' label will be returned // for the slot. // Clear category exclusions so all ads can be returned. slot.clearCategoryExclusions(); // Make an ad request. Any ad can be returned for the slot.
JavaScript (قديمة)
// 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
-
clearTargeting(key?: string): Slot
-
يؤدي إلى محو معلمات استهداف معيّنة أو كلها على مستوى الشريحة في هذه الخانة.
-
- مثال
-
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setTargeting("allow_expandable", "true") .setTargeting("interests", ["sports", "music"]) .setTargeting("color", "red") .addService(googletag.pubads()); slot.clearTargeting("color"); // Targeting 'allow_expandable' and 'interests' are still present, // while 'color' was cleared. slot.clearTargeting(); // All targeting has been cleared.
JavaScript (قديمة)
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.
- يمكن أيضًا مراجعة
-
المَعلمات key?: string
مفتاح مَعلمة الاستهداف المفتاح اختياري، وسيتم محو جميع معلمات الاستهداف في حال عدم تحديدها. -
المرتجعات Slot
كائن الشريحة الذي تم استدعاء الطريقة عليه.
defineSizeMapping
-
defineSizeMapping(sizeMapping: SizeMappingArray): Slot
-
لضبط مصفوفة من عمليات الربط من حد أدنى لحجم إطار العرض إلى حجم الخانة لهذه الخانة.
-
- مثال
-
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); const mapping = googletag .sizeMapping() .addSize([100, 100], [88, 31]) .addSize( [320, 400], [ [320, 50], [300, 50], ] ) .build(); slot.defineSizeMapping(mapping);
JavaScript (قديمة)
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
لإنشائها. تتكوّن كل عملية ربط للحجم من عنصرَين:SingleSizeArray
وGeneralSize
. -
المرتجعات Slot
كائن الشريحة الذي تم استدعاء الطريقة عليه.
get
-
get(key: string): null | string
-
تعرض قيمة سمة AdSense المرتبطة بالمفتاح المحدّد لهذه الخانة. للاطّلاع على سمات مستوى الخدمة المكتسَبة من هذه الخانة، استخدِم
PubAdsService.get
. -
- مثال
-
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .set("adsense_background_color", "#FFFFFF") .addService(googletag.pubads()); slot.get("adsense_background_color"); // Returns '#FFFFFF'.
JavaScript (قديمة)
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
اسم السمة المطلوب البحث عنها. -
المرتجعات null | string
القيمة الحالية لمفتاح السمة أوnull
إذا لم يكن المفتاح متوفّرًا
getAdUnitPath
-
getAdUnitPath(): string
-
تعرض المسار الكامل للوحدة الإعلانية مع رمز الشبكة ومسار الوحدة الإعلانية.
-
- مثال
-
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); slot.getAdUnitPath(); // Returns '/1234567/sports'.
JavaScript (قديمة)
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[]
-
لعرض قائمة مفاتيح السمات التي تم تعيينها في هذه الخانة. للاطّلاع على مفاتيح سمات مستوى الخدمة المكتسبة من خلال هذه الخانة، استخدِم
PubAdsService.getAttributeKeys
. -
- مثال
-
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .set("adsense_background_color", "#FFFFFF") .set("adsense_border_color", "#AABBCC") .addService(googletag.pubads()); slot.getAttributeKeys(); // Returns ['adsense_background_color', 'adsense_border_color'].
JavaScript (قديمة)
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[]
مصفوفة من مفاتيح السمات. الترتيب غير محدد.
getCategoryExclusions
-
getCategoryExclusions(): string[]
-
تؤدي إلى عرض تصنيفات استبعاد فئات الإعلانات لهذه الخانة.
-
- مثال
-
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setCategoryExclusion("AirlineAd") .setCategoryExclusion("TrainAd") .addService(googletag.pubads()); slot.getCategoryExclusions(); // Returns ['AirlineAd', 'TrainAd'].
JavaScript (قديمة)
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[]
تصنيفات استبعاد فئات الإعلانات لهذه الخانة، أو مصفوفة فارغة في حال عدم تحديد أيّ منها.
getResponseInformation
-
getResponseInformation(): null | ResponseInformation
-
تعرِض معلومات استجابة الإعلان. ويعتمد ذلك على آخر استجابة للإعلان للخانة الإعلانية. في حال طلب ذلك عندما لا تحتوي الخانة على إعلان، سيتم عرض
null
. -
-
المرتجعات null | ResponseInformation
أحدث معلومات استجابة الإعلان، أوnull
إذا كانت الخانة لا تحتوي على إعلان.
getSlotElementId
-
getSlotElementId(): string
-
تعرض رقم تعريف الخانة
div
المقدَّمة عند تحديد الخانة. -
- مثال
-
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); slot.getSlotElementId(); // Returns 'div-1'.
JavaScript (قديمة)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); slot.getSlotElementId(); // Returns 'div-1'.
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); slot.getSlotElementId(); // Returns 'div-1'.
-
المرتجعات string
رقم تعريف الخانةdiv
getTargeting
-
getTargeting(key: string): string[]
-
لعرض مَعلمة استهداف مخصّص معيّنة تم ضبطها في هذه الخانة. لا يتمّ تضمين مَعلمات الاستهداف على مستوى الخدمة.
-
- مثال
-
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setTargeting("allow_expandable", "true") .addService(googletag.pubads()); slot.getTargeting("allow_expandable"); // Returns ['true']. slot.getTargeting("age"); // Returns [] (empty array).
JavaScript (قديمة)
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[]
-
عرض قائمة بجميع مفاتيح الاستهداف المخصّص التي تم ضبطها في هذه الخانة لا يتم تضمين مفاتيح الاستهداف على مستوى الخدمة.
-
- مثال
-
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setTargeting("allow_expandable", "true") .setTargeting("interests", ["sports", "music"]) .addService(googletag.pubads()); slot.getTargetingKeys(); // Returns ['interests', 'allow_expandable'].
JavaScript (قديمة)
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
-
set(key: string, value: string): Slot
-
يضبط قيمة لسمة AdSense في هذه الشريحة الإعلانية. سيؤدي هذا الإجراء إلى إلغاء أي قيم تم ضبطها على مستوى الخدمة لهذا المفتاح.
سيؤدي استدعاء هذه الطريقة أكثر من مرة للمفتاح نفسه إلى إلغاء القيم التي تم ضبطها سابقًا لهذا المفتاح. يجب ضبط جميع القيم قبل طلبdisplay
أوrefresh
. -
- مثال
-
JavaScript
// Setting an attribute on a single ad slot. googletag .defineSlot("/1234567/sports", [160, 600], "div") .set("adsense_background_color", "#FFFFFF") .addService(googletag.pubads());
JavaScript (قديمة)
// 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
كائن الشريحة الذي تم استدعاء الطريقة عليه.
setCategoryExclusion
-
setCategoryExclusion(categoryExclusion: string): Slot
-
لضبط تصنيف استبعاد فئة إعلان على مستوى الخانة في هذه الخانة.
-
- مثال
-
JavaScript
// Label = AirlineAd googletag .defineSlot("/1234567/sports", [160, 600], "div") .setCategoryExclusion("AirlineAd") .addService(googletag.pubads());
JavaScript (قديمة)
// 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
تصنيف استبعاد فئة الإعلان المطلوب إضافته. -
المرتجعات Slot
كائن الشريحة الذي تم استدعاء الطريقة عليه.
setClickUrl
-
setClickUrl(value: string): Slot
-
لضبط عنوان URL للنقرة الذي ستتم إعادة توجيه المستخدمين إليه بعد النقر على الإعلان.
ستظل خوادم "مدير إعلانات Google" تسجِّل النقرة حتى إذا تم استبدال عنوان URL للنقرة. يتم إلحاق أي عنوان URL لصفحة مقصودة مرتبط بتصميم الإعلان المعروض بالقيمة المقدمة. ويتم استبدال القيمة في الطلبات اللاحقة. وينطبق ذلك فقط على الطلبات غير التابعة لـ SRA. -
- مثال
-
JavaScript
googletag .defineSlot("/1234567/sports", [160, 600], "div") .setClickUrl("http://www.example.com?original_click_url=") .addService(googletag.pubads());
JavaScript (قديمة)
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
عند عدم توفُّر إعلان في هذه الشريحة. يؤدي هذا إلى إلغاء إعدادات مستوى الخدمة. -
- مثال
-
JavaScript
googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setCollapseEmptyDiv(true, true) .addService(googletag.pubads()); // The above will cause the div for this slot to be collapsed // when the page is loaded, before ads are requested. googletag .defineSlot("/1234567/sports", [160, 600], "div-2") .setCollapseEmptyDiv(true) .addService(googletag.pubads()); // The above will cause the div for this slot to be collapsed // only after GPT detects that no ads are available for the slot.
JavaScript (قديمة)
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
ما إذا كان سيتم تصغير الخانة في حال عدم عرض أي إعلان.collapseBeforeAdFetch?: boolean
ما إذا كان سيتم تصغير الخانة حتى قبل استرجاع الإعلان يتم تجاهل السياسة إذا لم تكن التصغيرtrue
. -
المرتجعات Slot
كائن الشريحة الذي تم استدعاء الطريقة عليه.
setConfig
-
setConfig(slotConfig: SlotSettingsConfig): void
-
لضبط خيارات الضبط العامة لهذه الخانة
-
-
المَعلمات slotConfig: SlotSettingsConfig
كائن التهيئة.
setForceSafeFrame
-
setForceSafeFrame(forceSafeFrame: boolean): Slot
-
تحدِّد هذه السياسة ما إذا كان يجب فرض عرض الإعلانات في هذه الخانة باستخدام حاوية SafeFrame.
يُرجى وضع الأمور التالية في الاعتبار أثناء استخدام واجهة برمجة التطبيقات هذه:- لن يسري هذا الإعداد إلا على طلبات الإعلانات اللاحقة التي يتم إجراؤها في الخانات المعنية.
- سيؤدي دائمًا إعداد مستوى الخانة، في حال تحديده، إلى تجاوز الإعداد على مستوى الصفحة.
- في حال ضبط هذه السياسة على
true
(على مستوى الشريحة أو على مستوى الصفحة)، سيتم عرض الإعلان دائمًا باستخدام حاوية SafeFrame بشكل مستقل عن الخيار الذي تم تحديده في واجهة مستخدم "مدير إعلانات Google". - ومع ذلك، في حال ضبط الإعلان على
false
أو تركه بدون تحديد، سيتم عرض الإعلان باستخدام حاوية SafeFrame اعتمادًا على نوع تصميم الإعلان والاختيار الذي تم إجراؤه في واجهة مستخدم "مدير إعلانات Google". - ويجب استخدام واجهة برمجة التطبيقات هذه بحذر لأنها قد تؤثر في سلوك تصميمات الإعلانات التي تحاول الانفصال عن إطارات iframe أو التي تعتمد على عرضها مباشرةً في إحدى صفحات الناشرين.
-
- مثال
-
JavaScript
googletag .defineSlot("/1234567/sports", [160, 600], "div") .setForceSafeFrame(true) .addService(googletag.pubads());
JavaScript (قديمة)
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: null | SafeFrameConfig): Slot
-
لضبط الإعدادات المفضّلة على مستوى الخانة لإعدادات SafeFrame. وسيتم تجاهل أي مفاتيح غير معروفة في عنصر الضبط. سيتم تجاهل الإعدادات بالكامل في حال ضبط قيمة غير صالحة لمفتاح تم التعرّف عليه.
هذه الإعدادات المفضّلة على مستوى الخانة، إذا تم تحديدها، ستلغي أي إعدادات مفضّلة على مستوى الصفحة. -
- مثال
-
JavaScript
googletag.pubads().setForceSafeFrame(true); // The following slot will have a sandboxed safeframe that only // disallows top-level navigation. googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setSafeFrameConfig({ sandbox: true }) .addService(googletag.pubads()); // The following slot will inherit page-level settings. googletag.defineSlot("/1234567/news", [160, 600], "div-2").addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
JavaScript (قديمة)
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: null | SafeFrameConfig
كائن التهيئة. -
المرتجعات Slot
كائن الشريحة الذي تم استدعاء الطريقة عليه.
setTargeting
-
setTargeting(key: string, value: string | string[]): Slot
-
لضبط مَعلمة استهداف مخصّص لهذه الخانة. سيؤدي استدعاء هذه الطريقة عدة مرات للمفتاح نفسه إلى استبدال القيم القديمة. ستحلّ القيم المحدّدة هنا محلّ مَعلمات الاستهداف المضبوطة على مستوى الخدمة. يتم تحديد هذه المفاتيح في حسابك على "مدير إعلانات Google".
-
- مثال
-
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Example with a single value for a key. slot.setTargeting("allow_expandable", "true"); // Example with multiple values for a key inside in an array. slot.setTargeting("interests", ["sports", "music"]);
JavaScript (قديمة)
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
-
updateTargetingFromMap(map: { [adUnitPath: string]: string | string[] }): Slot
-
تحدِّد هذه السياسة مَعلمات استهداف مخصّصة لهذه الخانة، من خريطة المفتاح:القيمة في عنصر JSON. يشبه ذلك استدعاء
Slot.setTargeting
لجميع القيم الرئيسية للكائن. يتم تحديد هذه المفاتيح في حسابك على "مدير إعلانات Google".
ملاحظات:- في حال الاستبدال، سيتم الاحتفاظ بالقيمة الأخيرة فقط.
- إذا كانت القيمة صفيفًا، فسيتم استبدال أي قيمة سابقة ولن يتم دمجها.
- ستحلّ القيم المحدّدة هنا محلّ مَعلمات الاستهداف المضبوطة على مستوى الخدمة.
-
- مثال
-
JavaScript
const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div"); slot.updateTargetingFromMap({ color: "red", interests: ["sports", "music", "movies"], });
JavaScript (قديمة)
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: { [adUnitPath: string]: string | string[] }
ربط مَعلمة الاستهداف key:value -
المرتجعات Slot
كائن الشريحة الذي تم استدعاء الطريقة عليه.
googletag.config.AdExpansionConfig
الإعدادات للتحكُّم في توسيع الإعلان
ملخّص الملكية | |
---|---|
enabled
|
ما إذا كانت ميزة توسيع الإعلان مفعَّلة أو غير مفعَّلة.
|
- مثال
-
JavaScript
// Enable ad slot expansion across the entire page. googletag.setConfig({ adExpansion: { enabled: true }, });
JavaScript (قديمة)
// 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 }, });
enabled
-
enabled: boolean
-
ما إذا كانت ميزة توسيع الإعلان مفعَّلة أو غير مفعَّلة.
يؤدي ضبط هذه القيمة إلى إلغاء الإعدادات التلقائية التي تم ضبطها في "مدير إعلانات Google".
googletag.config.ComponentAuctionConfig
عنصر يمثّل مزادًا فيه مكوّن واحد فقط في مزاد إعلانات على الجهاز فقط.
ملخّص الملكية | |
---|---|
auctionConfig
|
كائن إعداد مزاد لمزاد المكوِّن هذا.
|
configKey
|
مفتاح الإعداد المرتبط بمزاد المكوِّن هذا.
|
- يمكن أيضًا مراجعة
auctionConfig
-
auctionConfig: null | { 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
" المحدَّد. -
- مثال
-
JavaScript
const componentAuctionConfig = { // Seller URL should be https and the same as decisionLogicUrl's origin seller: "https://testSeller.com", decisionLogicUrl: "https://testSeller.com/ssp/decision-logic.js", interestGroupBuyers: ["https://example-buyer.com"], auctionSignals: { auction_signals: "auction_signals" }, sellerSignals: { seller_signals: "seller_signals" }, perBuyerSignals: { // listed on interestGroupBuyers "https://example-buyer.com": { per_buyer_signals: "per_buyer_signals", }, }, }; const auctionSlot = googletag.defineSlot("/1234567/example", [160, 600]); // To add configKey to the component auction: auctionSlot.setConfig({ componentAuction: [ { configKey: "https://testSeller.com", auctionConfig: componentAuctionConfig, }, ], }); // To remove configKey from the component auction: auctionSlot.setConfig({ componentAuction: [ { configKey: "https://testSeller.com", auctionConfig: null, }, ], });
JavaScript (قديمة)
var componentAuctionConfig = { // Seller URL should be https and the same as decisionLogicUrl's origin seller: "https://testSeller.com", decisionLogicUrl: "https://testSeller.com/ssp/decision-logic.js", interestGroupBuyers: ["https://example-buyer.com"], auctionSignals: { auction_signals: "auction_signals" }, sellerSignals: { seller_signals: "seller_signals" }, perBuyerSignals: { // listed on interestGroupBuyers "https://example-buyer.com": { per_buyer_signals: "per_buyer_signals", }, }, }; var auctionSlot = googletag.defineSlot("/1234567/example", [160, 600]); // To add configKey to the component auction: auctionSlot.setConfig({ componentAuction: [ { configKey: "https://testSeller.com", auctionConfig: componentAuctionConfig, }, ], }); // To remove configKey from the component auction: auctionSlot.setConfig({ componentAuction: [ { configKey: "https://testSeller.com", auctionConfig: null, }, ], });
TypeScript
const componentAuctionConfig = { // Seller URL should be https and the same as decisionLogicUrl's origin seller: "https://testSeller.com", decisionLogicUrl: "https://testSeller.com/ssp/decision-logic.js", interestGroupBuyers: ["https://example-buyer.com"], auctionSignals: { auction_signals: "auction_signals" }, sellerSignals: { seller_signals: "seller_signals" }, perBuyerSignals: { // listed on interestGroupBuyers "https://example-buyer.com": { per_buyer_signals: "per_buyer_signals", }, }, }; const auctionSlot = googletag.defineSlot("/1234567/example", [160, 600])!; // To add configKey to the component auction: auctionSlot.setConfig({ componentAuction: [ { configKey: "https://testSeller.com", auctionConfig: componentAuctionConfig, }, ], }); // To remove configKey from the component auction: auctionSlot.setConfig({ componentAuction: [ { configKey: "https://testSeller.com", auctionConfig: null, }, ], });
- يمكن أيضًا مراجعة
configKey
-
configKey: string
-
مفتاح الإعداد المرتبط بمزاد المكوِّن هذا.
يجب أن تكون هذه القيمة غير فارغة ويجب أن تكون فريدة. إذا كان كائنانComponentAuctionConfig
يتشاركان قيمة configKey نفسها، سيحلّ العنصر الأخير الذي سيتم ضبطه محلّ الإعدادات السابقة. -
googletag.config.InterstitialConfig
يشير ذلك المصطلح إلى كائن يحدِّد سلوك شريحة إعلانية بينية واحدة.
ملخّص الملكية | |
---|---|
triggers
|
إعداد مشغِّل الإعلان البيني لهذا الإعلان البيني
|
triggers
-
triggers: Partial<Record<InterstitialTrigger, boolean>>
-
سيتم تفعيل إعداد مشغِّل الإعلانات البينية لهذا الإعلان البيني.
سيؤدي ضبط قيمة المشغِّل البيني علىtrue
إلى تفعيله وسيوقفهfalse
. وسيؤدي هذا إلى إلغاء القيم التلقائية التي تم ضبطها في "مدير إعلانات Google". -
- مثال
-
JavaScript
// Define a GPT managed web interstitial ad slot. const interstitialSlot = googletag.defineOutOfPageSlot( "/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL ); // Enable optional interstitial triggers. // Change this value to false to disable. const enableTriggers = true; interstitialSlot.setConfig({ interstitial: { triggers: { navBar: enableTriggers, unhideWindow: enableTriggers, }, }, });
JavaScript (قديمة)
// 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.PageSettingsConfig
واجهة الإعداد الرئيسية للإعدادات على مستوى الصفحة.
يسمح هذا الإعداد بإعداد ميزات متعددة من خلال طلب بيانات واحد من واجهة برمجة التطبيقات.
جميع المواقع المدرَجة أدناه هي أمثلة ولا تعكس الميزات الفعلية التي تستخدم setConfig. للاطّلاع على مجموعة الميزات، اطّلِع على الحقول ضمن نوع PageSettingsConfig أدناه.
أمثلة:
- لا يتم تعديل سوى الميزات المحددة في طلب
setConfig
.// Configure feature alpha. googletag.setConfig({ alpha: {...} }); // Configure feature bravo. Feature alpha is unchanged. googletag.setConfig({ bravo: {...} });
- يتم تعديل جميع الإعدادات الخاصة بميزة معيّنة مع كل مكالمة إلى الرقم
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, });
ملخّص الملكية | |
---|---|
adExpansion
|
الإعدادات للتحكُّم في توسيع الإعلان
|
pps
|
إعدادات التحكّم في الإشارات المقدَّمة من الناشر (PPS)
|
privacyTreatments
|
إعدادات للتحكّم في معالجة خصوصية الناشرين
|
adExpansion
-
adExpansion: null | AdExpansionConfig
-
الإعدادات للتحكُّم في توسيع الإعلان
-
pps
-
pps: null | PublisherProvidedSignalsConfig
-
إعدادات التحكّم في الإشارات المقدَّمة من الناشر (PPS)
-
privacyTreatments
-
privacyTreatments: null | PrivacyTreatmentsConfig
-
إعدادات للتحكّم في معالجة خصوصية الناشرين
-
googletag.config.PrivacyTreatmentsConfig
إعدادات للتحكّم في معالجة خصوصية الناشرين
ملخّص الملكية | |
---|---|
treatments
|
مجموعة من إجراءات خصوصية الناشرين التي يمكن تفعيلها.
|
treatments
-
treatments: "disablePersonalization"[]
-
مجموعة من إجراءات خصوصية الناشرين التي يمكن تفعيلها.
-
- مثال
-
JavaScript
// Disable personalization across the entire page. googletag.setConfig({ privacyTreatments: { treatments: ["disablePersonalization"] }, });
JavaScript (قديمة)
// Disable personalization across the entire page. googletag.setConfig({ privacyTreatments: { treatments: ["disablePersonalization"] }, });
TypeScript
// Disable personalization across the entire page. googletag.setConfig({ privacyTreatments: { treatments: ["disablePersonalization"] }, });
googletag.config.PublisherProvidedSignalsConfig
عنصر إعداد الإشارات المقدَّمة من الناشر (PPS)
ملخّص الملكية | |
---|---|
taxonomies
|
كائن يحتوي على تعيينات التصنيف.
|
- مثال
-
JavaScript
googletag.setConfig({ pps: { taxonomies: { IAB_AUDIENCE_1_1: { values: ["6", "626"] }, // '6' = 'Demographic | Age Range | 18-20' // '626' = 'Interest | Sports | Darts' IAB_CONTENT_2_2: { values: ["48", "127"] }, // '48' = 'Books and Literature | Fiction' // '127' = 'Careers | Job Search' }, }, });
JavaScript (قديمة)
googletag.setConfig({ pps: { taxonomies: { IAB_AUDIENCE_1_1: { values: ["6", "626"] }, // '6' = 'Demographic | Age Range | 18-20' // '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 | 18-20' // '626' = 'Interest | Sports | Darts' IAB_CONTENT_2_2: { values: ["48", "127"] }, // '48' = 'Books and Literature | Fiction' // '127' = 'Careers | Job Search' }, }, });
- يمكن أيضًا مراجعة
taxonomies
-
taxonomies: Partial<Record<Taxonomy, TaxonomyData>>
-
كائن يحتوي على تعيينات التصنيف.
-
googletag.config.SlotSettingsConfig
واجهة الإعدادات الرئيسية للإعدادات على مستوى الخانة.
يسمح هذا الإعداد بإعداد ميزات متعددة من خلال طلب بيانات واحد من واجهة برمجة التطبيقات لفتحة واحدة.
جميع السمات المدرَجة أدناه هي أمثلة ولا تعكس الميزات الفعلية التي تستخدم setConfig. للاطّلاع على مجموعة الميزات، اطّلِع على الحقول ضمن نوع StreamSettingsConfig أدناه.
أمثلة:
- لا يتم تعديل سوى الميزات المحددة في طلب
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, });
ملخّص الملكية | |
---|---|
adExpansion
|
الإعدادات للتحكُّم في توسيع الإعلان
|
componentAuction
|
تمثّل هذه السمة مصفوفة من مزادات المكوّنات التي سيتم تضمينها في مزاد إعلانات على الجهاز فقط.
|
interstitial
|
الإعدادات التي تتحكم في سلوك الشريحة الإعلانية البينية.
|
adExpansion
-
adExpansion: AdExpansionConfig
-
الإعدادات للتحكُّم في توسيع الإعلان
-
componentAuction
-
componentAuction: ComponentAuctionConfig[]
-
تمثّل هذه السمة مصفوفة من مزادات المكوّنات التي سيتم تضمينها في مزاد إعلانات على الجهاز فقط.
-
interstitial
-
interstitial: InterstitialConfig
-
الإعدادات التي تتحكم في سلوك الشريحة الإعلانية البينية.
-
googletag.config.TaxonomyData
كائن يحتوي على قيم تصنيف واحد.
ملخّص الملكية | |
---|---|
values
|
قائمة بقيم التصنيف
|
values
-
values: string[]
-
قائمة بقيم التصنيف
-
googletag.events.Event
الواجهة الأساسية لجميع أحداث GPT ستحتوي جميع أحداث GPT أدناه على الحقول التالية.
ملخّص الملكية | |
---|---|
serviceName
|
اسم الخدمة التي أدت إلى تشغيل الحدث.
|
slot
|
الخانة التي أدت إلى تشغيل الحدث.
|
- يمكن أيضًا مراجعة
serviceName
-
serviceName: string
-
اسم الخدمة التي أدت إلى تشغيل الحدث.
-
slot
-
slot: Slot
-
الخانة التي أدت إلى تشغيل الحدث.
-
googletag.events.EventTypeMap
هذا نوع زائف يربط اسم حدث بنوع عنصر الحدث المقابل له في Service.addEventListener
وService.removeEventListener
. وقد تم توثيقها لأغراض متعلقة بالأمان وكتابة المراجعات فقط.
ملخّص الملكية | |
---|---|
impressionViewable
|
عنوان البريد الإلكتروني البديل لـ
events.ImpressionViewableEvent .
|
rewardedSlotClosed
|
عنوان البريد الإلكتروني البديل لـ
events.RewardedSlotClosedEvent .
|
rewardedSlotGranted
|
عنوان البريد الإلكتروني البديل لـ
events.RewardedSlotGrantedEvent .
|
rewardedSlotReady
|
عنوان البريد الإلكتروني البديل لـ
events.RewardedSlotReadyEvent .
|
slotOnload
|
عنوان البريد الإلكتروني البديل لـ
events.SlotOnloadEvent .
|
slotRenderEnded
|
عنوان البريد الإلكتروني البديل لـ
events.SlotRenderEndedEvent .
|
slotRequested
|
عنوان البريد الإلكتروني البديل لـ
events.SlotRequestedEvent .
|
slotResponseReceived
|
عنوان البريد الإلكتروني البديل لـ
events.SlotResponseReceived .
|
slotVisibilityChanged
|
عنوان البريد الإلكتروني البديل لـ
events.SlotVisibilityChangedEvent .
|
impressionViewable
-
impressionViewable: ImpressionViewableEvent
-
عنوان البريد الإلكتروني البديل لـ
events.ImpressionViewableEvent
. -
rewardedSlotClosed
-
rewardedSlotClosed: RewardedSlotClosedEvent
-
عنوان البريد الإلكتروني البديل لـ
events.RewardedSlotClosedEvent
. -
rewardedSlotGranted
-
rewardedSlotGranted: RewardedSlotGrantedEvent
-
عنوان البريد الإلكتروني البديل لـ
events.RewardedSlotGrantedEvent
. -
rewardedSlotReady
-
rewardedSlotReady: RewardedSlotReadyEvent
-
عنوان البريد الإلكتروني البديل لـ
events.RewardedSlotReadyEvent
. -
slotOnload
-
slotOnload: SlotOnloadEvent
-
عنوان البريد الإلكتروني البديل لـ
events.SlotOnloadEvent
. -
slotRenderEnded
-
slotRenderEnded: SlotRenderEndedEvent
-
عنوان البريد الإلكتروني البديل لـ
events.SlotRenderEndedEvent
. -
slotRequested
-
slotRequested: SlotRequestedEvent
-
عنوان البريد الإلكتروني البديل لـ
events.SlotRequestedEvent
. -
slotResponseReceived
-
slotResponseReceived: SlotResponseReceived
-
عنوان البريد الإلكتروني البديل لـ
events.SlotResponseReceived
. -
slotVisibilityChanged
-
slotVisibilityChanged: SlotVisibilityChangedEvent
-
عنوان البريد الإلكتروني البديل لـ
events.SlotVisibilityChangedEvent
. -
googletag.events.ImpressionViewableEvent
يمتد
يتم تنشيط هذا الحدث عندما تصبح مرة الظهور قابلة للعرض، وفقًا لمعايير العرض النشط.
ملخّص الملكية | |
---|---|
serviceName
|
اسم الخدمة التي أدت إلى تشغيل الحدث.
تم الاكتساب من
|
slot
|
الخانة التي أدت إلى تشغيل الحدث.
تم الاكتساب من
|
- مثال
-
JavaScript
// 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 (قديمة)
// 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
يمتد
يتم تنشيط هذا الحدث عندما يغلق المستخدم خانة إعلان يضمّ مكافأة. وقد يتم تنشيطها إما قبل منح المكافأة أو بعدها. لتحديد ما إذا تم منح المكافأة، استخدِم events.RewardedSlotGrantedEvent
بدلاً من ذلك.
ملخّص الملكية | |
---|---|
serviceName
|
اسم الخدمة التي أدت إلى تشغيل الحدث.
تم الاكتساب من
|
slot
|
الخانة التي أدت إلى تشغيل الحدث.
تم الاكتساب من
|
- مثال
-
JavaScript
// This listener is called when the user closes a rewarded ad slot. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); 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 (قديمة)
// This listener is called when the user closes a rewarded ad slot. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); 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
// This listener is called when the user closes a rewarded ad slot. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); 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
يمتد
يتم تنشيط هذا الحدث عند منح مكافأة مقابل مشاهدة إعلان بمكافأة. إذا تم إغلاق الإعلان قبل استيفاء معايير منح المكافأة، لن يتم تنشيط هذا الحدث.
ملخّص الملكية | |
---|---|
payload
|
عنصر يحتوي على معلومات حول المكافأة التي تم منحها
|
serviceName
|
اسم الخدمة التي أدت إلى تشغيل الحدث.
تم الاكتساب من
|
slot
|
الخانة التي أدت إلى تشغيل الحدث.
تم الاكتساب من
|
- مثال
-
JavaScript
// This listener is called whenever a reward is granted for a // rewarded ad. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); 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 (قديمة)
// This listener is called whenever a reward is granted for a // rewarded ad. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); 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
// This listener is called whenever a reward is granted for a // rewarded ad. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); 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
-
payload: null | RewardedPayload
-
عنصر يحتوي على معلومات حول المكافأة التي تم منحها
-
googletag.events.RewardedSlotReadyEvent
يمتد
يتم تنشيط هذا الحدث عندما يكون إعلان مكافأة جاهزًا للعرض. ويتحمل الناشر مسؤولية تقديم خيار عرض الإعلان للمستخدم قبل عرضه.
ملخّص الملكية | |
---|---|
serviceName
|
اسم الخدمة التي أدت إلى تشغيل الحدث.
تم الاكتساب من
|
slot
|
الخانة التي أدت إلى تشغيل الحدث.
تم الاكتساب من
|
ملخّص الطريقة | |
---|---|
makeRewardedVisible
|
تعرِض هذه السمة الإعلان الذي يضم مكافأة.
|
- مثال
-
JavaScript
// This listener is called when a rewarded ad slot becomes ready to be // displayed. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); 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 (قديمة)
// This listener is called when a rewarded ad slot becomes ready to be // displayed. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); 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.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("rewardedSlotReady", (event) => { const slot = event.slot; console.log("Rewarded ad slot", slot.getSlotElementId(), "is ready to be displayed."); // Replace with custom logic. const userHasConsented = true; if (userHasConsented) { event.makeRewardedVisible(); } if (slot === targetSlot) { // Slot specific logic. } });
- يمكن أيضًا مراجعة
makeRewardedVisible
-
makeRewardedVisible(): void
-
تعرِض هذه السمة الإعلان الذي يضم مكافأة. وينبغي ألا يتم استدعاء هذه الطريقة إلى أن يوافق المستخدم على عرض الإعلان.
-
googletag.events.SlotOnloadEvent
يمتد
يتم تنشيط هذا الحدث عندما ينشط إطار iframe لتصميم الإعلان حدث التحميل. عند عرض إعلانات الوسائط الغنية في وضع العرض المتزامن، لا يتم استخدام إطار iframe، وبالتالي لن يتم تنشيط SlotOnloadEvent
.
ملخّص الملكية | |
---|---|
serviceName
|
اسم الخدمة التي أدت إلى تشغيل الحدث.
تم الاكتساب من
|
slot
|
الخانة التي أدت إلى تشغيل الحدث.
تم الاكتساب من
|
- مثال
-
JavaScript
// 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 (قديمة)
// 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
يمتد
يتم تنشيط هذا الحدث عند إدخال رمز تصميم الإعلان في خانة. وسيحدث هذا الحدث قبل استرجاع موارد تصميم الإعلان، لذا قد لا يظهر تصميم الإعلان بعد. إذا كنت بحاجة إلى معرفة وقت انتهاء تحميل جميع موارد تصميمات الإعلانات لأحد الخانات، ننصحك باستخدام events.SlotOnloadEvent
بدلاً من ذلك.
ملخّص الملكية | |
---|---|
advertiserId
|
الرقم التعريفي للمعلِن للإعلان المعروض
|
campaignId
|
رقم تعريف الحملة الخاص بالإعلان المعروض
|
companyIds
|
أرقام تعريف الشركات التي تقدّم عروض أسعار على إعلان إعادة التعبئة المعروض.
|
creativeId
|
رقم تعريف تصميم الإعلان الخاص بالإعلان المحجوزة والمعروض.
|
creativeTemplateId
|
رقم تعريف نموذج تصميم الإعلان الخاص بالإعلان الحجزي المعروض.
|
isBackfill
|
ما إذا كان الإعلان عبارة عن إعادة تعبئة
|
isEmpty
|
ما إذا تم عرض إعلان للخانة أم لا.
|
labelIds
|
أرقام تعريف تصنيفات الإعلان المعروض
|
lineItemId
|
رقم تعريف العنصر في الإعلان الحجزي المعروض.
|
serviceName
|
اسم الخدمة التي أدت إلى تشغيل الحدث.
تم الاكتساب من
|
size
|
يشير إلى حجم البكسل لتصميم الإعلان المعروض.
|
slot
|
الخانة التي أدت إلى تشغيل الحدث.
تم الاكتساب من
|
slotContentChanged
|
ما إذا تم تغيير محتوى الخانة مع الإعلان المعروض
|
sourceAgnosticCreativeId
|
رقم تعريف تصميم الإعلان للحجز المعروض أو إعلان إعادة التعبئة.
|
sourceAgnosticLineItemId
|
رقم تعريف العنصر الخاص بالإعلان المعروض أو إعلان إعادة التعبئة.
|
yieldGroupIds
|
أرقام تعريف مجموعات الشبكات الإعلانية المدِرّة للأرباح لإعلان إعادة التعبئة المعروض.
|
- مثال
-
JavaScript
// 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("Label IDs:", event.labelIds); 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 (قديمة)
// 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("Label IDs:", event.labelIds); 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("Label IDs:", event.labelIds); 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: null | number
-
الرقم التعريفي للمعلِن للإعلان المعروض القيمة هي
null
للخانات الفارغة والإعلانات عند إضافة البيانات السابقة وتصميمات الإعلانات التي تعرضها خدمات أخرى غيرPubAdsService
. -
campaignId
-
campaignId: null | number
-
رقم تعريف الحملة الخاص بالإعلان المعروض القيمة هي
null
للخانات الفارغة والإعلانات عند إضافة البيانات السابقة وتصميمات الإعلانات التي تعرضها خدمات أخرى غيرPubAdsService
. -
companyIds
-
companyIds: null | number[]
-
أرقام تعريف الشركات التي تقدّم عروض أسعار على إعلان إعادة التعبئة المعروض. القيمة هي
null
للخانات الفارغة والإعلانات المحجوزة وتصاميم الإعلانات التي تعرضها خدمات غيرPubAdsService
. -
creativeId
-
creativeId: null | number
-
رقم تعريف تصميم الإعلان الخاص بالإعلان المحجوزة والمعروض. القيمة هي
null
للخانات الفارغة والإعلانات عند إضافة البيانات السابقة وتصميمات الإعلانات التي تعرضها خدمات أخرى غيرPubAdsService
. -
creativeTemplateId
-
creativeTemplateId: null | number
-
رقم تعريف نموذج تصميم الإعلان الخاص بالإعلان الحجزي المعروض. القيمة هي
null
للخانات الفارغة والإعلانات عند إضافة البيانات السابقة وتصميمات الإعلانات التي تعرضها خدمات أخرى غيرPubAdsService
. -
isBackfill
-
isBackfill: boolean
-
ما إذا كان الإعلان عبارة عن إعادة تعبئة تكون القيمة هي
true
إذا كان الإعلان عبارة عن إعلان إضافي، أوfalse
في الحالات الأخرى. -
isEmpty
-
isEmpty: boolean
-
ما إذا تم عرض إعلان للخانة أم لا. تكون القيمة هي
true
في حال عدم عرض أي إعلان، أوfalse
. -
labelIds
-
labelIds: null | number[]
-
أرقام تعريف تصنيفات الإعلان المعروض القيمة هي
null
للخانات الفارغة والإعلانات عند إضافة البيانات السابقة وتصميمات الإعلانات التي تعرضها خدمات أخرى غيرPubAdsService
. -
lineItemId
-
lineItemId: null | number
-
رقم تعريف العنصر في الإعلان الحجزي المعروض. القيمة هي
null
للخانات الفارغة والإعلانات عند إضافة البيانات السابقة وتصميمات الإعلانات التي تعرضها خدمات أخرى غيرPubAdsService
. -
size
-
size: null | string | number[]
-
يشير إلى حجم البكسل لتصميم الإعلان المعروض. مثال:
[728, 90]
القيمة هيnull
للخانات الإعلانية الفارغة. -
slotContentChanged
-
slotContentChanged: boolean
-
ما إذا تم تغيير محتوى الخانة مع الإعلان المعروض وتكون القيمة
true
في حال تغيير المحتوى، أوfalse
في الحالات الأخرى. -
sourceAgnosticCreativeId
-
sourceAgnosticCreativeId: null | number
-
رقم تعريف تصميم الإعلان للحجز المعروض أو إعلان إعادة التعبئة. تبلغ القيمة
null
إذا لم يكن الإعلان عبارة عن حجز أو إعادة تعبئة عنصر، أو إذا تم عرض تصميم الإعلان من خلال خدمات أخرى غيرPubAdsService
. -
sourceAgnosticLineItemId
-
sourceAgnosticLineItemId: null | number
-
رقم تعريف العنصر الخاص بالإعلان المعروض أو إعلان إعادة التعبئة. تبلغ القيمة
null
إذا لم يكن الإعلان عبارة عن حجز أو إعادة تعبئة عنصر، أو إذا تم عرض تصميم الإعلان من خلال خدمات أخرى غيرPubAdsService
. -
yieldGroupIds
-
yieldGroupIds: null | number[]
-
أرقام تعريف مجموعات الشبكات الإعلانية المدِرّة للأرباح لإعلان إعادة التعبئة المعروض. القيمة هي
null
للخانات الفارغة والإعلانات المحجوزة وتصاميم الإعلانات التي تعرضها خدمات غيرPubAdsService
. -
googletag.events.SlotRequestedEvent
يمتد
يتمّ تنشيط هذا الحدث عند طلب إعلان لشريحة معيّنة.
ملخّص الملكية | |
---|---|
serviceName
|
اسم الخدمة التي أدت إلى تشغيل الحدث.
تم الاكتساب من
|
slot
|
الخانة التي أدت إلى تشغيل الحدث.
تم الاكتساب من
|
- مثال
-
JavaScript
// 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 (قديمة)
// 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
يمتد
يتم تنشيط هذا الحدث عند تلقي استجابة على إعلان لشريحة معيّنة.
ملخّص الملكية | |
---|---|
serviceName
|
اسم الخدمة التي أدت إلى تشغيل الحدث.
تم الاكتساب من
|
slot
|
الخانة التي أدت إلى تشغيل الحدث.
تم الاكتساب من
|
- مثال
-
JavaScript
// 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 (قديمة)
// 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
يمتد
يتم تنشيط هذا الحدث عندما تتغير النسبة المئوية على الشاشة من مساحة الشريحة الإعلانية. يتم تقييد الحدث ولن يتم تنشيطه أكثر من مرة كل 200 ملي ثانية.
ملخّص الملكية | |
---|---|
inViewPercentage
|
النسبة المئوية لمساحة الإعلان المرئية
|
serviceName
|
اسم الخدمة التي أدت إلى تشغيل الحدث.
تم الاكتساب من
|
slot
|
الخانة التي أدت إلى تشغيل الحدث.
تم الاكتساب من
|
- مثال
-
JavaScript
// 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 (قديمة)
// 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
-
النسبة المئوية لمساحة الإعلان المرئية القيمة هي رقم بين 0 و100.
-
googletag.secureSignals.BidderSignalProvider
لعرض إشارة آمنة لمقدّم عرض سعر محدّد.
يتكوّن مزوّد الإشارات الآمنة لمقدّم عروض الأسعار من جزأين:
- دالة تجميع تعرض خطأ
Promise
الذي يتم تحويله إلى إشارة آمنة. - سمة
id
التي تحدِّد مقدِّم عرض السعر المرتبط بالإشارة.
secureSignals.PublisherSignalProvider
بدلاً من ذلك.
ملخّص الملكية | |
---|---|
collectorFunction
|
.
|
id
|
معرّف فريد لأداة جمع البيانات المرتبطة بهذه الإشارة الآمنة، على النحو المسجَّل في "مدير إعلانات Google"
|
- مثال
-
JavaScript
// id is provided googletag.secureSignalProviders.push({ id: "collector123", collectorFunction: () => { // ...custom signal generation logic... return Promise.resolve("signal"); }, });
JavaScript (قديمة)
// 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>
-
id
-
id: string
-
معرّف فريد لأداة جمع البيانات المرتبطة بهذه الإشارة الآمنة، على النحو المسجَّل في "مدير إعلانات Google"
-
googletag.secureSignals.PublisherSignalProvider
تعرض إشارة آمنة لناشر محدّد.
يتكوّن موفِّر إشارات الناشر من جزأين:
- دالة تجميع تعرض خطأ
Promise
الذي يتم تحويله إلى إشارة آمنة. - سمة
networkCode
التي تحدِّد هوية الناشر المرتبط بالإشارة
secureSignals.BidderSignalProvider
بدلاً من ذلك.
ملخّص الملكية | |
---|---|
collectorFunction
|
.
|
networkCode
|
رمز الشبكة (كما يظهر في مسار الوحدة الإعلانية) للناشر المرتبط بهذه الإشارة الآمنة.
|
- مثال
-
JavaScript
// networkCode is provided googletag.secureSignalProviders.push({ networkCode: "123456", collectorFunction: () => { // ...custom signal generation logic... return Promise.resolve("signal"); }, });
JavaScript (قديمة)
// 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>
-
networkCode
-
networkCode: string
-
رمز الشبكة (كما يظهر في مسار الوحدة الإعلانية) للناشر المرتبط بهذه الإشارة الآمنة.
-
googletag.secureSignals.SecureSignalProvidersArray
واجهة لإدارة الإشارات الآمنة
ملخّص الطريقة | |
---|---|
clearAllCache
|
يؤدي إلى محو جميع الإشارات المخزّنة مؤقتًا من مساحة التخزين على الجهاز.
|
push
|
يؤدي هذا الإجراء إلى إضافة
secureSignals.SecureSignalProvider جديد إلى مصفوفة مزوِّد الإشارات وبدء عملية إنشاء الإشارة.
|
clearAllCache
-
clearAllCache(): void
-
يؤدي إلى محو جميع الإشارات المخزّنة مؤقتًا من مساحة التخزين على الجهاز.
-
push
-
push(provider: SecureSignalProvider): void
-
يؤدي هذا الإجراء إلى إضافة
secureSignals.SecureSignalProvider
جديد إلى مصفوفة مزوِّد الإشارات وبدء عملية إنشاء الإشارة. -
-
المَعلمات provider: SecureSignalProvider
العنصرsecureSignals.SecureSignalProvider
المطلوب إضافته إلى المصفوفة