يستخدم هذا المرجع تدوين TypeScript لوصف الأنواع. يقدّم الجدول التالي شرحًا موجزًا من خلال مثال.
| اكتب تعبيرًا | |
|---|---|
string |
نوع السلسلة الأساسي |
string[] |
نوع مصفوفة، حيث يمكن أن تكون القيم سلاسل فقط. |
number | string |
نوع اتحاد، حيث قد تكون القيمة إما رقمًا أو سلسلة. |
Array<number | string> |
نوع مصفوفة، حيث تكون القيم من نوع معقّد (اتحاد). |
[number, string] |
نوع صف، حيث تكون القيمة مصفوفة من عنصرين يجب أن تحتوي على رقم وسلسلة بهذا الترتيب. |
Slot |
نوع كائن، حيث تكون القيمة مثيلاً لـ googletag.Slot. |
() => void |
نوع دالة بدون وسيطات محدّدة وبدون قيمة عرض |
لمزيد من المعلومات حول الأنواع وتعبيرات الأنواع المتوافقة، يُرجى الرجوع إلى دليل TypeScript .
التعليقات التوضيحية للنوع
تشير النقطتان بعد متغير أو اسم مَعلمة أو اسم خاصية أو توقيع دالة إلى تعليق توضيحي للنوع. تصف التعليقات التوضيحية للنوع الأنواع التي يمكن للعنصر الموجود على يسار النقطتين قبولها أو إرجاعها. يعرض الجدول التالي أمثلة على التعليقات التوضيحية للأنواع التي قد تظهر في هذا المرجع.
| تعليق توضيحي للنوع | |
|---|---|
param: string |
يشير إلى أنّ param يقبل قيمة سلسلة أو يعرضها. يتم استخدام هذه البنية للمتغيّرات والمَعلمات والسمات وأنواع القيم التي تم إرجاعها.
|
param?: number | string |
يشير إلى أنّ السمة param اختيارية، ولكنّها تقبل إما رقمًا أو سلسلة عند تحديدها. يتم استخدام هذه البنية للمَعلمات والسمات.
|
...params: Array<() => void> |
يشير إلى أنّ params هي
مَعلمة rest
تقبل الدوال. تقبل معلَمات Rest عددًا غير محدود من القيم من النوع المحدّد.
|
googletag
| مساحات الاسم | |
|---|---|
config | واجهة الضبط الرئيسية للإعدادات على مستوى الصفحة |
enums | هذه هي مساحة الاسم التي تستخدمها علامة GPT لأنواع التعداد. |
events | هذه هي مساحة الاسم التي تستخدمها GPT للأحداث. |
secure | هذه هي مساحة الاسم التي تستخدمها علامة GPT لإدارة الإشارات الآمنة. |
| واجهات | |
|---|---|
Command | تقبل مصفوفة الأوامر تسلسلاً من الدوال وتستدعيها بالترتيب. |
Companion | خدمة "الإعلانات المصاحبة" |
Privacy | عنصر ضبط لإعدادات الخصوصية |
Pub | خدمة "إعلانات الناشرين" |
Request | دالّة رد الاتصال التي يتم استدعاؤها قبل كل طلب عرض إعلان عند التسجيل من خلال PubAdsService.registerRequestHook. |
Response | عنصر يمثّل استجابة إعلان واحدة |
Rewarded | عنصر يمثّل المكافأة المرتبطة بـ إعلان مقابل مكافأة. |
Service | فئة الخدمة الأساسية التي تحتوي على طرق شائعة لجميع الخدمات. |
Size | أداة إنشاء لعناصر مواصفات تعيين الحجم |
Slot | الخانة هي عنصر يمثّل خانة إعلانية واحدة على صفحة. |
| الأسماء المستعارة للأنواع | |
|---|---|
Fluid | سلسلة الحجم التي تشغل فيها حاوية الإعلان% 100 من عرض عنصر div الرئيسي، ثم يتم تغيير حجم ارتفاعها ليتناسب مع محتوى تصميم الإعلان. |
General | إعدادات حجم صالحة لموضع إعلان، ويمكن أن تكون حجمًا واحدًا أو أحجامًا متعددة. |
Multi | قائمة بالأحجام الصالحة الفردية |
Named | الأحجام المُسمّاة التي يمكن أن تتوفّر في خانة إعلانية معيّنة |
Single | حجم واحد صالح لموضع إعلان |
Single | مصفوفة من رقمَين يمثّلان [العرض، الارتفاع] |
Size | تمثيل بياني لحجم إطار العرض بالنسبة إلى أحجام الإعلانات |
Size | قائمة بعمليات ربط الأحجام |
| المتغيّرات | |
|---|---|
api | علامة تشير إلى أنّه تم تحميل واجهة برمجة التطبيقات GPT API وأنّها جاهزة للاستدعاء |
cmd | يشير هذا إلى قائمة انتظار الأوامر العامة لتنفيذ الطلبات ذات الصلة بعلامة GPT بشكل غير متزامن. |
pubads | علامة تشير إلى أنّ PubAdsService مفعَّلة ومحمَّلة وتعمل بشكل كامل |
secure | يشير إلى مصفوفة مقدّمي الإشارات الآمنة. |
| الدوال | |
|---|---|
companion | تعرض مرجعًا إلى CompanionAdsService. |
define | تنشئ هذه الطريقة خانة إعلانية خارج الصفحة باستخدام مسار الوحدة الإعلانية المحدّد. |
define | تنشئ هذه الدالة خانة إعلانية بمسار وحدة إعلانية وحجم محدّدَين وتربطها برقم تعريف عنصر div على الصفحة التي ستحتوي على الإعلان. |
destroy | يؤدي ذلك إلى تدمير الخانات المحدّدة، وإزالة جميع العناصر والمراجع ذات الصلة بهذه الخانات من GPT. |
disable | يؤدي هذا الخيار إلى إيقاف وحدة تحكم ناشري Google. |
display | توجّه خدمات الخانات لعرض الخانة. |
enable | يتيح هذا الخيار تفعيل جميع خدمات GPT التي تم تحديدها للخانة الإعلانية على الصفحة. |
get | تتيح هذه الطريقة الحصول على نسخة ثابتة من خيارات الإعدادات العامة للصفحة التي تم ضبطها من خلال setConfig. |
get | تعرض هذه الدالة الإصدار الحالي من GPT. |
open | يفتح "وحدة تحكم ناشري Google". |
pubads | تعرض مرجعًا إلى PubAdsService. |
set | يضبط هذا الإعداد عنوانًا لجميع إطارات iframe الخاصة بحاويات الإعلانات التي أنشأتها PubAdsService، من هذه النقطة فصاعدًا. |
set | تضبط خيارات الإعدادات العامة للصفحة. |
size | تنشئ هذه الطريقة SizeMappingBuilder جديدًا. |
الأسماء المستعارة للأنواع
FluidSize
FluidSize: "fluid"GeneralSize
GeneralSize: SingleSize | MultiSizeMultiSize
MultiSize: SingleSize[]NamedSize
- fluid: تأخذ حاوية الإعلان% 100 من عرض عنصر div الرئيسي، ثم يتم تغيير حجم ارتفاعها ليتناسب مع محتوى تصميم الإعلان. يشبه سلوك عناصر الكتلة العادية في الصفحة. يُستخدَم لـ "الإعلانات المدمجة مع المحتوى" و"إعلانات البانر" (يُرجى الاطّلاع على المقالة ذات الصلة). يُرجى العِلم أنّ كلاً من
fluidو['fluid']هما شكلان مقبولان للإعلان عن حجم خانة إعلانية على أنّه مرن.
SingleSize
SingleSize: SingleSizeArray | NamedSizeSingleSizeArray
SingleSizeArray: [number, number]SizeMapping
SizeMapping: [SingleSizeArray, GeneralSize]SizeMappingArray
SizeMappingArray: SizeMapping[]المتغيّرات
Const apiReady
apiReady: boolean | undefinedundefined إلى أن تصبح واجهة برمجة التطبيقات جاهزة.يُرجى العِلم أنّ الطريقة المقترَحة للتعامل مع الطلبات غير المتزامنة هي استخدام googletag.cmd لوضع عمليات معاودة الاتصال في قائمة انتظار عندما تصبح علامة GPT جاهزة. لا تحتاج عمليات الاستدعاء هذه إلى التحقّق من googletag.apiReady لأنّه من المضمون تنفيذها بعد إعداد واجهة برمجة التطبيقات.
Const cmd
cmd: ((this: typeof globalThis) => void)[] | CommandArrayتتم تهيئة المتغيّر
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()); });
TypeScript
googletag.cmd.push(() => { googletag.defineSlot("/1234567/sports", [160, 600])!.addService(googletag.pubads()); });
Const pubadsReady
pubadsReady: boolean | undefinedundefined إلى أن يتم استدعاء enableServices وتحميل PubAdsService وإعدادها.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"); }, });
TypeScript
window.googletag = window.googletag || { cmd: [] }; googletag.secureSignalProviders = googletag.secureSignalProviders || []; googletag.secureSignalProviders.push({ id: "collector123", collectorFunction: () => { return Promise.resolve("signal"); }, });
الدوال
companionAds
companionAds(): CompanionAdsService| المرتجعات | |
|---|---|
CompanionAdsService | خدمة "الإعلانات المصاحبة" |
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);
TypeScript
// Define a custom out-of-page ad slot. googletag.defineOutOfPageSlot("/1234567/sports", "div-1"); // Define a GPT managed web interstitial ad slot. googletag.defineOutOfPageSlot("/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL);
- انظر أيضًا
| المعلمات | |
|---|---|
adUnitPath: string | مسار الوحدة الإعلانية الكامل مع رمز الشبكة ورمز الوحدة الإعلانية |
| رقم تعريف عنصر div الذي سيحتوي على هذه الوحدة الإعلانية أو OutOfPageFormat |
| المرتجعات | |
|---|---|
Slot | null | الخانة التي تم إنشاؤها حديثًا، أو null إذا تعذّر إنشاء خانة |
defineSlot
defineSlot(adUnitPath: string, size: GeneralSize, div?: string): Slot | null- مثال
JavaScript
googletag.defineSlot("/1234567/sports", [728, 90], "div-1");
TypeScript
googletag.defineSlot("/1234567/sports", [728, 90], "div-1");
- انظر أيضًا
| المعلمات | |
|---|---|
adUnitPath: string | مسار الوحدة الإعلانية الكامل مع رمز الشبكة ورمز الوحدة |
size: GeneralSize | عرض الخانة الإعلانية المضافة وارتفاعها هذا هو الحجم المستخدَم في طلب عرض الإعلان في حال عدم توفير أيّ تعيين للحجم المتجاوب أو إذا كان حجم إطار العرض أصغر من أصغر حجم تم توفيره في التعيين. |
| رقم تعريف div الذي سيحتوي على هذه الوحدة الإعلانية. |
| المرتجعات | |
|---|---|
Slot | null | الخانة التي تم إنشاؤها حديثًا، أو null إذا تعذّر إنشاء خانة |
destroySlots
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();
TypeScript
// The calls to construct an ad and display contents. const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1")!; googletag.display("div-1"); const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2")!; googletag.display("div-2"); // This call to destroy only slot1. googletag.destroySlots([slot1]); // This call to destroy both slot1 and slot2. googletag.destroySlots([slot1, slot2]); // This call to destroy all slots. googletag.destroySlots();
| المعلمات | |
|---|---|
| مصفوفة الخانات المطلوب تدميرها. تُعدّ المصفوفة اختيارية، وسيتم تدمير جميع الخانات إذا لم يتم تحديدها. |
| المرتجعات | |
|---|---|
boolean | true إذا تم تدمير الخانات، وfalse في الحالات الأخرى |
disablePublisherConsole
disablePublisherConsole(): void- انظر أيضًا
display
display(divOrSlot: string | Element | Slot): voidفي حال استخدام بنية الإعلان الأحادي الطلب (SRA)، سيتم جلب جميع الخانات الإعلانية التي لم يتم جلبها في وقت طلب هذا الإجراء دفعة واحدة. لفرض عدم عرض خانة إعلانية، يجب إزالة عنصر div بالكامل.
- انظر أيضًا
| المعلمات | |
|---|---|
divOrSlot: string | Element | Slot | إما معرّف عنصر div الذي يحتوي على الخانة الإعلانية أو عنصر div أو عنصر الخانة. إذا تم توفير عنصر div، يجب أن يتضمّن سمة "id" تتطابق مع المعرّف الذي تم تمريره إلى defineSlot. |
enableServices
enableServices(): voidgetConfig
getConfig(keys: string | string[]): Readonly<Pick<PageSettingsConfig, "adsenseAttributes" | "disableInitialLoad" | "targeting">>لا تتوافق بعض سمات
setConfig() مع هذه الطريقة. السمات المتوافقة هي:- مثال
JavaScript
// Get the value of the `targeting` setting. const targetingConfig = googletag.getConfig("targeting"); // Get the value of the `adsenseAttributes` and `disableInitialLoad` settings. const config = googletag.getConfig(["adsenseAttributes", "disableInitialLoad"]);
TypeScript
// Get the value of the `targeting` setting. const targetingConfig = googletag.getConfig("targeting"); // Get the value of the `adsenseAttributes` and `disableInitialLoad` settings. const config = googletag.getConfig(["adsenseAttributes", "disableInitialLoad"]);
| المعلمات | |
|---|---|
keys: string | string[] | مفاتيح خيارات الضبط التي تريد الحصول عليها |
| المرتجعات | |
|---|---|
Readonly<Pick<PageSettingsConfig, "adsenseAttributes" | "disableInitialLoad" | "targeting">> | نسخة مجمّدة من خيارات ضبط الصفحة |
getVersion
getVersion(): string- انظر أيضًا
| المرتجعات | |
|---|---|
string | سلسلة إصدار GPT التي يتم تنفيذها حاليًا |
openConsole
openConsole(div?: string): void- مثال
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 لخانة إعلانية هذه القيمة اختيارية. عند توفير هذه السمة، ستحاول "وحدة تحكّم الناشر" فتح تفاصيل الخانة الإعلانية المحدّدة في العرض. |
pubads
pubads(): PubAdsService| المرتجعات | |
|---|---|
PubAdsService | خدمة "إعلانات الناشر" |
setAdIframeTitle
setAdIframeTitle(title: string): void- مثال
JavaScript
googletag.setAdIframeTitle("title");
TypeScript
googletag.setAdIframeTitle("title");
| المعلمات | |
|---|---|
title: string | العنوان الجديد لجميع إطارات iframe الخاصة بحاويات الإعلانات |
setConfig
setConfig(config: PageSettingsConfig): void| المعلمات | |
|---|---|
config: PageSettingsConfig | |
sizeMapping
sizeMapping(): SizeMappingBuildergoogletag.CommandArray
| الطُرق | |
|---|---|
push | تنفّذ هذه الدالة تسلسل الدوال المحدّدة في الوسيطات بالترتيب. |
الطُرق
push
push(...f: ((this: typeof globalThis) => void)[]): number- مثال
JavaScript
googletag.cmd.push(() => { googletag.defineSlot("/1234567/sports", [160, 600]).addService(googletag.pubads()); });
TypeScript
googletag.cmd.push(() => { googletag.defineSlot("/1234567/sports", [160, 600])!.addService(googletag.pubads()); });
| المعلمات | |
|---|---|
| دالة JavaScript المطلوب تنفيذها ستكون عملية الربط في وقت التشغيل دائمًا globalThis. ننصحك بتمرير دالة سهمية للاحتفاظ بقيمة this للسياق المعجمي المضمّن. |
| المرتجعات | |
|---|---|
number | عدد الأوامر التي تمت معالجتها حتى الآن يتوافق ذلك مع القيمة المعروضة من Array.push (الطول الحالي للمصفوفة). |
googletag.CompanionAdsService
Service| الطُرق | |
|---|---|
add | يتم تسجيل أداة مراقبة أحداث تتيح لك إعداد دالة JavaScript واستدعائها عند وقوع حدث GPT معيّن على الصفحة. مكتسَب من الإجراء |
get | احصل على قائمة الفترات الزمنية المرتبطة بهذه الخدمة. مكتسَب من الإجراء |
remove | لإزالة مستمع تم تسجيله سابقًا مكتسَب من الإجراء |
set | يحدّد هذا الإعداد ما إذا كان سيتم تلقائيًا ملء الخانات الإعلانية المصاحبة التي لم يتم ملؤها. |
- انظر أيضًا
الطُرق
setRefreshUnfilledSlots
setRefreshUnfilledSlots(value: boolean): voidيمكن استدعاء هذه الطريقة عدة مرات خلال فترة بقاء الصفحة لتفعيل الملء التلقائي وإيقافه. سيتم فقط ملء الخانات المسجَّلة أيضًا في PubAdsService. بسبب قيود السياسة، لم يتم تصميم هذه الطريقة لملء خانات الإعلانات المصاحبة الفارغة عند عرض فيديو من Ad Exchange.
- مثال
JavaScript
googletag.companionAds().setRefreshUnfilledSlots(true);
TypeScript
googletag.companionAds().setRefreshUnfilledSlots(true);
| المعلمات | |
|---|---|
value: boolean | true لملء الخانات الفارغة تلقائيًا، وfalse لتركها بدون تغيير |
googletag.PrivacySettingsConfig
| الخصائص | |
|---|---|
child | تشير هذه المَعلمة إلى ما إذا كان يجب تصنيف الصفحة على أنّها موجّهة للأطفال. |
limited | تتيح هذه الميزة عرض الإعلانات في وضع الإعلانات المحدودة للمساعدة في تلبية احتياجات الامتثال التنظيمي للناشرين. |
non | تتيح هذه الميزة عرض الإعلانات في وضع الإعلانات غير المخصّصة للمساعدة في تلبية احتياجات الامتثال التنظيمي للناشرين. |
restrict | يتيح هذا الإعداد عرض الإعلانات في وضع المعالجة المحدودة للمساعدة في تلبية احتياجات الامتثال التنظيمي للناشرين. |
tag | المعالجة المحظورة على فئات عمرية معيّنة، والتي تشير إلى ما إذا كان يجب التعامل مع طلب عرض الإعلان على أنّه موجّه إلى الأطفال أو المراهقين أو غير محدّد |
traffic | يشير هذا العمود إلى ما إذا كانت الطلبات تمثّل زيارات مدفوعة أو الزيارات الواردة من نتائج البحث المجانية. |
under | تشير هذه المَعلمة إلى ما إذا كان يجب وضع علامة على طلبات عرض الإعلانات بأنّها واردة من مستخدمين دون سن الرشد. |
- انظر أيضًا
الخصائص
Optional childDirectedTreatment
childDirectedTreatment?: booleannull لمحو الإعدادات.Optional limitedAds
limitedAds?: booleanيمكنك توجيه GPT لطلب إعلانات محدودة بطريقتَين:
- تلقائيًا، باستخدام إشارة من منصّة إدارة موافقة متوافقة مع الإصدار 2.0 من "إطار الشفافية والموافقة" الصادر عن مكتب IAB
- يدويًا، من خلال ضبط قيمة هذا الحقل على
true
يُرجى العِلم أنّه ليس من الضروري تفعيل الإعلانات المحدودة يدويًا عند استخدام منصة لإدارة الموافقة.
- مثال
JavaScript
// Manually enable limited ads serving. // GPT must be loaded from the limited ads URL to configure this setting. googletag.pubads().setPrivacySettings({ limitedAds: true, });
TypeScript
// Manually enable limited ads serving. // GPT must be loaded from the limited ads URL to configure this setting. googletag.pubads().setPrivacySettings({ limitedAds: true, });
- انظر أيضًا
Optional nonPersonalizedAds
nonPersonalizedAds?: booleanOptional restrictDataProcessing
restrictDataProcessing?: booleanOptional tagForAgeTreatment
tagForAgeTreatment?: TagForAgeTreatmentيُرجى الرجوع إلى مستشارك القانوني لتحديد إعدادات المعالجة الموجّهة للفئات العمرية في ما يتعلّق بمستخدِمي موقعك الإلكتروني استنادًا إلى متطلّباتك القانونية والتنظيمية. لمزيد من المعلومات حول هذا الإعداد، يُرجى مراجعة مقالة مركز المساعدة هذه.
من خلال ضبط هذه السمة، أنت تقرّ بأنّ هذا الإشعار دقيق وأنّك مفوَّض للتصرّف نيابةً عن مالك الموقع الإلكتروني. أنت تدرك أنّ إساءة استخدام هذا الإعداد قد تؤدي إلى إغلاق حسابك على Google.
- مثال
JavaScript
// Enable teen privacy treatment. googletag.pubads().setPrivacySettings({ tagForAgeTreatment: googletag.enums.TagForAgeTreatment.TEEN, }); // Clear age treatment configuration. googletag.pubads().setPrivacySettings({ tagForAgeTreatment: googletag.enums.TagForAgeTreatment.UNSPECIFIED, });
TypeScript
// Enable teen privacy treatment. googletag.pubads().setPrivacySettings({ tagForAgeTreatment: googletag.enums.TagForAgeTreatment.TEEN, }); // Clear age treatment configuration. googletag.pubads().setPrivacySettings({ tagForAgeTreatment: googletag.enums.TagForAgeTreatment.UNSPECIFIED, });
Optional trafficSource
trafficSource?: TrafficSourceundefined في التقارير.- مثال
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, });
Optional underAgeOfConsent
underAgeOfConsent?: booleannull لمحو الإعدادات.googletag.PubAdsService
Service| الطُرق | |
|---|---|
add | يتم تسجيل أداة مراقبة أحداث تتيح لك إعداد دالة JavaScript واستدعائها عند وقوع حدث GPT معيّن على الصفحة. مكتسَب من الإجراء |
clear | تزيل هذه الطريقة الإعلانات من الخانات المحدّدة وتستبدلها بمحتوى فارغ. |
clear | تمّت إزالة هذا العمود. تؤدي هذه الطريقة إلى محو جميع تصنيفات استبعاد فئات الإعلانات على مستوى الصفحة. |
clear | تمّت إزالة هذا العمود. لمحو مَعلمات الاستهداف المخصّص لمفتاح معيّن أو لجميع المفاتيح. |
collapse | تمّت إزالة هذا العمود. يؤدي ذلك إلى تفعيل تصغير عناصر div الخاصة بالخانات الإعلانية كي لا تشغل أي مساحة على الصفحة في حال عدم توفّر محتوى إعلاني لعرضه. |
disable | تمّت إزالة هذا العمود. يؤدي ذلك إلى إيقاف طلبات الإعلانات عند تحميل الصفحة، ولكن يسمح بطلب الإعلانات باستخدام طلب PubAdsService.refresh. |
display | تنشئ هذه الدالة خانة إعلانية وتعرضها باستخدام مسار الوحدة الإعلانية وحجمها المحدّدَين. |
enable | تمّت إزالة هذا العمود. تتيح هذه الطريقة تفعيل ميزة "التحميل الكسول" في علامة GPT على النحو المحدّد في عنصر الضبط. |
enable | تمّت إزالة هذا العمود. يتم تفعيل وضع "إرسال الطلبات دفعةً واحدة" لجلب إعلانات متعددة في الوقت نفسه. |
enable | تمّت إزالة هذا العمود. يُعلم GPT بأنّ إعلانات الفيديو ستظهر على الصفحة. |
get | تمّت إزالة هذا العمود. تعرض هذه الدالة قيمة سمة AdSense المرتبطة بالمفتاح المحدّد. |
get | تمّت إزالة هذا العمود. تعرض هذه الطريقة مفاتيح السمات التي تم ضبطها في هذه الخدمة. |
get | احصل على قائمة الفترات الزمنية المرتبطة بهذه الخدمة. مكتسَب من الإجراء |
get | تمّت إزالة هذا العمود. تعرض هذه الطريقة مَعلمة استهداف مخصّصة محدّدة على مستوى الخدمة تم ضبطها. |
get | تمّت إزالة هذا العمود. تعرض هذه الطريقة قائمة بجميع مفاتيح الاستهداف المخصّصة على مستوى الخدمة التي تم ضبطها. |
is | تمّت إزالة هذا العمود. تُرجع هذه الطريقة ما إذا تم إيقاف الطلبات الأولية للإعلانات بنجاح من خلال استدعاء سابق للدالة PubAdsService.disableInitialLoad أم لا. |
refresh | تجلب هذه الدالة إعلانات جديدة وتعرضها في خانات معيّنة أو في جميع الخانات على الصفحة. |
register | يتم تسجيل دالة ربط ليتم تنفيذها بالتوازي مع دوال الربط المسجَّلة الأخرى قبل كل طلب عرض إعلان على الصفحة خلال مهلة عامة. |
remove | لإزالة مستمع تم تسجيله سابقًا مكتسَب من الإجراء |
set | تمّت إزالة هذا العمود. تضبط هذه الطريقة قيم سمات AdSense التي تنطبق على جميع الخانات الإعلانية ضمن خدمة Publisher Ads. |
set | تمّت إزالة هذا العمود. يتم ضبط استبعاد فئة إعلانية على مستوى الصفحة لاسم التصنيف المحدّد. |
set | تمّت إزالة هذا العمود. يؤدي هذا الإعداد إلى تفعيل التوسيط الأفقي للإعلانات أو إيقافه. |
set | تمّت إزالة هذا العمود. تحدّد هذه السياسة ما إذا كان يجب فرض عرض جميع الإعلانات على الصفحة باستخدام حاوية SafeFrame. |
set | تمّت إزالة هذا العمود. يمرّر معلومات عن الموقع الجغرافي للجهاز من المواقع الإلكترونية حتى تتمكّن من استهداف المواقع الجغرافية في البنود الإعلانية لمواقع جغرافية معيّنة. |
set | يتيح هذا الإعداد ضبط جميع إعدادات الخصوصية من واجهة برمجة تطبيقات واحدة باستخدام عنصر ضبط. |
set | يضبط قيمة المعرّف المقدَّم من الناشر. |
set | تمّت إزالة هذا العمود. تحدّد هذه السمة الإعدادات المفضّلة على مستوى الصفحة لضبط SafeFrame. |
set | تمّت إزالة هذا العمود. يتم ضبط مَعلمات الاستهداف المخصّصة لمفتاح معيّن ينطبق على جميع الخانات الإعلانية في خدمة "إعلانات الناشرين". |
set | تمّت إزالة هذا العمود. تضبط هذه السمة معلومات محتوى الفيديو التي سيتم إرسالها مع طلبات عرض الإعلانات لأغراض الاستهداف واستبعاد المحتوى. |
update | يغيّر هذا الإجراء الارتباط الذي يتم إرساله مع طلبات عرض الإعلانات، ما يؤدي إلى بدء مشاهدة صفحة جديدة بشكل فعّال. |
الطُرق
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();
TypeScript
const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1")!; googletag.display("div-1"); const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2")!; googletag.display("div-2"); // This call to clear only slot1. googletag.pubads().clear([slot1]); // This call to clear both slot1 and slot2. googletag.pubads().clear([slot1, slot2]); // This call to clear all slots. googletag.pubads().clear();
| المعلمات | |
|---|---|
| مصفوفة الخانات المطلوب محوها المصفوفة اختيارية، وسيتم محو جميع الخانات إذا لم يتم تحديدها. |
| المرتجعات | |
|---|---|
boolean | تعرض هذه الدالة القيمة true إذا تم محو الخانات، وfalse في الحالات الأخرى. |
clearCategoryExclusions
clearCategoryExclusions(): PubAdsService- مثال
JavaScript
// Set category exclusion to exclude ads with 'AirlineAd' labels. googletag.setConfig({ categoryExclusion: ["AirlineAd"], }); // Make ad requests. No ad with 'AirlineAd' label will be returned. // Clear category exclusions so all ads can be returned. googletag.setConfig({ categoryExclusion: null, }); // Make ad requests. Any ad can be returned.
TypeScript
// Set category exclusion to exclude ads with 'AirlineAd' labels. googletag.setConfig({ categoryExclusion: ["AirlineAd"], }); // Make ad requests. No ad with 'AirlineAd' label will be returned. // Clear category exclusions so all ads can be returned. googletag.setConfig({ categoryExclusion: null, }); // Make ad requests. Any ad can be returned.
| المرتجعات | |
|---|---|
PubAdsService | عنصر الخدمة الذي تم استدعاء الطريقة عليه |
clearTargeting
clearTargeting(key?: string): PubAdsService- مثال
JavaScript
googletag.setConfig({ targeting: { interests: "sports", colors: "blue", fruits: "apple", }, }); googletag.setConfig({ targeting: { interests: null, }, }); // Targeting 'colors' and 'fruits' are still present, while 'interests' // was cleared. googletag.setConfig({ targeting: null, }); // All targeting has been cleared.
TypeScript
googletag.setConfig({ targeting: { interests: "sports", colors: "blue", fruits: "apple", }, }); googletag.setConfig({ targeting: { interests: null, }, }); // Targeting 'colors' and 'fruits' are still present, while 'interests' // was cleared. googletag.setConfig({ targeting: null, }); // All targeting has been cleared.
- انظر أيضًا
| المعلمات | |
|---|---|
| مفتاح مَعلمة الاستهداف المفتاح اختياري، وسيتم محو جميع مَعلمات الاستهداف إذا لم يتم تحديده. |
| المرتجعات | |
|---|---|
PubAdsService | عنصر الخدمة الذي تم استدعاء الطريقة عليه |
collapseEmptyDivs
collapseEmptyDivs(collapseBeforeAdFetch?: boolean): boolean| المعلمات | |
|---|---|
| ما إذا كان سيتم تصغير الخانات حتى قبل جلب الإعلانات. هذه المَعلمة اختيارية، وفي حال عدم توفيرها، سيتم استخدام false كقيمة تلقائية. |
| المرتجعات | |
|---|---|
boolean | تعرض هذه الطريقة القيمة true في حال تفعيل وضع تصغير div، والقيمة false في حال تعذّر تفعيل وضع التصغير بسبب استدعاء الطريقة بعد تفعيل الخدمة. |
disableInitialLoad
disableInitialLoad(): voidrefresh.display
display(adUnitPath: string, size: GeneralSize, div?: string | Element, clickUrl?: string): voidهذه الطريقة هي اختصار يعادل استدعاء googletag.defineSlot متبوعًا مباشرةً بـ googletag.display.
يعتمد سلوك هذه الطريقة على ما إذا كانت بنية الإعلان الأحادي الطلب (SRA) مفعَّلة:
- تفعيل SRA: سيتم تجميع كل الخانات الإعلانية المحدّدة حتى وقت هذا الطلب وطلبها معًا.
- إيقاف SRA (الإعداد التلقائي): سيتم طلب الخانة الإعلانية بشكل فردي.
display() أو refresh() اللاحقة.- مثال
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 الذي يحتوي على الخانة أو عنصر div نفسه. |
| عنوان URL للنقرة المطلوب استخدامه في هذه الخانة |
enableLazyLoad
enableLazyLoad(config?: {
fetchMarginPercent?: number;
mobileScaling?: number;
renderMarginPercent?: number;
}): voidملاحظة: لا تعمل ميزة "الجلب الكسول" في بنية الإعلان الأحادي الطلب (SRA) إلا إذا كانت جميع الخانات خارج هامش الجلب.
- مثال
JavaScript
googletag.setConfig({ lazyLoad: { // Fetch slots within 5 viewports. fetchMarginPercent: 500, // Render slots within 2 viewports. renderMarginPercent: 200, // Double the above values on mobile. mobileScaling: 2.0, }, });
TypeScript
googletag.setConfig({ lazyLoad: { // Fetch slots within 5 viewports. fetchMarginPercent: 500, // Render slots within 2 viewports. renderMarginPercent: 200, // Double the above values on mobile. mobileScaling: 2.0, }, });
- انظر أيضًا
| المعلمات | |
|---|---|
| يسمح عنصر الإعدادات بتخصيص سلوك التحميل الكسول. ستستخدم أي إعدادات محذوفة إعدادًا تلقائيًا تضبطه Google وسيتم تعديله بمرور الوقت. لإيقاف إعداد معيّن، مثل هامش الجلب، اضبط القيمة على -1.
|
enableSingleRequest
enableSingleRequest(): boolean- انظر أيضًا
| المرتجعات | |
|---|---|
boolean | تعرض هذه الدالة القيمة true في حال تفعيل وضع "إرسال الطلبات دفعةً واحدة"، والقيمة false في حال تعذّر تفعيل هذا الوضع بسبب استدعاء الطريقة بعد تفعيل الخدمة. |
enableVideoAds
enableVideoAds(): voidget
get(key: string): string- مثال
JavaScript
googletag.setConfig({ adsenseAttributes: { page_url: "http://www.example.com", }, }); const adsenseConfig = googletag.getConfig("adsenseAttributes").adsenseAttributes; const pageUrl = adsenseConfig?.page_url || null; // Returns 'http://www.example.com'.
TypeScript
googletag.setConfig({ adsenseAttributes: { page_url: "http://www.example.com", }, }); const adsenseConfig = googletag.getConfig("adsenseAttributes").adsenseAttributes; const pageUrl = adsenseConfig?.page_url || null; // Returns 'http://www.example.com'.
- انظر أيضًا
| المعلمات | |
|---|---|
key: string | اسم السمة المطلوب البحث عنها |
| المرتجعات | |
|---|---|
string | القيمة الحالية لمفتاح السمة، أو null إذا لم يكن المفتاح متوفّرًا. |
getAttributeKeys
getAttributeKeys(): string[]- مثال
JavaScript
googletag.setConfig({ adsenseAttributes: { page_url: "http://www.example.com", document_language: "en", }, }); const adsenseConfig = googletag.getConfig("adsenseAttributes").adsenseAttributes; const adsenseAttributes = Object.keys(adsenseConfig || {}); // Returns ['page_url', 'document_language'].
TypeScript
googletag.setConfig({ adsenseAttributes: { page_url: "http://www.example.com", document_language: "en", }, }); const adsenseConfig = googletag.getConfig("adsenseAttributes").adsenseAttributes; const adsenseAttributes = Object.keys(adsenseConfig || {}); // Returns ['page_url', 'document_language'].
| المرتجعات | |
|---|---|
string[] | مصفوفة من مفاتيح السمات التي تم ضبطها في هذه الخدمة الترتيب غير محدّد. |
getTargeting
getTargeting(key: string): string[]- مثال
JavaScript
googletag.setConfig({ targeting: { interests: "sports", }, }); const targetingConfig = googletag.getConfig("targeting").targeting; // Get targeting for a specific key. const targeting = targetingConfig?.["interests"] || []; // Returns ['sports']. const ageTargeting = targetingConfig?.["age"] || []; // Returns [] (empty array).
TypeScript
googletag.setConfig({ targeting: { interests: "sports", }, }); const targetingConfig = googletag.getConfig("targeting").targeting; // Get targeting for a specific key. const targeting = targetingConfig?.["interests"] || []; // Returns ['sports']. const ageTargeting = targetingConfig?.["age"] || []; // Returns [] (empty array).
| المعلمات | |
|---|---|
key: string | مفتاح الاستهداف المطلوب البحث عنه |
| المرتجعات | |
|---|---|
string[] | القيم المرتبطة بهذا المفتاح، أو مصفوفة فارغة في حال عدم توفّر هذا المفتاح |
getTargetingKeys
getTargetingKeys(): string[]- مثال
JavaScript
googletag.setConfig({ targeting: { interests: "sports", colors: "blue", }, }); const targetingConfig = googletag.getConfig("targeting").targeting; const keys = Object.keys(targetingConfig || {}); // Returns ['interests', 'colors'].
TypeScript
googletag.setConfig({ targeting: { interests: "sports", colors: "blue", }, }); const targetingConfig = googletag.getConfig("targeting").targeting; const keys = Object.keys(targetingConfig || {}); // Returns ['interests', 'colors'].
| المرتجعات | |
|---|---|
string[] | مصفوفة من مفاتيح الاستهداف الترتيب غير محدّد. |
isInitialLoadDisabled
isInitialLoadDisabled(): boolean| المرتجعات | |
|---|---|
boolean | تعرض القيمة true إذا كان الطلب السابق إلى PubAdsService.disableInitialLoad ناجحًا، وfalse في الحالات الأخرى. |
إعادة تحميل
refresh(slots?: 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 });
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 });
| المعلمات | |
|---|---|
| الخانات المطلوب إعادة تحميلها تكون المصفوفة اختيارية، وسيتم إعادة تحميل جميع الخانات الإعلانية إذا لم يتم تحديدها. |
| خيارات الإعداد المرتبطة بطلب إعادة التحميل هذا
|
registerRequestHook
registerRequestHook(hook: RequestHook, hookId: string): (() => void)Experimental لتسجيل دالة ربط يتم تنفيذها بالتوازي مع دوال الربط المسجَّلة الأخرى قبل كل طلب عرض إعلان على الصفحة خلال مهلة عامة- مثال
JavaScript
// Register a request hook. const unregister = googletag.pubads().registerRequestHook(async ({ slots }) => { const someAsynchronousAction = Promise.resolve(); await someAsynchronousAction; for (const slot of slots) { slot.setConfig({ targeting: { hookApplied: "true" } }); } }, "my-hook"); // Unregister the hook. unregister();
TypeScript
// Register a request hook. const unregister = googletag.pubads().registerRequestHook(async ({ slots }) => { const someAsynchronousAction = Promise.resolve(); await someAsynchronousAction; for (const slot of slots) { slot.setConfig({ targeting: { hookApplied: "true" } }); } }, "my-hook"); // Unregister the hook. unregister();
| المعلمات | |
|---|---|
hook: RequestHook | دالة تأخذ عنصرًا يحتوي على قائمة الخانات المطلوبة وتُرجع وعدًا يتم تنفيذه بعد اكتمال جميع الإجراءات غير المتزامنة. |
hookId: string | رقم تعريف لتصنيف الخطاف من أجل تحسين بيانات التشخيص |
| المرتجعات | |
|---|---|
(() => void) | دالة لإلغاء تسجيل الخطاف. |
set
set(key: string, value: string): PubAdsServiceسيؤدي استدعاء هذه الدالة أكثر من مرة للمفتاح نفسه إلى إلغاء القيم المحدّدة سابقًا لذلك المفتاح. يجب ضبط جميع القيم قبل استدعاء
display أو refresh.- مثال
JavaScript
googletag.setConfig({ adsenseAttributes: { page_url: "http://www.example.com", }, });
TypeScript
googletag.setConfig({ adsenseAttributes: { page_url: "http://www.example.com", }, });
- انظر أيضًا
| المعلمات | |
|---|---|
key: string | اسم السمة |
value: string | قيمة السمة |
| المرتجعات | |
|---|---|
PubAdsService | عنصر الخدمة الذي تم استدعاء الطريقة عليه |
setCategoryExclusion
setCategoryExclusion(categoryExclusion: string): PubAdsService- مثال
JavaScript
// Label = AirlineAd. googletag.setConfig({ categoryExclusion: ["AirlineAd"], });
TypeScript
// Label = AirlineAd. googletag.setConfig({ categoryExclusion: ["AirlineAd"], });
| المعلمات | |
|---|---|
categoryExclusion: string | تصنيف استبعاد فئة الإعلان المطلوب إضافته |
| المرتجعات | |
|---|---|
PubAdsService | عنصر الخدمة الذي تم استدعاء الطريقة عليه |
setCentering
setCentering(centerAds: boolean): voidيجب استدعاء هذه الطريقة قبل استدعاء
display أو refresh لأنّه سيتم توسيط الإعلانات التي يتم طلبها بعد استدعاء هذه الطريقة فقط.- مثال
JavaScript
// Make ads centered. googletag.setConfig({ centering: true, });
TypeScript
// Make ads centered. googletag.setConfig({ centering: true, });
| المعلمات | |
|---|---|
centerAds: boolean | true لتوسيط الإعلانات، وfalse لمحاذاتها إلى اليمين. |
setForceSafeFrame
setForceSafeFrame(forceSafeFrame: boolean): PubAdsServiceيُرجى مراعاة ما يلي أثناء استخدام واجهة برمجة التطبيقات هذه:
- لن يسري هذا الإعداد إلا على طلبات عرض الإعلانات اللاحقة التي يتم إجراؤها للخانات الإعلانية المعنيّة.
- في حال تحديد الإعداد على مستوى الخانة الإعلانية، سيتم دائمًا إلغاء الإعداد على مستوى الصفحة.
- في حال ضبطها على
true(على مستوى الخانة الإعلانية أو الصفحة)، سيتم دائمًا عرض الإعلان باستخدام حاوية SafeFrame بغض النظر عن الخيار المحدّد في واجهة مستخدم "إدارة إعلانات Google". - ومع ذلك، إذا تم ضبطها على
falseأو تُركت بدون تحديد، سيتم عرض الإعلان باستخدام حاوية SafeFrame استنادًا إلى نوع تصميم الإعلان والاختيار الذي تم إجراؤه في واجهة مستخدم "مدير إعلانات Google". - يجب استخدام واجهة برمجة التطبيقات هذه بحذر لأنّها قد تؤثر في سلوك تصاميم الإعلانات التي تحاول الخروج من إطارات iFrame أو تعتمد على عرضها مباشرةً في صفحة الناشر.
- مثال
JavaScript
googletag.setConfig({ safeFrame: { forceSafeFrame: true, }, }); // The following slot will be opted-out of the page-level force // SafeFrame instruction. googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setConfig({ safeFrame: { forceSafeFrame: 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.setConfig({ safeFrame: { forceSafeFrame: true, }, }); // The following slot will be opted-out of the page-level force // SafeFrame instruction. googletag .defineSlot("/1234567/sports", [160, 600], "div-1")! .setConfig({ safeFrame: { forceSafeFrame: 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.setConfig({ location: "10001,US", });
TypeScript
// Postal code: googletag.setConfig({ location: "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, });
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");
TypeScript
googletag.pubads().setPublisherProvidedId("12JD92JD8078S8J29SDOAKC0EF230337");
- انظر أيضًا
| المعلمات | |
|---|---|
ppid: string | معرّف أبجدي رقمي يقدّمه الناشر يجب أن يتراوح عدد الأحرف بين 22 و150 حرفًا. |
| المرتجعات | |
|---|---|
PubAdsService | عنصر الخدمة الذي تم استدعاء الطريقة عليه |
setSafeFrameConfig
setSafeFrameConfig(config: SafeFrameConfig): PubAdsServiceسيتم إلغاء هذه الإعدادات المفضّلة على مستوى الصفحة من خلال الإعدادات المفضّلة على مستوى الخانة، في حال تحديدها.
- مثال
JavaScript
googletag.setConfig({ safeFrame: { forceSafeFrame: true, allowOverlayExpansion: true, allowPushExpansion: true, sandbox: true, }, }); googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setConfig({ safeFrame: { allowOverlayExpansion: false, }, }) .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.setConfig({ safeFrame: { forceSafeFrame: true, allowOverlayExpansion: true, allowPushExpansion: true, sandbox: true, }, }); googletag .defineSlot("/1234567/sports", [160, 600], "div-1")! .setConfig({ safeFrame: { allowOverlayExpansion: false, }, }) .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- مثال
JavaScript
// Example with a single value for a key. googletag.setConfig({ targeting: { interests: "sports", }, }); // Example with multiple values for a key inside in an array. googletag.setConfig({ targeting: { interests: ["sports", "music"], }, });
TypeScript
// Example with a single value for a key. googletag.setConfig({ targeting: { interests: "sports", }, }); // Example with multiple values for a key inside in an array. googletag.setConfig({ targeting: { interests: ["sports", "music"], }, });
- انظر أيضًا
| المعلمات | |
|---|---|
key: string | مفتاح مَعلمة الاستهداف |
value: string | string[] | قيمة مَعلمة الاستهداف أو مصفوفة القيم |
| المرتجعات | |
|---|---|
PubAdsService | عنصر الخدمة الذي تم استدعاء الطريقة عليه |
setVideoContent
setVideoContent(videoContentId: string, videoCmsId: string): voidvideoContentId وvideoCmsId، استخدِم القيم المقدَّمة لخدمة تحليل المحتوى في "إدارة إعلانات Google".| المعلمات | |
|---|---|
videoContentId: string | معرّف محتوى الفيديو |
videoCmsId: string | معرّف الفيديو في نظام إدارة المحتوى |
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.
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.RequestHook
googletag.ResponseInformation
| الخصائص | |
|---|---|
advertiser | رقم تعريف المعلِن |
campaign | رقم تعريف الحملة. |
creative | رقم تعريف تصميم الإعلان |
creative | رقم تعريف نموذج الإعلان. |
line | رقم تعريف البند الإعلاني |
- انظر أيضًا
الخصائص
advertiserId
advertiserId: numbercampaignId
campaignId: numbercreativeId
creativeId: numbercreativeTemplateId
creativeTemplateId: numberlineItemId
lineItemId: numbergoogletag.RewardedPayload
| الخصائص | |
|---|---|
amount | عدد العناصر المضمّنة في المكافأة |
type | نوع العنصر المضمَّن في المكافأة (على سبيل المثال، "عملة"). |
- انظر أيضًا
الخصائص
amount
amount: numbertype
type: stringgoogletag.Service
| الطُرق | |
|---|---|
add | يتم تسجيل أداة مراقبة أحداث تتيح لك إعداد دالة JavaScript واستدعائها عند وقوع حدث GPT معيّن على الصفحة. |
get | احصل على قائمة الفترات الزمنية المرتبطة بهذه الخدمة. |
remove | لإزالة مستمع تم تسجيله سابقًا |
الطُرق
addEventListener
addEventListener<K extends keyof EventTypeMap>(eventType: K, listener: ((arg: EventTypeMap[K]) => void)): Service- events.GameManualInterstitialSlotClosedEvent
- events.GameManualInterstitialSlotReadyEvent
- events.ImpressionViewableEvent
- events.RewardedSlotClosedEvent
- events.RewardedSlotGrantedEvent
- events.RewardedSlotReadyEvent
- events.SlotOnloadEvent
- events.SlotRenderEndedEvent
- events.SlotRequestedEvent
- events.SlotResponseReceived
- events.SlotVisibilityChangedEvent
- مثال
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. } });
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(); });
TypeScript
googletag.cmd.push(() => { // Define a new ad slot. googletag .defineSlot("/6355419/Travel", [728, 90], "div-for-slot")! .addService(googletag.pubads()); // Define a new function that removes itself via removeEventListener // after the impressionViewable event fires. const onViewableListener = (event: googletag.events.ImpressionViewableEvent) => { googletag.pubads().removeEventListener("impressionViewable", onViewableListener); setTimeout(() => { googletag.pubads().refresh([event.slot]); }, 30000); }; // Add onViewableListener as a listener for impressionViewable events. googletag.pubads().addEventListener("impressionViewable", onViewableListener); googletag.enableServices(); });
| المعلمات | |
|---|---|
eventType: K | سلسلة تمثّل نوع الحدث الذي أنشأته GPT. تكون أنواع الأحداث حسّاسة لحالة الأحرف. |
listener: ((event: EventTypeMap[K]) => void) | دالة تستخدم وسيطة عنصر حدث واحد. |
googletag.SizeMappingBuilder
| الطُرق | |
|---|---|
add | تضيف هذه الطريقة عملية ربط من مصفوفة ذات حجم واحد (تمثّل إطار العرض) إلى مصفوفة ذات حجم واحد أو مصفوفات متعددة الأحجام تمثّل خانة الإعلان. |
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]
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(): SizeMappingArrayفي حال تقديم أي عمليات ربط غير صالحة، ستعرض هذه الطريقة
null. بخلاف ذلك، تعرض المواصفات بالتنسيق الصحيح لتمريرها إلى Slot.defineSizeMapping.ملاحظة: سلوك أداة الإنشاء بعد استدعاء هذه الطريقة غير محدّد.
| المرتجعات | |
|---|---|
SizeMappingArray | النتيجة التي تم إنشاؤها بواسطة أداة الإنشاء هذه يمكن أن تكون القيمة فارغة إذا تم تقديم تعيينات أحجام غير صالحة. |
googletag.Slot
| الطُرق | |
|---|---|
add | يضيف هذا الإجراء خدمة إلى هذه الخانة. |
clear | تمّت إزالة هذا العمود. يؤدي هذا الإجراء إلى محو جميع تصنيفات استبعاد فئات الإعلانات على مستوى الخانة لهذه الخانة. |
clear | تمّت إزالة هذا العمود. يمحو هذا الخيار مَعلمات استهداف معيّنة أو جميع مَعلمات الاستهداف المخصّصة على مستوى الخانة لهذه الخانة. |
define | يتم ضبط مصفوفة من عمليات الربط من الحد الأدنى لحجم إطار العرض إلى حجم الخانة لهذه الخانة. |
get | تمّت إزالة هذا العمود. تعرض هذه الطريقة قيمة سمة AdSense المرتبطة بالمفتاح المحدّد لهذه الخانة. |
get | تعرض هذه السمة المسار الكامل للوحدة الإعلانية، مع رمز الشبكة ومسار الوحدة الإعلانية. |
get | تمّت إزالة هذا العمود. تعرض هذه الطريقة قائمة بمفاتيح السمات التي تم ضبطها في هذه الخانة. |
get | تمّت إزالة هذا العمود. تعرض تصنيفات استبعاد فئات الإعلانات لهذه الخانة. |
get | تحصل على نسخة مجمّدة من خيارات الإعدادات العامة للمساحة الإعلانية التي تم ضبطها من خلال setConfig. |
get | يعرض معلومات استجابة الإعلان. |
get | تعرض هذه الدالة رقم تعريف الخانة div الذي تم تقديمه عند تحديد الخانة. |
get | تمّت إزالة هذا العمود. تعرض هذه الطريقة معلَمة استهداف مخصّصة معيّنة تم ضبطها على هذه الخانة. |
get | تمّت إزالة هذا العمود. تعرض هذه الطريقة قائمة بجميع مفاتيح الاستهداف المخصّصة التي تم ضبطها في هذه الخانة. |
set | تمّت إزالة هذا العمود. تحدّد هذه الطريقة قيمة لسمة AdSense في هذه الخانة الإعلانية. |
set | تمّت إزالة هذا العمود. يضبط تصنيفًا لاستبعاد فئات الإعلانات على مستوى الخانة في هذه الخانة. |
set | تمّت إزالة هذا العمود. يضبط عنوان URL للنقرة الذي ستتم إعادة توجيه المستخدمين إليه بعد النقر على الإعلان. |
set | تمّت إزالة هذا العمود. يحدّد ما إذا كان يجب إخفاء الخانة div في حال عدم توفّر إعلان فيها. |
set | يضبط خيارات الإعدادات العامة لهذه الخانة. |
set | تمّت إزالة هذا العمود. تحدّد هذه السياسة ما إذا كان يجب فرض عرض الإعلانات في هذه الخانة باستخدام حاوية SafeFrame. |
set | تمّت إزالة هذا العمود. تضبط الإعدادات المفضّلة على مستوى الخانة لإعدادات SafeFrame. |
set | تمّت إزالة هذا العمود. يتم ضبط مَعلمة استهداف مخصّصة لهذه الخانة. |
update | تمّت إزالة هذا العمود. تحدّد هذه الطريقة مَعلمات الاستهداف المخصّصة لهذه الخانة الإعلانية، من خريطة مفتاح:قيمة في عنصر JSON. |
الطُرق
addService
addService(service: Service): Slot- مثال
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") .setConfig({ categoryExclusion: ["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.setConfig({ categoryExclusion: null, }); // 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")! .setConfig({ categoryExclusion: ["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.setConfig({ categoryExclusion: null, }); // 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") .setConfig({ targeting: { allow_expandable: "true", interests: ["sports", "music"], color: "red", }, }) .addService(googletag.pubads()); slot.setConfig({ targeting: { color: null, }, }); // Targeting 'allow_expandable' and 'interests' are still present, // while 'color' was cleared. slot.setConfig({ targeting: null, }); // All targeting has been cleared.
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setConfig({ targeting: { allow_expandable: "true", interests: ["sports", "music"], color: "red", }, }) .addService(googletag.pubads()); slot.setConfig({ targeting: { color: null, }, }); // Targeting 'allow_expandable' and 'interests' are still present, // while 'color' was cleared. slot.setConfig({ targeting: null, }); // All targeting has been cleared.
- انظر أيضًا
| المعلمات | |
|---|---|
| مفتاح مَعلمة الاستهداف المفتاح اختياري، وسيتم محو جميع مَعلمات الاستهداف إذا لم يتم تحديده. |
| المرتجعات | |
|---|---|
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);
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): string- مثال
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setConfig({ adsenseAttributes: { page_url: "http://www.example.com", }, }) .addService(googletag.pubads()); const adsenseConfig = slot.getConfig("adsenseAttributes").adsenseAttributes; const pageUrl = adsenseConfig?.page_url || null; // Returns 'http://www.example.com'.
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setConfig({ adsenseAttributes: { page_url: "http://www.example.com", }, }) .addService(googletag.pubads()); const adsenseConfig = slot.getConfig("adsenseAttributes").adsenseAttributes; const pageUrl = adsenseConfig?.page_url || null; // Returns 'http://www.example.com'.
- انظر أيضًا
| المعلمات | |
|---|---|
key: string | اسم السمة المطلوب البحث عنها |
| المرتجعات | |
|---|---|
string | القيمة الحالية لمفتاح السمة، أو null إذا لم يكن المفتاح متوفّرًا. |
getAdUnitPath
getAdUnitPath(): string- مثال
JavaScript
const 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[]- مثال
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setConfig({ adsenseAttributes: { page_url: "http://www.example.com", document_language: "en", }, }) .addService(googletag.pubads()); const adsenseConfig = slot.getConfig("adsenseAttributes").adsenseAttributes; const adsenseAttributes = Object.keys(adsenseConfig || {}); // Returns ['page_url', 'document_language'].
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setConfig({ adsenseAttributes: { page_url: "http://www.example.com", document_language: "en", }, }) .addService(googletag.pubads()); const adsenseConfig = slot.getConfig("adsenseAttributes").adsenseAttributes; const adsenseAttributes = Object.keys(adsenseConfig || {}); // Returns ['page_url', 'document_language'].
| المرتجعات | |
|---|---|
string[] | مصفوفة من مفاتيح السمات الترتيب غير محدّد. |
getCategoryExclusions
getCategoryExclusions(): string[]- مثال
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setConfig({ categoryExclusion: ["AirlineAd", "TrainAd"], }) .addService(googletag.pubads()); const exclusions = slot.getConfig("categoryExclusion")?.categoryExclusion || []; // Returns ['AirlineAd', 'TrainAd'].
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setConfig({ categoryExclusion: ["AirlineAd", "TrainAd"], }) .addService(googletag.pubads()); const exclusions = slot.getConfig("categoryExclusion")?.categoryExclusion || []; // Returns ['AirlineAd', 'TrainAd'].
| المرتجعات | |
|---|---|
string[] | تصنيفات استبعاد فئات الإعلانات لهذه الخانة، أو مصفوفة فارغة في حال عدم ضبط أي تصنيفات |
getConfig
getConfig(keys: string | string[]): Readonly<Pick<SlotSettingsConfig, "adsenseAttributes" | "targeting" | "categoryExclusion">>لا تتوافق بعض سمات
setConfig() مع هذه الطريقة. السمات المتوافقة هي:- مثال
JavaScript
const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div"); // Get the value of the `targeting` setting. const targetingConfig = slot.getConfig("targeting"); // Get the value of the `adsenseAttributes` and `categoryExclusion` settings. const config = slot.getConfig(["adsenseAttributes", "categoryExclusion"]);
TypeScript
const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div")!; // Get the value of the `targeting` setting. const targetingConfig = slot.getConfig("targeting"); // Get the value of the `adsenseAttributes` and `categoryExclusion` settings. const config = slot.getConfig(["adsenseAttributes", "categoryExclusion"]);
| المعلمات | |
|---|---|
keys: string | string[] | مفاتيح خيارات الضبط التي تريد الحصول عليها |
| المرتجعات | |
|---|---|
Readonly<Pick<SlotSettingsConfig, "adsenseAttributes" | "targeting" | "categoryExclusion">> | نسخة مجمّدة من خيارات الضبط الخاصة بالخانة |
getResponseInformation
getResponseInformation(): ResponseInformationnull.| المرتجعات | |
|---|---|
ResponseInformation | أحدث معلومات استجابة الإعلان، أو null إذا لم تكن الخانة تحتوي على إعلان. |
getSlotElementId
getSlotElementId(): stringdiv الذي تم تقديمه عند تحديد الخانة.- مثال
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); slot.getSlotElementId(); // Returns 'div'.
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); slot.getSlotElementId(); // Returns 'div'.
| المرتجعات | |
|---|---|
string | رقم تعريف الخانة div |
getTargeting
getTargeting(key: string): string[]- مثال
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setConfig({ targeting: { allow_expandable: "true", }, }) .addService(googletag.pubads()); const targetingConfig = slot.getConfig("targeting").targeting; // Get targeting for a specific key. const targeting = targetingConfig?.["allow_expandable"] || []; // Returns ['true']. const ageTargeting = targetingConfig?.["age"] || []; // Returns [] (empty array).
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setConfig({ targeting: { allow_expandable: "true", }, }) .addService(googletag.pubads()); const targetingConfig = slot.getConfig("targeting").targeting; // Get targeting for a specific key. const targeting = targetingConfig?.["allow_expandable"] || []; // Returns ['true']. const ageTargeting = targetingConfig?.["age"] || []; // Returns [] (empty array).
| المعلمات | |
|---|---|
key: string | مفتاح الاستهداف المطلوب البحث عنه |
| المرتجعات | |
|---|---|
string[] | القيم المرتبطة بهذا المفتاح، أو مصفوفة فارغة في حال عدم توفّر هذا المفتاح |
getTargetingKeys
getTargetingKeys(): string[]- مثال
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setConfig({ targeting: { allow_expandable: "true", interests: ["sports", "music"], }, }) .addService(googletag.pubads()); const targetingConfig = slot.getConfig("targeting").targeting; const keys = Object.keys(targetingConfig || {}); // Returns ['interests', 'allow_expandable'].
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setConfig({ targeting: { allow_expandable: "true", interests: ["sports", "music"], }, }) .addService(googletag.pubads()); const targetingConfig = slot.getConfig("targeting").targeting; const keys = Object.keys(targetingConfig || {}); // Returns ['interests', 'allow_expandable'].
| المرتجعات | |
|---|---|
string[] | مصفوفة من مفاتيح الاستهداف الترتيب غير محدّد. |
set
set(key: string, value: string): Slotسيؤدي استدعاء هذه الطريقة أكثر من مرة للمفتاح نفسه إلى إلغاء القيم التي تم ضبطها سابقًا لهذا المفتاح. يجب ضبط جميع القيم قبل استدعاء
display أو refresh.- مثال
JavaScript
// Setting an attribute on a single ad slot. googletag .defineSlot("/1234567/sports", [160, 600], "div") .setConfig({ adsenseAttributes: { page_url: "http://www.example.com", }, }) .addService(googletag.pubads());
TypeScript
// Setting an attribute on a single ad slot. googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setConfig({ adsenseAttributes: { page_url: "http://www.example.com", }, }) .addService(googletag.pubads());
- انظر أيضًا
| المعلمات | |
|---|---|
key: string | اسم السمة |
value: string | قيمة السمة |
| المرتجعات | |
|---|---|
Slot | عنصر الخانة الذي تم استدعاء الطريقة عليه |
setCategoryExclusion
setCategoryExclusion(categoryExclusion: string): Slot- مثال
JavaScript
// Label = AirlineAd. googletag .defineSlot("/1234567/sports", [160, 600], "div") .setConfig({ categoryExclusion: ["AirlineAd"], }) .addService(googletag.pubads());
TypeScript
// Label = AirlineAd. googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setConfig({ categoryExclusion: ["AirlineAd"], }) .addService(googletag.pubads());
| المعلمات | |
|---|---|
categoryExclusion: string | تصنيف استبعاد فئة الإعلان المطلوب إضافته |
| المرتجعات | |
|---|---|
Slot | عنصر الخانة الذي تم استدعاء الطريقة عليه |
setClickUrl
setClickUrl(value: string): Slotتواصل خوادم "إدارة إعلانات Google" تسجيل النقرات حتى في حال استبدال عنوان URL للنقرة. تتم إضافة أي عنوان URL للصفحة المقصودة مرتبط بتصميم الإعلان الذي يتم عرضه إلى القيمة المقدَّمة. وتؤدي الطلبات اللاحقة إلى استبدال القيمة. لا تعمل هذه الميزة إلا مع الطلبات التي لا تستخدم بنية الإعلان الأحادي الطلب (SRA).
- مثال
JavaScript
googletag .defineSlot("/1234567/sports", [160, 600], "div") .setConfig({ clickUrl: "http://www.example.com?original_click_url=", }) .addService(googletag.pubads());
TypeScript
googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setConfig({ clickUrl: "http://www.example.com?original_click_url=", }) .addService(googletag.pubads());
| المعلمات | |
|---|---|
value: string | عنوان URL للنقرة المطلوب ضبطه |
| المرتجعات | |
|---|---|
Slot | عنصر الخانة الذي تم استدعاء الطريقة عليه |
setCollapseEmptyDiv
setCollapseEmptyDiv(collapse: boolean, collapseBeforeAdFetch?: boolean): Slotdiv في حال عدم توفّر إعلان فيها. يؤدي ذلك إلى إلغاء الإعدادات على مستوى الخدمة.- مثال
JavaScript
const slot1 = googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setConfig({ collapseDiv: "BEFORE_FETCH", }) .addService(googletag.pubads()); // The above will cause the div for this slot to be collapsed // when the page is loaded, before ads are requested. const slot2 = googletag .defineSlot("/1234567/sports", [160, 600], "div-2") .setConfig({ collapseDiv: "ON_NO_FILL", }) .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
const slot1 = googletag .defineSlot("/1234567/sports", [160, 600], "div-1")! .setConfig({ collapseDiv: "BEFORE_FETCH", }) .addService(googletag.pubads()); // The above will cause the div for this slot to be collapsed // when the page is loaded, before ads are requested. const slot2 = googletag .defineSlot("/1234567/sports", [160, 600], "div-2")! .setConfig({ collapseDiv: "ON_NO_FILL", }) .addService(googletag.pubads()); // The above will cause the div for this slot to be collapsed // only after GPT detects that no ads are available for the slot.
| المعلمات | |
|---|---|
collapse: boolean | ما إذا كان سيتم تصغير الخانة في حال عدم عرض أي إعلان |
| ما إذا كان سيتم تصغير الخانة حتى قبل جلب الإعلان يتم تجاهل هذه السمة إذا لم تكن قيمة سمة التصغير true. |
| المرتجعات | |
|---|---|
Slot | عنصر الخانة الذي تم استدعاء الطريقة عليه |
setConfig
setConfig(slotConfig: SlotSettingsConfig): Slot| المعلمات | |
|---|---|
slotConfig: SlotSettingsConfig | عنصر الإعدادات |
| المرتجعات | |
|---|---|
Slot | عنصر الخانة الذي تم استدعاء الطريقة عليه |
setForceSafeFrame
setForceSafeFrame(forceSafeFrame: boolean): Slotيُرجى مراعاة ما يلي أثناء استخدام واجهة برمجة التطبيقات هذه:
- لن يسري هذا الإعداد إلا على طلبات عرض الإعلانات اللاحقة التي يتم إجراؤها للخانات الإعلانية المعنيّة.
- في حال تحديد الإعداد على مستوى الخانة الإعلانية، سيتم دائمًا إلغاء الإعداد على مستوى الصفحة.
- في حال ضبطها على
true(على مستوى الخانة الإعلانية أو الصفحة)، سيتم دائمًا عرض الإعلان باستخدام حاوية SafeFrame بغض النظر عن الخيار المحدّد في واجهة مستخدم "إدارة إعلانات Google". - ومع ذلك، إذا تم ضبطها على
falseأو تُركت بدون تحديد، سيتم عرض الإعلان باستخدام حاوية SafeFrame استنادًا إلى نوع تصميم الإعلان والاختيار الذي تم إجراؤه في واجهة مستخدم "مدير إعلانات Google". - يجب استخدام واجهة برمجة التطبيقات هذه بحذر لأنّها قد تؤثر في سلوك تصاميم الإعلانات التي تحاول الخروج من إطارات iFrame أو تعتمد على عرضها مباشرةً في صفحة الناشر.
- مثال
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: SafeFrameConfig): Slotستلغي هذه الإعدادات المفضّلة على مستوى الخانة أي إعدادات مفضّلة على مستوى الصفحة، في حال تحديدها.
- مثال
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: SafeFrameConfig | عنصر الإعدادات |
| المرتجعات | |
|---|---|
Slot | عنصر الخانة الذي تم استدعاء الطريقة عليه |
setTargeting
setTargeting(key: string, value: string | string[]): Slot- مثال
JavaScript
const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div"); slot.addService(googletag.pubads()); // Example with a single value for a key. slot.setConfig({ targeting: { allow_expandable: "true", }, }); // Example with multiple values for a key inside in an array. slot.setConfig({ targeting: { interests: ["sports", "music"], }, });
TypeScript
const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div")!; slot.addService(googletag.pubads()); // Example with a single value for a key. slot.setConfig({ targeting: { allow_expandable: "true", }, }); // Example with multiple values for a key inside in an array. slot.setConfig({ targeting: { interests: ["sports", "music"], }, });
- انظر أيضًا
| المعلمات | |
|---|---|
key: string | مفتاح مَعلمة الاستهداف |
value: string | string[] | قيمة مَعلمة الاستهداف أو مصفوفة القيم |
| المرتجعات | |
|---|---|
Slot | عنصر الخانة الذي تم استدعاء الطريقة عليه |
updateTargetingFromMap
updateTargetingFromMap(map: {
[adUnitPath: string]: string | string[];
}): Slotملاحظات:
- في حال الاستبدال، سيتم الاحتفاظ بالقيمة الأخيرة فقط.
- إذا كانت القيمة مصفوفة، سيتم استبدال أي قيمة سابقة، وليس دمجها.
- ستحلّ القيم المحدّدة هنا محلّ مَعلمات الاستهداف المحدّدة على مستوى الخدمة.
- مثال
JavaScript
const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div"); slot.updateTargetingFromMap({ color: "red", interests: ["sports", "music", "movies"], });
TypeScript
const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div")!; slot.updateTargetingFromMap({ color: "red", interests: ["sports", "music", "movies"], });
| المعلمات | |
|---|---|
map: { | خريطة المفتاح:القيمة لمَعلمة الاستهداف |
| المرتجعات | |
|---|---|
Slot | عنصر الخانة الذي تم استدعاء الطريقة عليه |
googletag.config
| واجهات | |
|---|---|
Ad | إعدادات للتحكّم في توسيع خانة الإعلان |
Ad | إعدادات للتحكّم في سلوك إعلانات AdSense |
Auto | إعدادات ضبط إعادة التحميل التلقائي |
Continue | إعدادات لضبط سلوك زر المتابعة |
Interstitial | عنصر يحدّد سلوك خانة إعلانية بينية واحدة |
Lazy | إعدادات للتحكّم في استخدام ميزة "التحميل الكسول" في علامة GPT |
Page | واجهة الضبط الرئيسية للإعدادات على مستوى الصفحة |
Privacy | إعدادات للتحكّم في معالجات الخصوصية لدى الناشرين |
Publisher | عنصر ضبط الإشارات المقدَّمة من الناشر (PPS) |
Safe | إعدادات للتحكّم في SafeFrame في GPT |
Slot | واجهة الضبط الرئيسية للإعدادات على مستوى الخانة |
Taxonomy | عنصر يحتوي على قيم تصنيف واحد. |
Video | إعدادات لضبط الإعدادات ذات الصلة بإعلانات الفيديو |
| الأسماء المستعارة للأنواع | |
|---|---|
Collapse | القيم المسموح بها للتحكّم في سلوك تصغير الخانات الإعلانية |
Interstitial | عوامل التشغيل المتوافقة لـ "الإعلانات البينية" |
Privacy | إجراءات الخصوصية المتوافقة مع الناشرين |
Taxonomy | التصنيفات المتوافقة مع الإشارات المقدَّمة من الناشر (PPS) |
الأسماء المستعارة للأنواع
CollapseDivBehavior
CollapseDivBehavior: "DISABLED" | "BEFORE_FETCH" | "ON_NO_FILL"InterstitialTrigger
InterstitialTrigger: "unhideWindow" | "navBar" | "inactivity" | "endOfArticle" | "continueReading" | "backward"ملاحظة: اعتبارًا من 15 يونيو 2026، لن يكون إجراء التفعيل
backward متاحًا ولن يؤدي تفعيله إلى أي نتيجة. لمزيد من المعلومات، يُرجى الاطّلاع على ملاحظات إصدار GPT.PrivacyTreatment
PrivacyTreatment: "disablePersonalization"التصنيف
Taxonomy: "IAB_AUDIENCE_1_1" | "IAB_CONTENT_2_2"googletag.config.AdExpansionConfig
| الخصائص | |
|---|---|
enabled | ما إذا كانت ميزة توسيع خانة الإعلان مفعَّلة أو غير مفعَّلة |
- مثال
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 }, });
الخصائص
تم تفعيل Optional
enabled?: booleanيؤدي ضبط هذه القيمة إلى إلغاء القيمة التلقائية التي تم ضبطها في "إدارة إعلانات Google".
googletag.config.AdSenseAttributesConfig
يمكن استخدام هذه السمات لإلغاء الإعدادات من جهة الخادم لكل طلب.
| الخصائص | |
|---|---|
adsense | شكل إعلان AdSense |
adsense | معرّفات قنوات AdSense |
adsense | ما إذا كان وضع الاختبار مفعَّلاً أم لا |
document | لغة الصفحة التي يتم عرض الإعلانات عليها |
page | عنوان URL للصفحة التي يتم عرض الإعلانات عليها |
الخصائص
Optional adsense_ad_format
adsense_ad_format?: "120x240_as" | "120x600_as" | "125x125_as" | "160x600_as" | "180x150_as" | "200x200_as" | "234x60_as" | "250x250_as" | "300x250_as" | "336x280_as" | "468x60_as" | "728x90_as"Optional adsense_channel_ids
adsense_channel_ids?: stringالقيم المسموح بها هي معرّفات القنوات مفصولة بعلامة "+".
مثال:
271828183+314159265Optional adsense_test_mode
adsense_test_mode?: "on"عند ضبطها على
on، يتم وضع علامة على الإعلانات بأنّها مخصّصة للاختبار فقط، ولن يتم تضمينها في الاحتساب أو الفوترة. يجب إلغاء ضبط هذا الإعداد لزيارات الإنتاج غير الاختبارية.Optional document_language
document_language?: stringالقيم المسموح بها هي رموز لغات صالحة وفقًا لمعيار ISO 639-1.
مثال:
en- انظر أيضًا
Optional page_url
page_url?: stringالقيم المسموح بها هي عناوين URL صالحة.
مثال:
http://www.example.comgoogletag.config.AutoRefreshConfig
| الخصائص | |
|---|---|
back | ما إذا كانت علامة GPT ستُعيد تحميل خانة إعلانية يتم عرضها بشكل نشط تلقائيًا عند استعادة الصفحة من ميزة "التخزين المؤقت للصفحات". |
heavy | ما إذا كانت علامة GPT ستُعيد تحميل خانة إعلانية تلقائيًا في حال تفعيل ميزة "التدخّل في الإعلانات الثقيلة" في Chrome على إطار iframe الخاص بالإعلان في الخانة. |
الخصائص
Optional backForwardCache
backForwardCache?: booleantrue.- مثال
JavaScript
// Set the auto refresh configuration, disabling auto refresh on // back/forward cache restore. googletag.setConfig({ autoRefresh: { backForwardCache: false } }); // Clear the auto refresh configuration, restoring to default behavior. googletag.setConfig({ autoRefresh: null });
TypeScript
// Set the auto refresh configuration, disabling auto refresh on // back/forward cache restore. googletag.setConfig({ autoRefresh: { backForwardCache: false } }); // Clear the auto refresh configuration, restoring to default behavior. googletag.setConfig({ autoRefresh: null });
- انظر أيضًا
Optional heavyAds
heavyAds?: booleantrue.- مثال
JavaScript
// Set the auto refresh configuration, disabling auto refresh on heavy // ad intervention. googletag.setConfig({ autoRefresh: { heavyAds: false } }); // Clear the auto refresh configuration, restoring to default behavior. googletag.setConfig({ autoRefresh: null });
TypeScript
// Set the auto refresh configuration, disabling auto refresh on heavy // ad intervention. googletag.setConfig({ autoRefresh: { heavyAds: false } }); // Clear the auto refresh configuration, restoring to default behavior. googletag.setConfig({ autoRefresh: null });
googletag.config.ContinueButtonConfig
| الخصائص | |
|---|---|
background | لون خلفية الزر |
font | مجموعة خطوط نص الزر |
font | لون نص الزر |
freq | الفاصل الزمني لتحديد عدد مرات الظهور بالدقائق |
target | رقم تعريف عنصر HTML الذي سيتم عرض زر المتابعة عليه أو تفعيله. |
- انظر أيضًا
الخصائص
Optional backgroundColor
backgroundColor?: stringمثال:
'blue'، '#94B1FF'Optional خط
font?: stringمثال:
'Arial'Optional fontColor
fontColor?: stringمثال:
'white'، '#B73B87'Optional freqCapIntervalMinutes
freqCapIntervalMinutes?: numberيجب أن تكون عددًا صحيحًا أكبر من أو يساوي 1.
Optional targetId
targetId?: stringgoogletag.config.InterstitialConfig
| الخصائص | |
|---|---|
require | ما إذا كانت الموافقة على التخزين المحلي مطلوبة لعرض هذا الإعلان البيني. |
triggers | إعدادات مشغّل "الإعلان البيني" لهذا الإعلان |
الخصائص
Optional requireStorageAccess
requireStorageAccess?: booleanتستخدم علامة GPT التخزين المحلي لفرض حدّ لعدد مرات الظهور للإعلانات البينية. ومع ذلك، يظل المستخدمون الذين لم يمنحوا موافقة على استخدام مساحة التخزين المحلية مؤهَّلين لعرض "الإعلانات البينية". يؤدي ضبط هذه السمة على
true إلى إيقاف الإعداد التلقائي، ويضمن عرض "الإعلانات البينية" فقط للمستخدمين الذين قدّموا موافقتهم على استخدام مساحة التخزين على الجهاز.- مثال
JavaScript
// Opt out of showing interstitials to users // without local storage consent. const interstitialSlot = googletag.defineOutOfPageSlot( "/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL, ); interstitialSlot.setConfig({ interstitial: { requireStorageAccess: true, // defaults to false }, });
TypeScript
// Opt out of showing interstitials to users // without local storage consent. const interstitialSlot = googletag.defineOutOfPageSlot( "/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL, )!; interstitialSlot.setConfig({ interstitial: { requireStorageAccess: true, // defaults to false }, });
Optional مشغِّل
triggers?: Partial<Record<InterstitialTrigger, boolean>>سيؤدي ضبط قيمة مشغّل الإعلان البيني على
true إلى تفعيله، وسيؤدي ضبطها على false إلى إيقافه. سيؤدي ذلك إلى إلغاء القيم التلقائية التي تم ضبطها في "إدارة إعلانات Google".- مثال
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, }, }, });
TypeScript
// Define a GPT managed web interstitial ad slot. const interstitialSlot = googletag.defineOutOfPageSlot( "/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL, )!; // Enable optional interstitial triggers. // Change this value to false to disable. const enableTriggers = true; interstitialSlot.setConfig({ interstitial: { triggers: { navBar: enableTriggers, unhideWindow: enableTriggers, }, }, });
- انظر أيضًا
googletag.config.LazyLoadConfig
| الخصائص | |
|---|---|
fetch | الحدّ الأدنى للمسافة من إطار العرض الحالي الذي يجب أن تكون فيه الخانة قبل طلب إعلان، ويتم التعبير عنه كنسبة مئوية من حجم إطار العرض. |
mobile | مُضاعِف يتم تطبيقه على الهوامش على الأجهزة الجوّالة |
render | الحدّ الأدنى للمسافة من إطار العرض الحالي الذي يجب أن تكون فيه خانة إعلانية قبل عرض إعلان، ويتم التعبير عنه كنسبة مئوية من حجم إطار العرض. |
- انظر أيضًا
الخصائص
Optional fetchMarginPercent
fetchMarginPercent?: numberعند استخدام هذا الإعداد مع renderMarginPercent، يسمح بالجلب المُسبق لإعلان، ولكن مع الانتظار لعرض الموارد الفرعية الأخرى وتنزيلها. وعلى هذا النحو، يجب أن تكون هذه القيمة دائمًا أكبر من أو تساوي renderMarginPercent.
تعني القيمة
0 "عندما تدخل الخانة إطار العرض"، وتعني القيمة 100 "عندما يكون الإعلان على بُعد إطار عرض واحد"، وهكذا.Optional mobileScaling
mobileScaling?: numberيتيح ذلك استخدام هوامش مختلفة على الأجهزة الجوّالة مقارنةً بأجهزة الكمبيوتر المكتبي، حيث قد تختلف أحجام إطارات العرض وسرعات الانتقال. على سبيل المثال، ستؤدي القيمة 2.0 إلى مضاعفة جميع الهوامش في 2 على الأجهزة الجوّالة، ما يزيد من الحد الأدنى للمسافة التي يمكن أن تفصل بين الخانة وإطار العرض قبل جلب الإعلان وعرضه.
Optional renderMarginPercent
renderMarginPercent?: numberعند استخدام هذا الإعداد مع fetchMarginPercent، يسمح بالجلب المُسبق للإعلان، ولكن مع الانتظار لعرض الموارد الفرعية الأخرى وتنزيلها. على هذا النحو، يجب أن تكون هذه القيمة دائمًا أقل من أو تساوي fetchMarginPercent.
تعني القيمة
0 "عندما تدخل الخانة إلى إطار العرض"، وتعني القيمة 100 "عندما يكون الإعلان على بُعد إطار عرض واحد"، وهكذا.googletag.config.PageSettingsConfig
تسمح بضبط ميزات متعددة من خلال طلب بيانات من واجهة برمجة التطبيقات.
جميع السمات المدرَجة أدناه هي أمثلة ولا تعكس الميزات الفعلية التي تستخدم setConfig. للاطّلاع على مجموعة الميزات، يُرجى مراجعة الحقول ضمن نوع PageSettingsConfig أدناه.
أمثلة:
- يتم تعديل الميزات المحدّدة في طلب googletag.setConfig فقط.
// Configure feature alpha. googletag.setConfig({ alpha: {...} }); // Configure feature bravo. Feature alpha is unchanged. googletag.setConfig({ bravo: {...} });
- يتم تعديل جميع إعدادات ميزة معيّنة مع كل طلب إلى googletag.setConfig.
// Configure feature charlie to echo = 1, foxtrot = true. googletag.setConfig({ charlie: { echo: 1, foxtrot: true, } }); // Update feature charlie to echo = 2. Since foxtrot was not specified, // the value is cleared. googletag.setConfig({ charlie: { echo: 2 } });
- يمكن محو جميع إعدادات ميزة معيّنة من خلال ضبط القيمة
null.// Configure features delta, golf, and hotel. googletag.setConfig({ delta: {...}, golf: {...}, hotel: {...}, }); // Feature delta and hotel are cleared, but feature golf remains set. googletag.setConfig({ delta: null, hotel: null, });
| الخصائص | |
|---|---|
ad | إعدادات للتحكّم في توسيع خانة الإعلان |
adsense | إعداد لضبط سمات AdSense |
ad | متوقّف نهائيًا. |
auto | إعداد لضبط سلوك إعادة تحميل الإعلانات تلقائيًا |
category | إعداد لضبط استبعادات فئات الإعلانات |
centering | إعداد للتحكّم في توسيط الإعلانات أفقيًا |
collapse | إعداد للتحكّم في سلوك تصغير الخانات الإعلانية |
disable | إعداد للتحكّم في وقت طلب الإعلانات |
lazy | إعدادات للتحكّم في استخدام ميزة "التحميل الكسول" في علامة GPT |
location | إعداد لاستهداف المواقع الجغرافية في تفاصيل الإعلان. |
pps | إعدادات للتحكّم في الإشارات المقدَّمة من الناشر (PPS) |
privacy | إعدادات للتحكّم في معالجات الخصوصية لدى الناشرين |
request | إعداد للتحكّم في الحد الأقصى للوقت الذي ستنتظره علامة GPT حتى تكتمل جميع عمليات الربط المسجَّلة للطلبات قبل المتابعة في طلب عرض الإعلان. |
safe | إعدادات للتحكّم في استخدام SafeFrame في GPT |
single | إعداد لتفعيل أو إيقاف بنية الإعلان الأحادي الطلب (SRA) |
targeting | إعداد للتحكّم في استهداف المفتاح/القيمة |
thread | إعداد للتحكّم في ما إذا كان يجب أن تتخلى علامة GPT عن سلسلة تعليمات JS عند طلب تصاميم الإعلانات وعرضها. |
video | إعدادات للتحكّم في إعلانات الفيديو |
الخصائص
Optional adExpansion
adExpansion?: AdExpansionConfigOptional adsenseAttributes
adsenseAttributes?: AdSenseAttributesConfigستنطبق سمات AdSense التي تم ضبطها من خلال هذا الإعداد على جميع الخانات الإعلانية في الصفحة. يمكن استدعاء هذا الإعداد عدة مرات لتحديد قيم سمات متعددة أو استبدال القيم الحالية.
لا تسري تغييرات سمات AdSense إلا على طلبات عرض الإعلانات المطلوبة بعد استدعاء هذه الطريقة. لهذا السبب، ننصح بطلب هذه الطريقة قبل أي طلبات إلى googletag.display أو PubAdsService.refresh.
- مثال
JavaScript
// Set the document language and page URL. googletag.setConfig({ adsenseAttributes: { document_language: "en", page_url: "http://www.example.com" }, }); // Clear the page URL only. googletag.setConfig({ adsenseAttributes: { page_url: null } }); // Clear all AdSense attributes. googletag.setConfig({ adsenseAttributes: null });
TypeScript
// Set the document language and page URL. googletag.setConfig({ adsenseAttributes: { document_language: "en", page_url: "http://www.example.com" }, }); // Clear the page URL only. googletag.setConfig({ adsenseAttributes: { page_url: null } }); // Clear all AdSense attributes. googletag.setConfig({ adsenseAttributes: null });
Optional adYield
adYield?: "DISABLED" | "ENABLED_ALL_SLOTS"Optional autoRefresh
autoRefresh?: AutoRefreshConfig- مثال
JavaScript
// Set the auto refresh configuration. googletag.setConfig({ autoRefresh: { heavyAds: false } }); // Clear the auto refresh configuration. googletag.setConfig({ autoRefresh: null });
TypeScript
// Set the auto refresh configuration. googletag.setConfig({ autoRefresh: { heavyAds: false } }); // Clear the auto refresh configuration. googletag.setConfig({ autoRefresh: null });
Optional categoryExclusion
categoryExclusion?: string[]- مثال
JavaScript
// Label = AirlineAd. googletag.setConfig({ categoryExclusion: ["AirlineAd"] }); // Clearing category exclusion setting. googletag.setConfig({ categoryExclusion: null });
TypeScript
// Label = AirlineAd. googletag.setConfig({ categoryExclusion: ["AirlineAd"] }); // Clearing category exclusion setting. googletag.setConfig({ categoryExclusion: null });
Optional التوسيط
centering?: booleanلا تنطبق تغييرات التوسيط الأفقي إلا على طلبات عرض الإعلانات المطلوبة بعد استدعاء هذه الطريقة. لهذا السبب، ننصح بطلب هذه الطريقة قبل أي طلبات إلى googletag.display أو PubAdsService.refresh.
- مثال
JavaScript
// Make ads centered. googletag.setConfig({ centering: true }); // Clear the centering setting. googletag.setConfig({ centering: null });
TypeScript
// Make ads centered. googletag.setConfig({ centering: true }); // Clear the centering setting. googletag.setConfig({ centering: null });
Optional collapseDiv
collapseDiv?: CollapseDivBehaviorلا تشغل الخانة الإعلانية المصغّرة أي مساحة على الصفحة.
القيم المسموح بها:
-
null(تلقائي): لن يتم تصغير الخانة الإعلانية. -
DISABLED: لن يتم تصغير الخانة، سواء تم عرض إعلان أم لا. -
BEFORE_FETCH: ستبدأ الخانة في وضع التصغير، ثم تتوسّع عند عرض إعلان. -
ON_NO_FILL: ستبدأ الخانة الإعلانية موسَّعة، وسيتم تصغيرها في حال عدم عرض أي إعلان.
- مثال
JavaScript
// Collapse the div for this slot if no ad is returned. googletag.setConfig({ collapseDiv: "ON_NO_FILL" }); // Collapse the div for this slot by default, and expand only // if an ad is returned. googletag.setConfig({ collapseDiv: "BEFORE_FETCH" }); // Do not collapse the div for this slot. googletag.setConfig({ collapseDiv: "DISABLED" }); // Clear the collapse setting. googletag.setConfig({ collapseDiv: null });
TypeScript
// Collapse the div for this slot if no ad is returned. googletag.setConfig({ collapseDiv: "ON_NO_FILL" }); // Collapse the div for this slot by default, and expand only // if an ad is returned. googletag.setConfig({ collapseDiv: "BEFORE_FETCH" }); // Do not collapse the div for this slot. googletag.setConfig({ collapseDiv: "DISABLED" }); // Clear the collapse setting. googletag.setConfig({ collapseDiv: null });
Optional disableInitialLoad
disableInitialLoad?: booleanتُسجِّل طريقة googletag.display تلقائيًا الخانات الإعلانية وتطلب الإعلانات لها. ومع ذلك، قد يكون من الأفضل في بعض الأحيان فصل هذين الإجراءَين، من أجل التحكّم بدقة أكبر في وقت تحميل محتوى الإعلان.
من خلال تفعيل هذا الإعداد، لن يتم طلب الإعلانات للخانَات المسجَّلة عند استدعاء الطريقة
display(). بدلاً من ذلك، يجب إجراء طلب منفصل إلى PubAdsService.refresh لبدء طلب عرض الإعلان.يجب استدعاء هذه الطريقة قبل استدعاء googletag.enableServices.
- مثال
JavaScript
// Prevent requesting ads when `display()` is called. googletag.setConfig({ disableInitialLoad: true });
TypeScript
// Prevent requesting ads when `display()` is called. googletag.setConfig({ disableInitialLoad: true });
Optional lazyLoad
lazyLoad?: LazyLoadConfig"التحميل الكسول" هو أسلوب لتأخير طلب الإعلانات وعرضها إلى أن تقترب من إطار عرض المستخدِم. للحصول على مثال أكثر تفصيلاً، يمكنك الاطّلاع على نموذج التحميل الكسول.
ملاحظة: في حال تفعيل
singleRequest، لن يعمل الجلب الكسول إلا عندما تكون جميع الخانات خارج هامش الجلب.ستستخدم أي إعدادات للتحميل الكسول لم يتم تحديدها عند طلب
setConfig() قيمة تلقائية تحدّدها Google. وقد يتم ضبط هذه الإعدادات التلقائية بمرور الوقت. لإيقاف إعداد معيّن، اضبط القيمة على null.- مثال
JavaScript
// Enable lazy loading. googletag.setConfig({ lazyLoad: { // Fetch slots within 5 viewports. fetchMarginPercent: 500, // Render slots within 2 viewports. renderMarginPercent: 200, // Double the above values on mobile. mobileScaling: 2.0, }, }); // Clear fetch margin only. googletag.setConfig({ lazyLoad: { fetchMarginPercent: null }, }); // Clear all lazy loading settings. googletag.setConfig({ lazyLoad: null });
TypeScript
// Enable lazy loading. googletag.setConfig({ lazyLoad: { // Fetch slots within 5 viewports. fetchMarginPercent: 500, // Render slots within 2 viewports. renderMarginPercent: 200, // Double the above values on mobile. mobileScaling: 2.0, }, }); // Clear fetch margin only. googletag.setConfig({ lazyLoad: { fetchMarginPercent: null }, }); // Clear all lazy loading settings. googletag.setConfig({ lazyLoad: null });
Optional الموقع الجغرافي
location?: string- مثال
JavaScript
// Geo-target line items to US postal code 10001. googletag.setConfig({ location: "10001,US" }); // Clear the location setting. googletag.setConfig({ location: null });
TypeScript
// Geo-target line items to US postal code 10001. googletag.setConfig({ location: "10001,US" }); // Clear the location setting. googletag.setConfig({ location: null });
- انظر أيضًا
Optional pps
Optional privacyTreatments
privacyTreatments?: PrivacyTreatmentsConfigOptional Experimental requestHookTimeoutMs
requestHookTimeoutMs?: number | "auto"يتم تنفيذ جميع دوال الربط المسجَّلة لطلبات الإعلانات بالتوازي. تحدّد هذه المهلة الحدّ الأقصى لمدة إيقاف عملية طلب عرض الإعلان مؤقتًا أثناء انتظار اكتمال عمليات التنفيذ الموازية.
القيم المسموح بها:
- رقم موجب بالمللي ثانية: فترة الانتظار المخصّصة
-
'auto': تستخدم علامة GPT مهلة محسّنة من Google. -
null: لإيقاف المهلات (تنتظر علامة GPT إلى أجل غير مسمى حتى تكتمل عمليات الربط)
- مثال
JavaScript
// Set a 1000ms timeout for request hooks. googletag.setConfig({ requestHookTimeoutMs: 1000 }); // Use a Google-optimized timeout for request hooks. googletag.setConfig({ requestHookTimeoutMs: "auto" }); // Clear the timeout. googletag.setConfig({ requestHookTimeoutMs: null });
TypeScript
// Set a 1000ms timeout for request hooks. googletag.setConfig({ requestHookTimeoutMs: 1000 }); // Use a Google-optimized timeout for request hooks. googletag.setConfig({ requestHookTimeoutMs: "auto" }); // Clear the timeout. googletag.setConfig({ requestHookTimeoutMs: null });
Optional safeFrame
safeFrame?: SafeFrameConfigستنطبق القيم التي تم ضبطها من خلال هذا الإعداد على جميع الخانات الإعلانية في الصفحة. قد تلغي الخانات الإعلانية الفردية هذه القيم من خلال SlotSettingsConfig.safeFrame.
- مثال
JavaScript
// Force SafeFrame for all ads on the page. googletag.setConfig({ safeFrame: { forceSafeFrame: true }, }); // Configure SafeFrame to allow overlay expansion. googletag.setConfig({ safeFrame: { allowOverlayExpansion: true }, }); // Clear forceSafeFrame setting. googletag.setConfig({ safeFrame: { forceSafeFrame: null }, }); // Clear all SafeFrame settings. googletag.setConfig({ safeFrame: null });
TypeScript
// Force SafeFrame for all ads on the page. googletag.setConfig({ safeFrame: { forceSafeFrame: true }, }); // Configure SafeFrame to allow overlay expansion. googletag.setConfig({ safeFrame: { allowOverlayExpansion: true }, }); // Clear forceSafeFrame setting. googletag.setConfig({ safeFrame: { forceSafeFrame: null }, }); // Clear all SafeFrame settings. googletag.setConfig({ safeFrame: null });
Optional singleRequest
singleRequest?: booleanعند تفعيل بنية الإعلان الأحادي الطلب، سيتم تجميع كل الخانات الإعلانية المحدّدة قبل طلب googletag.display أو PubAdsService.refresh في طلب عرض إعلان واحد. يوفّر ذلك مزايا في الأداء، ولكنه ضروري أيضًا لضمان الالتزام بحظر الإعلانات المتزامنة والاستبعادات التنافسية.
عند إيقاف بنية الإعلان الأحادي الطلب، يتم طلب كل خانة إعلانية بشكل فردي. هذا هو الإعداد التلقائي لـ GPT.
يجب استدعاء هذه الطريقة قبل استدعاء googletag.enableServices.
- مثال
JavaScript
// Enable Single Request Architecture. googletag.setConfig({ singleRequest: true });
TypeScript
// Enable Single Request Architecture. googletag.setConfig({ singleRequest: true });
Optional الاستهداف
targeting?: Record<string, string | string[]>سيتم تطبيق الاستهداف الذي تم ضبطه من خلال هذا الإعداد على جميع الخانات الإعلانية في الصفحة. يمكن استدعاء هذا الإعداد عدة مرات لتحديد قيم مفاتيح استهداف متعددة أو استبدال القيم الحالية. يتم تحديد مفاتيح الاستهداف في حسابك على "إدارة إعلانات Google".
- مثال
JavaScript
// Setting a single targeting key-value. googletag.setConfig({ targeting: { interests: "sports" } }); // Setting multiple values for a single targeting key googletag.setConfig({ targeting: { interests: ["sports", "music"] } }); // Setting multiple targeting key-values at once. googletag.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } }); // Clearing a single targeting key. googletag.setConfig({ targeting: { interests: null } });
TypeScript
// Setting a single targeting key-value. googletag.setConfig({ targeting: { interests: "sports" } }); // Setting multiple values for a single targeting key googletag.setConfig({ targeting: { interests: ["sports", "music"] } }); // Setting multiple targeting key-values at once. googletag.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } }); // Clearing a single targeting key. googletag.setConfig({ targeting: { interests: null } });
- انظر أيضًا
Optional threadYield
threadYield?: "DISABLED" | "ENABLED_ALL_SLOTS"لن تتخلى علامة GPT عن سلسلة المهام إلا للمتصفحات التي تتيح استخدام واجهة برمجة التطبيقات Scheduler.postTask أو Scheduler.yield.
القيم المسموح بها:
-
null(تلقائي): ستتخلى علامة GPT عن سلسلة مهام JavaScript للخانات خارج إطار العرض. -
ENABLED_ALL_SLOTS: ستتخلى GPT عن سلسلة مهام JS لجميع الخانات بغض النظر عمّا إذا كانت الخانة ضمن إطار العرض. DISABLED: لن تتيح علامة GPT استخدام سلسلة تعليمات JavaScript.
- مثال
JavaScript
// Disable yielding. googletag.setConfig({ threadYield: "DISABLED" }); // Enable yielding for all slots. googletag.setConfig({ threadYield: "ENABLED_ALL_SLOTS" }); // Enable yielding only for slots outside of the viewport (default). googletag.setConfig({ threadYield: null });
TypeScript
// Disable yielding. googletag.setConfig({ threadYield: "DISABLED" }); // Enable yielding for all slots. googletag.setConfig({ threadYield: "ENABLED_ALL_SLOTS" }); // Enable yielding only for slots outside of the viewport (default). googletag.setConfig({ threadYield: null });
- انظر أيضًا
Optional videoAds
videoAds?: VideoAdsConfig- مثال
JavaScript
// Enable video ads and set video content and content source IDs. googletag.setConfig({ videoAds: { enableVideoAds: true, videoContentId: "e1eGlRL7ju8", videoCmsId: "1234567", }, });
TypeScript
// Enable video ads and set video content and content source IDs. googletag.setConfig({ videoAds: { enableVideoAds: true, videoContentId: "e1eGlRL7ju8", videoCmsId: "1234567", }, });
- انظر أيضًا
googletag.config.PrivacyTreatmentsConfig
| الخصائص | |
|---|---|
treatments | مصفوفة من معالجات الخصوصية التي يمكن للناشر تفعيلها |
الخصائص
treatments
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
| الخصائص | |
|---|---|
taxonomies | عنصر يحتوي على عمليات ربط التصنيف أو قيمة فارغة لمحو الإعدادات |
- مثال
JavaScript
googletag.setConfig({ pps: { taxonomies: { IAB_AUDIENCE_1_1: { values: ["6", "626"] }, // '6' = 'Demographic | Age Range | 30-34' // '626' = 'Interest | Sports | Darts' IAB_CONTENT_2_2: { values: ["48", "127"] }, // '48' = 'Books and Literature | Fiction' // '127' = 'Careers | Job Search' }, }, });
TypeScript
googletag.setConfig({ pps: { taxonomies: { IAB_AUDIENCE_1_1: { values: ["6", "626"] }, // '6' = 'Demographic | Age Range | 30-34' // '626' = 'Interest | Sports | Darts' IAB_CONTENT_2_2: { values: ["48", "127"] }, // '48' = 'Books and Literature | Fiction' // '127' = 'Careers | Job Search' }, }, });
الخصائص
taxonomies
taxonomies: Partial<Record<Taxonomy, TaxonomyData>>googletag.config.SafeFrameConfig
| الخصائص | |
|---|---|
allow | ما إذا كان يجب أن يسمح SafeFrame بتوسيع محتوى الإعلان من خلال تراكب محتوى الصفحة |
allow | ما إذا كان يجب أن يسمح SafeFrame بتوسيع محتوى الإعلان من خلال دفع محتوى الصفحة |
force | ما إذا كان يجب فرض عرض الإعلانات باستخدام حاوية SafeFrame |
sandbox | ما إذا كان يجب أن يستخدم SafeFrame سمة وضع الحماية في HTML5 لمنع التنقّل في المستوى الأعلى بدون تفاعل المستخدم. |
use | تمّت إزالة هذا العمود. ما إذا كان يجب أن يستخدم SafeFrame نطاقات فرعية عشوائية لتصاميم الإعلانات القائمة على الحجز. |
الخصائص
Optional allowOverlayExpansion
allowOverlayExpansion?: booleanOptional allowPushExpansion
allowPushExpansion?: booleanOptional forceSafeFrame
forceSafeFrame?: booleanOptional sandbox
sandbox?: booleantrue (لا يمكن فرضها على false). يُرجى العِلم أنّ سمة وضع الحماية توقف المكوّنات الإضافية (مثل Flash).Optional useUniqueDomain
useUniqueDomain?: booleannull لمحو القيمة المخزَّنة.ملاحظة: تكون هذه الميزة مفعَّلة تلقائيًا.
- انظر أيضًا
googletag.config.SlotSettingsConfig
تسمح بضبط ميزات متعددة من خلال طلب بيانات من واجهة برمجة التطبيقات لخانة واحدة
جميع السمات المدرَجة أدناه هي أمثلة ولا تعكس الميزات الفعلية التي تستخدم setConfig. للاطّلاع على مجموعة الميزات، يُرجى مراجعة الحقول ضمن نوع SlotSettingsConfig أدناه.
أمثلة:
- يتم تعديل الميزات المحدّدة في طلب Slot.setConfig فقط.
const slot = googletag.defineSlot("/1234567/example", [160, 600]); // Configure feature alpha. slot.setConfig({ alpha: {...} }); // Configure feature bravo. Feature alpha is unchanged. slot.setConfig({ bravo: {...} });
- يتم تعديل جميع إعدادات ميزة معيّنة مع كل طلب إلى Slot.setConfig.
// Configure feature charlie to echo = 1, foxtrot = true. slot.setConfig({ charlie: { echo: 1, foxtrot: true, } }); // Update feature charlie to echo = 2. Since foxtrot was not specified, // the value is cleared. slot.setConfig({ charlie: { echo: 2 } });
- يمكن محو جميع إعدادات ميزة معيّنة من خلال ضبط القيمة
null.// Configure features delta, golf, and hotel. slot.setConfig({ delta: {...}, golf: {...}, hotel: {...}, }); // Feature delta and hotel are cleared, but feature golf remains set. slot.setConfig({ delta: null, hotel: null, });
| الخصائص | |
|---|---|
ad | إعدادات ضبط ميزة "توسيع خانة الإعلان" |
adsense | إعداد لضبط سمات AdSense |
category | إعداد لضبط استبعادات فئات الإعلانات |
click | إعداد لضبط عنوان URL الذي ستتم إعادة توجيه المستخدمين إليه بعد النقر على الإعلان. |
collapse | إعداد لضبط سلوك تصغير الخانة الإعلانية |
continue | إعدادات لضبط سلوك زر المتابعة في "الإعلانات أثناء إيقاف الفيديو مؤقتًا". |
interstitial | الإعدادات التي تضبط سلوك الخانة الإعلانية البينية |
safe | إعدادات لضبط استخدام SafeFrame في GPT |
targeting | إعداد لضبط استهداف أزواج المفتاح/القيمة |
الخصائص
Optional adExpansion
adExpansion?: AdExpansionConfig- انظر أيضًا
Optional adsenseAttributes
adsenseAttributes?: AdSenseAttributesConfigلن تنطبق سمات AdSense التي تم ضبطها من خلال هذا الإعداد إلا على الخانة الإعلانية. يمكن استدعاء هذا الإعداد عدة مرات لتحديد قيم سمات متعددة أو استبدال القيم الحالية.
لا تسري تغييرات سمات AdSense إلا على طلبات عرض الإعلانات المطلوبة بعد استدعاء هذه الطريقة. لهذا السبب، ننصح بطلب هذه الطريقة قبل أي طلبات إلى googletag.display أو PubAdsService.refresh.
- مثال
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Set the AdSense ad format and channel IDs. slot.setConfig({ adsenseAttributes: { adsense_ad_format: "120x240_as", adsense_channel_ids: "271828183+314159265", }, }); // Clear the AdSense channel IDs only. slot.setConfig({ adsenseAttributes: { adsense_channel_ids: null } }); // Clear all AdSense attributes. slot.setConfig({ adsenseAttributes: null });
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); // Set the AdSense ad format and channel IDs. slot.setConfig({ adsenseAttributes: { adsense_ad_format: "120x240_as", adsense_channel_ids: "271828183+314159265", }, }); // Clear the AdSense channel IDs only. slot.setConfig({ adsenseAttributes: { adsense_channel_ids: null } }); // Clear all AdSense attributes. slot.setConfig({ adsenseAttributes: null });
Optional categoryExclusion
categoryExclusion?: string[]- مثال
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Label = AirlineAd slot.setConfig({ categoryExclusion: ["AirlineAd"], }); // Clearing category exclusion setting. slot.setConfig({ categoryExclusion: null });
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); // Label = AirlineAd slot.setConfig({ categoryExclusion: ["AirlineAd"], }); // Clearing category exclusion setting. slot.setConfig({ categoryExclusion: null });
Optional clickUrl
clickUrl?: stringتستمر خوادم "إدارة إعلانات Google" في تسجيل النقرات حتى في حال استبدال عنوان URL للنقرة. تتم إضافة أي عنوان URL للصفحة المقصودة مرتبط بتصميم الإعلان الذي يتم عرضه إلى القيمة المقدَّمة. سيؤدي ضبط هذه القيمة أكثر من مرة إلى استبدال أي قيمة تم ضبطها سابقًا. سيؤدي إدخال
null إلى محو القيمة.ملاحظة: لا ينطبق هذا الإعداد إلا على الطلبات غير المستندة إلى بنية الإعلان الأحادي الطلب (SRA).
- مثال
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Sets the click URL to 'http://www.example.com?original_click_url='. slot.setConfig({ clickUrl: "http://www.example.com?original_click_url=", }); // Clears the click URL. slot.setConfig({ clickUrl: null, });
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); // Sets the click URL to 'http://www.example.com?original_click_url='. slot.setConfig({ clickUrl: "http://www.example.com?original_click_url=", }); // Clears the click URL. slot.setConfig({ clickUrl: null, });
Optional collapseDiv
collapseDiv?: CollapseDivBehaviorلا تشغل الخانة الإعلانية المصغّرة أي مساحة على الصفحة.
القيم المسموح بها:
-
null(تلقائي): لن يتم تصغير الخانة الإعلانية. -
DISABLED: لن يتم تصغير الخانة، سواء تم عرض إعلان أم لا. -
BEFORE_FETCH: ستبدأ الخانة في وضع التصغير، ثم تتوسّع عند عرض إعلان. -
ON_NO_FILL: ستبدأ الخانة الإعلانية موسَّعة، وسيتم تصغيرها في حال عدم عرض أي إعلان.
- مثال
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Collapse the div for this slot if no ad is returned. slot.setConfig({ collapseDiv: "ON_NO_FILL", }); // Collapse the div for this slot by default, and expand only // if an ad is returned. slot.setConfig({ collapseDiv: "BEFORE_FETCH", }); // Do not collapse the div for this slot. slot.setConfig({ collapseDiv: "DISABLED", }); // Clear the collapse setting. slot.setConfig({ collapseDiv: null, });
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); // Collapse the div for this slot if no ad is returned. slot.setConfig({ collapseDiv: "ON_NO_FILL", }); // Collapse the div for this slot by default, and expand only // if an ad is returned. slot.setConfig({ collapseDiv: "BEFORE_FETCH", }); // Do not collapse the div for this slot. slot.setConfig({ collapseDiv: "DISABLED", }); // Clear the collapse setting. slot.setConfig({ collapseDiv: null, });
Optional continueButton
continueButton?: ContinueButtonConfigتسمح هذه الإعدادات بتخصيص مظهر وسلوك تفاعلات الخروج ومواصلة القراءة المرتبطة بأشكال "الإعلانات أثناء إيقاف الفيديو مؤقتًا".
أي إعدادات لزر المتابعة لم يتم تحديدها عند استدعاء
setConfig() ستستخدم قيمة تلقائية تحددها Google.لإيقاف أو محو جميع إعدادات زر المتابعة، يمكنك تمرير
null.- مثال
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Configure continue button settings. slot.setConfig({ continueButton: { font: "Arial", fontColor: "white", backgroundColor: "blue", targetId: "target-div-id", freqCapIntervalMinutes: 20, }, }); // Clear continue button settings. slot.setConfig({ continueButton: null });
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); // Configure continue button settings. slot.setConfig({ continueButton: { font: "Arial", fontColor: "white", backgroundColor: "blue", targetId: "target-div-id", freqCapIntervalMinutes: 20, }, }); // Clear continue button settings. slot.setConfig({ continueButton: null });
Optional إعلان بيني
interstitial?: InterstitialConfigOptional safeFrame
safeFrame?: SafeFrameConfigلن تنطبق القيم التي تم ضبطها من خلال هذا الإعداد إلا على الخانة الإعلانية، وستلغي القيم التي تم ضبطها من خلال PageSettingsConfig.safeFrame.
- مثال
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Force SafeFrame for the slot. slot.setConfig({ safeFrame: { forceSafeFrame: true }, }); // Configure SafeFrame to allow overlay expansion for the slot. slot.setConfig({ safeFrame: { allowOverlayExpansion: true }, }); // Clear forceSafeFrame setting for the slot. slot.setConfig({ safeFrame: { forceSafeFrame: null }, }); // Clear all SafeFrame settings for the slot. slot.setConfig({ safeFrame: null });
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); // Force SafeFrame for the slot. slot.setConfig({ safeFrame: { forceSafeFrame: true }, }); // Configure SafeFrame to allow overlay expansion for the slot. slot.setConfig({ safeFrame: { allowOverlayExpansion: true }, }); // Clear forceSafeFrame setting for the slot. slot.setConfig({ safeFrame: { forceSafeFrame: null }, }); // Clear all SafeFrame settings for the slot. slot.setConfig({ safeFrame: null });
Optional الاستهداف
targeting?: Record<string, string | string[]>لن ينطبق الاستهداف الذي تم ضبطه من خلال هذا الإعداد إلا على الخانة الإعلانية. يمكن استدعاء هذا الإعداد عدة مرات لتحديد قيم مفاتيح استهداف متعددة أو استبدال القيم الحالية. يتم تحديد مفاتيح الاستهداف في حسابك على "إدارة إعلانات Google".
- مثال
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Setting a single targeting key-value. slot.setConfig({ targeting: { interests: "sports" } }); // Setting multiple values for a single targeting key. slot.setConfig({ targeting: { interests: ["sports", "music"] } }); // Setting multiple targeting key-values at once. slot.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } }); // Clearing a single targeting key. slot.setConfig({ targeting: { interests: null } }); // Clear all targeting keys. slot.setConfig({ targeting: null });
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); // Setting a single targeting key-value. slot.setConfig({ targeting: { interests: "sports" } }); // Setting multiple values for a single targeting key. slot.setConfig({ targeting: { interests: ["sports", "music"] } }); // Setting multiple targeting key-values at once. slot.setConfig({ targeting: { interests: ["sports", "music"], color: "red" } }); // Clearing a single targeting key. slot.setConfig({ targeting: { interests: null } }); // Clear all targeting keys. slot.setConfig({ targeting: null });
- انظر أيضًا
googletag.config.TaxonomyData
| الخصائص | |
|---|---|
values | قائمة بقيم التصنيف |
الخصائص
values
values: readonly string[]googletag.config.VideoAdsConfig
| الخصائص | |
|---|---|
enable | ما إذا كانت إعلانات الفيديو ستظهر على الصفحة |
video | رقم تعريف مصدر محتوى الفيديو |
video | معرّف محتوى الفيديو |
- انظر أيضًا
الخصائص
enableVideoAds
enableVideoAds: booleanعند ضبطها على
true، يتم تفعيل قيود استبعاد المحتوى على "الإعلانات الصورية" و"إعلانات الفيديو".إذا كان محتوى الفيديو معروفًا، اضبط videoContentId وvideoCmsId على القيم المقدَّمة لخدمة تحليل المحتوى في "إدارة إعلانات Google" لاستخدام ميزة استبعاد المحتوى في "الإعلانات الصورية".
Optional videoCmsId
videoCmsId?: stringهذه قيمة فريدة تحدّدها خدمة تحليل المحتوى في "إدارة إعلانات Google" لتحديد مصدر محتوى الفيديو الذي يحدّده videoContentId.
- انظر أيضًا
Optional videoContentId
videoContentId?: stringهذه قيمة فريدة تحدّد فيديو معيّنًا من مصدر المحتوى الذي يحدّده videoCmsId. يتم تعيين هذه القيمة من خلال نظام إدارة المحتوى الذي يستضيف محتوى الفيديو.
- انظر أيضًا
googletag.enums
| التعدادات | |
|---|---|
Out | أشكال الإعلانات خارج الصفحة التي تتيحها علامة GPT |
Tag | إعدادات معالجة الطلبات حسب العمر التي تتيحها علامة GPT |
Traffic | مصادر الزيارات المتوافقة مع علامة GPT |
التعدادات
OutOfPageFormat
OutOfPageFormat- انظر أيضًا
| أعضاء التعداد | |
|---|---|
AD_ | شكل الإعلان "روابط وعناصر إعلانية مرتكزة على نية المستخدم" |
BOTTOM_ | شكل الإعلان الثابت الذي تظهر فيه الخانة في أسفل إطار العرض |
GAME_ | شكل "الإعلانات البينية اليدوية في الألعاب" ملاحظة: "الإعلانات البينية اليدوية في الألعاب" هو شكل متاح بشكل محدود. |
INTERSTITIAL | تنسيق تصميم الإعلان البيني على الموقع الإلكتروني |
LEFT_ | شكل الإعلان على جانب الصفحة الأيسر |
REWARDED | شكل "الإعلانات مقابل مكافأة" |
RIGHT_ | تنسيق الإعلان على جانب الصفحة |
TOP_ | شكل ثابت يلتصق فيه موضع الإعلان بالجزء العلوي من إطار العرض |
TagForAgeTreatment
TagForAgeTreatment- انظر أيضًا
TrafficSource
TrafficSource- انظر أيضًا
googletag.events
| واجهات | |
|---|---|
Event | الواجهة الأساسية لجميع أحداث GPT |
Event | هذا نوع زائف يربط اسم حدث بنوع عنصر الحدث المقابل له في Service.addEventListener وService.removeEventListener. |
Game | يتم تنشيط هذا الحدث عندما يغلق المستخدم خانة إعلانية بينية يدوية في اللعبة. |
Game | يتم تنشيط هذا الحدث عندما تكون خانة الإعلان البيني اليدوي في اللعبة جاهزة للعرض على المستخدم. |
Impression | يتم بدء هذا الحدث عندما يصبح ظهور الإعلان قابلاً للعرض، وفقًا لمعايير "العرض النشط". |
Rewarded | يتم تنشيط هذا الحدث عندما يغلق المستخدم خانة "إعلان مقابل مكافأة". |
Rewarded | يتم بدء هذا الحدث عند منح مكافأة مقابل مشاهدة إعلان مقابل مكافأة. |
Rewarded | يتم بدء هذا الحدث عندما يكون الإعلان مقابل مكافأة جاهزًا للعرض. |
Rewarded | يتم تنشيط هذا الحدث عند انتهاء تشغيل "إعلان فيديو مقابل مكافأة". |
Slot | يتم تنشيط هذا الحدث عندما ينشّط إطار iframe الخاص بتصميم الإعلان حدث التحميل. |
Slot | يتم تنشيط هذا الحدث عند إدخال رمز تصميم الإعلان في خانة إعلانية. |
Slot | يتم تنشيط هذا الحدث عند طلب إعلان لموضع إعلان معيّن. |
Slot | يتم تنشيط هذا الحدث عند تلقّي استجابة إعلان لخانة معيّنة. |
Slot | يتم تنشيط هذا الحدث عندما تتغيّر النسبة المئوية لمساحة الخانة الإعلانية التي تظهر على الشاشة. |
googletag.events.Event
| الخصائص | |
|---|---|
service | اسم الخدمة التي أدّت إلى بدء الحدث |
slot | الخانة التي أدّت إلى بدء الحدث |
- انظر أيضًا
الخصائص
serviceName
serviceName: stringslot
slot: Slotgoogletag.events.EventTypeMap
| الخصائص | |
|---|---|
game | اسم مستعار لـ events.GameManualInterstitialSlotClosedEvent. |
game | اسم مستعار لـ events.GameManualInterstitialSlotReadyEvent. |
impression | اسم مستعار لـ events.ImpressionViewableEvent. |
rewarded | اسم بديل لـ events.RewardedSlotClosedEvent. |
rewarded | اسم مستعار لـ events.RewardedSlotGrantedEvent. |
rewarded | اسم مستعار لـ events.RewardedSlotReadyEvent. |
rewarded | اسم مستعار لـ events.RewardedSlotVideoCompletedEvent. |
slot | اسم مستعار لـ events.SlotOnloadEvent. |
slot | اسم مستعار لـ events.SlotRenderEndedEvent. |
slot | اسم مستعار لـ events.SlotRequestedEvent. |
slot | Alias for events.SlotResponseReceived. |
slot | اسم مستعار لـ events.SlotVisibilityChangedEvent. |
الخصائص
gameManualInterstitialSlotClosed
gameManualInterstitialSlotClosed: GameManualInterstitialSlotClosedEventgameManualInterstitialSlotReady
gameManualInterstitialSlotReady: GameManualInterstitialSlotReadyEventimpressionViewable
impressionViewable: ImpressionViewableEventrewardedSlotClosed
rewardedSlotClosed: RewardedSlotClosedEventrewardedSlotGranted
rewardedSlotGranted: RewardedSlotGrantedEventrewardedSlotReady
rewardedSlotReady: RewardedSlotReadyEventrewardedSlotVideoCompleted
rewardedSlotVideoCompleted: RewardedSlotVideoCompletedEventslotOnload
slotOnload: SlotOnloadEventslotRenderEnded
slotRenderEnded: SlotRenderEndedEventslotRequested
slotRequested: SlotRequestedEventslotResponseReceived
slotResponseReceived: SlotResponseReceivedslotVisibilityChanged
slotVisibilityChanged: SlotVisibilityChangedEventgoogletag.events.GameManualInterstitialSlotClosedEvent
Eventملاحظة: "الإعلان البيني اليدوي في الألعاب" هو شكل إعلان متاح بشكل محدود.
| الخصائص | |
|---|---|
service | اسم الخدمة التي أدّت إلى بدء الحدث مُكتسَبة من الموقع |
slot | الخانة التي أدّت إلى بدء الحدث مُكتسَبة من الموقع |
- مثال
JavaScript
// This listener is called when a game manual interstitial slot is closed. const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL, ); // Slot returns null if the page or device does not support game manual interstitial ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); googletag.pubads().addEventListener("gameManualInterstitialSlotClosed", (event) => { const slot = event.slot; console.log("Game manual interstital slot", slot.getSlotElementId(), "is closed."); if (slot === targetSlot) { // Slot specific logic. } }); }
TypeScript
// This listener is called when a game manual interstitial slot is closed. const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL, ); // Slot returns null if the page or device does not support game manual interstitial ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); googletag.pubads().addEventListener("gameManualInterstitialSlotClosed", (event) => { const slot = event.slot; console.log("Game manual interstital slot", slot.getSlotElementId(), "is closed."); if (slot === targetSlot) { // Slot specific logic. } }); }
googletag.events.GameManualInterstitialSlotReadyEvent
Eventملاحظة: "الإعلان البيني اليدوي" في اللعبة هو شكل إعلان محدود الوصول.
| الخصائص | |
|---|---|
service | اسم الخدمة التي أدّت إلى بدء الحدث مُكتسَبة من الموقع |
slot | الخانة التي أدّت إلى بدء الحدث مُكتسَبة من الموقع |
| الطُرق | |
|---|---|
make | يعرض الإعلان البيني اليدوي للعبة للمستخدم. |
- مثال
JavaScript
// This listener is called when a game manual interstitial slot is ready to // be displayed. const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL, ); // Slot returns null if the page or device does not support game manual interstitial ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); googletag.pubads().addEventListener("gameManualInterstitialSlotReady", (event) => { const slot = event.slot; console.log( "Game manual interstital slot", slot.getSlotElementId(), "is ready to be displayed.", ); // Replace with custom logic. const displayGmiAd = true; if (displayGmiAd) { event.makeGameManualInterstitialVisible(); } if (slot === targetSlot) { // Slot specific logic. } }); }
TypeScript
// This listener is called when a game manual interstitial slot is ready to // be displayed. const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL, ); // Slot returns null if the page or device does not support game manual interstitial ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); googletag.pubads().addEventListener("gameManualInterstitialSlotReady", (event) => { const slot = event.slot; console.log( "Game manual interstital slot", slot.getSlotElementId(), "is ready to be displayed.", ); // Replace with custom logic. const displayGmiAd = true; if (displayGmiAd) { event.makeGameManualInterstitialVisible(); } if (slot === targetSlot) { // Slot specific logic. } }); }
الطُرق
makeGameManualInterstitialVisible
makeGameManualInterstitialVisible(): boolean| المرتجعات | |
|---|---|
boolean | |
googletag.events.ImpressionViewableEvent
Event| الخصائص | |
|---|---|
service | اسم الخدمة التي أدّت إلى بدء الحدث مُكتسَبة من الموقع |
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. } });
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
Event| الخصائص | |
|---|---|
service | اسم الخدمة التي أدّت إلى بدء الحدث مُكتسَبة من الموقع |
slot | الخانة التي أدّت إلى بدء الحدث مُكتسَبة من الموقع |
- مثال
JavaScript
const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called when the user closes a rewarded ad slot. googletag.pubads().addEventListener("rewardedSlotClosed", (event) => { const slot = event.slot; console.log("Rewarded ad slot", slot.getSlotElementId(), "has been closed."); if (slot === targetSlot) { // Slot specific logic. } }); }
TypeScript
const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called when the user closes a rewarded ad slot. googletag.pubads().addEventListener("rewardedSlotClosed", (event) => { const slot = event.slot; console.log("Rewarded ad slot", slot.getSlotElementId(), "has been closed."); if (slot === targetSlot) { // Slot specific logic. } }); }
googletag.events.RewardedSlotGrantedEvent
Event| الخصائص | |
|---|---|
payload | عنصر يحتوي على معلومات عن المكافأة التي تم منحها. |
service | اسم الخدمة التي أدّت إلى بدء الحدث مُكتسَبة من الموقع |
slot | الخانة التي أدّت إلى بدء الحدث مُكتسَبة من الموقع |
- مثال
JavaScript
const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called whenever a reward is granted for a // rewarded ad. googletag.pubads().addEventListener("rewardedSlotGranted", (event) => { const slot = event.slot; console.group("Reward granted for slot", slot.getSlotElementId(), "."); // Log details of the reward. console.log("Reward type:", event.payload?.type); console.log("Reward amount:", event.payload?.amount); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } }); }
TypeScript
const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called whenever a reward is granted for a // rewarded ad. googletag.pubads().addEventListener("rewardedSlotGranted", (event) => { const slot = event.slot; console.group("Reward granted for slot", slot.getSlotElementId(), "."); // Log details of the reward. console.log("Reward type:", event.payload?.type); console.log("Reward amount:", event.payload?.amount); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } }); }
الخصائص
payload
payload: RewardedPayloadgoogletag.events.RewardedSlotReadyEvent
Event| الخصائص | |
|---|---|
service | اسم الخدمة التي أدّت إلى بدء الحدث مُكتسَبة من الموقع |
slot | الخانة التي أدّت إلى بدء الحدث مُكتسَبة من الموقع |
| الطُرق | |
|---|---|
make | يعرض الإعلان مقابل مكافأة. |
- مثال
JavaScript
// This listener is called when a rewarded ad slot becomes ready to be // displayed. const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called whenever a reward is granted for a // rewarded ad. googletag.pubads().addEventListener("rewardedSlotReady", (event) => { const slot = event.slot; console.log("Rewarded ad slot", slot.getSlotElementId(), "is ready to be displayed."); // Replace with custom logic. const userHasConsented = true; if (userHasConsented) { event.makeRewardedVisible(); } if (slot === targetSlot) { // Slot specific logic. } }); }
TypeScript
// This listener is called when a rewarded ad slot becomes ready to be // displayed. const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called whenever a reward is granted for a // rewarded ad. googletag.pubads().addEventListener("rewardedSlotReady", (event) => { const slot = event.slot; console.log("Rewarded ad slot", slot.getSlotElementId(), "is ready to be displayed."); // Replace with custom logic. const userHasConsented = true; if (userHasConsented) { event.makeRewardedVisible(); } if (slot === targetSlot) { // Slot specific logic. } }); }
الطُرق
makeRewardedVisible
makeRewardedVisible(): boolean| المرتجعات | |
|---|---|
boolean | ما إذا تم عرض "الإعلان مقابل مكافأة" بنجاح |
googletag.events.RewardedSlotVideoCompletedEvent
Event| الخصائص | |
|---|---|
service | اسم الخدمة التي أدّت إلى بدء الحدث مُكتسَبة من الموقع |
slot | الخانة التي أدّت إلى بدء الحدث مُكتسَبة من الموقع |
- مثال
JavaScript
const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called when the video in a rewarded ad slot has // finished playing. googletag.pubads().addEventListener("rewardedSlotVideoCompleted", (event) => { const slot = event.slot; console.log("Video in rewarded ad slot", slot.getSlotElementId(), "has finished playing."); if (slot === targetSlot) { // Slot specific logic. } }); }
TypeScript
const targetSlot = googletag.defineOutOfPageSlot( "/1234567/example", googletag.enums.OutOfPageFormat.REWARDED, ); // Slot returns null if the page or device does not support rewarded ads. if (targetSlot) { targetSlot.addService(googletag.pubads()); // This listener is called when the video in a rewarded ad slot has // finished playing. googletag.pubads().addEventListener("rewardedSlotVideoCompleted", (event) => { const slot = event.slot; console.log("Video in rewarded ad slot", slot.getSlotElementId(), "has finished playing."); if (slot === targetSlot) { // Slot specific logic. } }); }
googletag.events.SlotOnloadEvent
EventSlotOnloadEvent.| الخصائص | |
|---|---|
service | اسم الخدمة التي أدّت إلى بدء الحدث مُكتسَبة من الموقع |
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. } });
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
Event| الخصائص | |
|---|---|
advertiser | الرقم التعريفي للمعلن الذي يعرض الإعلان |
campaign | رقم تعريف الحملة للإعلان المعروض |
company | معرّفات الشركات التي قدّمت عروض أسعار لإعلان إعادة التعبئة المعروض |
creative | رقم تعريف تصميم الإعلان المحجوز الذي تم عرضه |
creative | رقم تعريف نموذج تصميم الإعلان المحجوز المعروض |
is | ما إذا كان الإعلان من نوع "الاحتياطي الإعلاني" |
is | ما إذا تم عرض إعلان في الخانة |
label | متوقّف نهائيًا. |
line | معرّف السلعة للإعلان المحجوز الذي تم عرضه |
response | معرّف الاستجابة هو معرّف فريد لاستجابة الإعلان. |
service | اسم الخدمة التي أدّت إلى بدء الحدث مُكتسَبة من الموقع |
size | تشير إلى حجم البكسل لتصميم الإعلان المعروض. |
slot | الخانة التي أدّت إلى بدء الحدث مُكتسَبة من الموقع |
slot | ما إذا تم تغيير محتوى الخانة باستخدام الإعلان المعروض |
source | المعرّف الإبداعي للإعلان المحجوز أو الإعلان الاحتياطي المعروض. |
source | معرّف السلعة للإعلان المحجوز أو إعلان إعادة التعبئة المعروضَين |
yield | أرقام تعريف مجموعات الأرباح للإعلان الاحتياطي المعروض |
- مثال
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("Line Item ID:", event.lineItemId); console.log("Size:", event.size); console.log("Slot content changed?", event.slotContentChanged); console.log("Source Agnostic Creative ID:", event.sourceAgnosticCreativeId); console.log("Source Agnostic Line Item ID:", event.sourceAgnosticLineItemId); console.log("Yield Group IDs:", event.yieldGroupIds); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } });
TypeScript
// This listener is called when a slot has finished rendering. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotRenderEnded", (event) => { const slot = event.slot; console.group("Slot", slot.getSlotElementId(), "finished rendering."); // Log details of the rendered ad. console.log("Advertiser ID:", event.advertiserId); console.log("Campaign ID:", event.campaignId); console.log("Company IDs:", event.companyIds); console.log("Creative ID:", event.creativeId); console.log("Creative Template ID:", event.creativeTemplateId); console.log("Is backfill?:", event.isBackfill); console.log("Is empty?:", event.isEmpty); console.log("Line Item ID:", event.lineItemId); console.log("Size:", event.size); console.log("Slot content changed?", event.slotContentChanged); console.log("Source Agnostic Creative ID:", event.sourceAgnosticCreativeId); console.log("Source Agnostic Line Item ID:", event.sourceAgnosticLineItemId); console.log("Yield Group IDs:", event.yieldGroupIds); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } });
- انظر أيضًا
الخصائص
advertiserId
advertiserId: numbernull للخانة الإعلانية الفارغة وإعلانات الملء الاحتياطي وتصاميم الإعلانات التي تعرضها خدمات أخرى غير PubAdsService.campaignId
campaignId: numbernull للخانة الإعلانية الفارغة وإعلانات الملء الاحتياطي وتصاميم الإعلانات التي تعرضها خدمات أخرى غير PubAdsService.companyIds
companyIds: number[]null للخانَات الفارغة والإعلانات المحجوزة وتصاميم الإعلانات التي تعرضها خدمات أخرى غير PubAdsService.creativeId
creativeId: numbernull للخانة الإعلانية الفارغة وإعلانات الملء الاحتياطي وتصاميم الإعلانات التي تعرضها خدمات أخرى غير PubAdsService.creativeTemplateId
creativeTemplateId: numbernull للخانة الإعلانية الفارغة وإعلانات الملء الاحتياطي وتصاميم الإعلانات التي تعرضها خدمات أخرى غير PubAdsService.isBackfill
isBackfill: booleantrue إذا كان الإعلان من نوع "إعلان احتياطي"، وfalse في الحالات الأخرى.isEmpty
isEmpty: booleantrue في حال عدم عرض أي إعلان، وfalse في الحالات الأخرى.labelIds
labelIds: number[]lineItemId
lineItemId: numbernull للخانة الإعلانية الفارغة وإعلانات الملء الاحتياطي وتصاميم الإعلانات التي تعرضها خدمات أخرى غير PubAdsService.responseIdentifier
responseIdentifier: stringsize
size: string | number[][728, 90] القيمة هي null للخانة الإعلانية الفارغة.slotContentChanged
slotContentChanged: booleantrue إذا تم تغيير المحتوى، وfalse في الحالات الأخرى.sourceAgnosticCreativeId
sourceAgnosticCreativeId: numbernull إذا لم يكن الإعلان محجوزًا أو لم يكن مخصّصًا لملء المساحات الإعلانية المتاحة في البنود الإعلانية، أو إذا تم عرض تصميم الإعلان من خلال خدمات أخرى غير PubAdsService.sourceAgnosticLineItemId
sourceAgnosticLineItemId: numbernull إذا لم يكن الإعلان محجوزًا أو لم يكن مخصّصًا لملء المساحات الإعلانية المتاحة في البنود الإعلانية، أو إذا تم عرض تصميم الإعلان من خلال خدمات أخرى غير PubAdsService.yieldGroupIds
yieldGroupIds: number[]null للخانَات الفارغة والإعلانات المحجوزة وتصاميم الإعلانات التي تعرضها خدمات أخرى غير PubAdsService.googletag.events.SlotRequestedEvent
Event| الخصائص | |
|---|---|
service | اسم الخدمة التي أدّت إلى بدء الحدث مُكتسَبة من الموقع |
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. } });
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
Event| الخصائص | |
|---|---|
service | اسم الخدمة التي أدّت إلى بدء الحدث مُكتسَبة من الموقع |
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. } });
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
Event| الخصائص | |
|---|---|
in | النسبة المئوية لمساحة الإعلان المرئية |
service | اسم الخدمة التي أدّت إلى بدء الحدث مُكتسَبة من الموقع |
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. } });
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: numbergoogletag.secureSignals
| واجهات | |
|---|---|
Bidder | تعرض هذه الدالة إشارة آمنة لمقدّم عرض سعر معيّن. |
Publisher | تعرض هذه الدالة إشارة آمنة لناشر محدّد. |
Secure | واجهة لإدارة الإشارات الآمنة |
| الأسماء المستعارة للأنواع | |
|---|---|
Secure | واجهة لعرض إشارة آمنة لمقدّم عرض سعر أو مقدّم خدمة معيّن. |
الأسماء المستعارة للأنواع
SecureSignalProvider
SecureSignalProvider: BidderSignalProvider | PublisherSignalProviderid أو networkCode، ولكن ليس كلتيهما.googletag.secureSignals.BidderSignalProvider
يتكوّن مزوّد الإشارات الآمنة لمقدّم عرض السعر من جزأين:
- دالة تجميعية تعرض
Promiseيتم تحليله إلى إشارة آمنة -
idيحدّد مقدّم عرض السعر المرتبط بالإشارة.
| الخصائص | |
|---|---|
collector | دالة تعرض Promise يتم تحليله إلى إشارة آمنة. |
id | معرّف فريد لجامع البيانات المرتبط بهذه الإشارة الآمنة، كما هو مسجَّل في "إدارة إعلانات Google". |
- مثال
JavaScript
// id is provided googletag.secureSignalProviders.push({ id: "collector123", collectorFunction: () => { // ...custom signal generation logic... return Promise.resolve("signal"); }, });
TypeScript
// id is provided googletag.secureSignalProviders!.push({ id: "collector123", collectorFunction: () => { // ...custom signal generation logic... return Promise.resolve("signal"); }, });
الخصائص
collectorFunction
collectorFunction: (() => Promise<string>)Promise يتم تحليله إلى إشارة آمنة.id
id: stringgoogletag.secureSignals.PublisherSignalProvider
يتكوّن مزوّد إشارات الناشر من جزأين:
- دالة تجميعية تعرض
Promiseيتم تحليله إلى إشارة آمنة -
networkCodeيحدّد الناشر المرتبط بالإشارة
| الخصائص | |
|---|---|
collector | دالة تعرض Promise يتم تحليله إلى إشارة آمنة. |
network | رمز الشبكة (كما يظهر في مسار الوحدة الإعلانية) للناشر المرتبط بهذه الإشارة الآمنة. |
- مثال
JavaScript
// networkCode is provided googletag.secureSignalProviders.push({ networkCode: "123456", collectorFunction: () => { // ...custom signal generation logic... return Promise.resolve("signal"); }, });
TypeScript
// networkCode is provided googletag.secureSignalProviders!.push({ networkCode: "123456", collectorFunction: () => { // ...custom signal generation logic... return Promise.resolve("signal"); }, });
الخصائص
collectorFunction
collectorFunction: (() => Promise<string>)Promise يتم تحليله إلى إشارة آمنة.networkCode
networkCode: stringgoogletag.secureSignals.SecureSignalProvidersArray
| الطُرق | |
|---|---|
clear | يمحو جميع الإشارات لجميع أدوات التجميع من ذاكرة التخزين المؤقت. |
push | تضيف هذه الطريقة secureSignals.SecureSignalProvider جديدًا إلى مصفوفة مزوّدي الإشارات وتبدأ عملية إنشاء الإشارات. |
الطُرق
clearAllCache
clearAllCache(): voidقد يؤدي استدعاء هذه الطريقة إلى تقليل احتمالية تضمين الإشارات في طلبات عرض الإعلانات لمشاهدات الصفحة الحالية وربما اللاحقة. لهذا السبب، يجب استدعاؤها فقط عند حدوث تغييرات مهمة في الحالة، مثل الأحداث التي تشير إلى مستخدم جديد (تسجيل الدخول، وتسجيل الخروج، والاشتراك، وما إلى ذلك).
push
push(provider: SecureSignalProvider): void| المعلمات | |
|---|---|
provider: SecureSignalProvider | عنصر secureSignals.SecureSignalProvider المطلوب إضافته إلى الصفيفة. |