การอ้างอิงนี้ใช้สัญลักษณ์ TypeScript เพื่ออธิบายประเภท ตารางต่อไปนี้จะให้คำอธิบายสั้นๆ ตามตัวอย่าง
ประเภทนิพจน์ | |
---|---|
string |
ประเภทสตริงพื้นฐาน |
string[] |
ประเภทอาร์เรย์ที่ค่าต้องเป็นสตริงเท่านั้น |
number | string |
ประเภทยูเนียนซึ่งค่าอาจเป็นตัวเลขหรือสตริงก็ได้ |
Array<number | string> |
ประเภทอาร์เรย์ที่ค่าเป็นประเภทที่ซับซ้อน (สหภาพ) |
[number, string] |
ประเภทของ Tuple โดยที่ค่าเป็นอาร์เรย์ 2 องค์ประกอบที่ต้องประกอบด้วยตัวเลขและสตริงในลำดับดังกล่าว |
Slot |
ประเภทออบเจ็กต์ที่ค่าเป็นอินสแตนซ์ของ googletag.Slot |
() => void |
ประเภทฟังก์ชันที่ไม่มีอาร์กิวเมนต์ที่กำหนดไว้ และไม่มีผลลัพธ์ |
ดูข้อมูลเพิ่มเติมเกี่ยวกับประเภทและนิพจน์ประเภทที่รองรับได้ที่ คู่มือ TypeScript
พิมพ์คำอธิบายประกอบ
เครื่องหมายโคลอนหลังตัวแปร ชื่อพารามิเตอร์ ชื่อพร็อพเพอร์ตี้ หรือลายเซ็นฟังก์ชันหมายถึงคำอธิบายประกอบประเภท คำอธิบายประกอบประเภทอธิบายประเภทที่องค์ประกอบทางด้านซ้ายของโคลอนสามารถยอมรับหรือแสดงผลได้ ตารางต่อไปนี้แสดงตัวอย่างประเภทคำอธิบายประกอบที่คุณอาจเห็นในข้อมูลอ้างอิงนี้
พิมพ์คำอธิบายประกอบ | |
---|---|
param: string |
ระบุว่า param ยอมรับหรือแสดงผลค่าสตริง ไวยากรณ์นี้ใช้กับตัวแปร พารามิเตอร์ พร็อพเพอร์ตี้ และประเภทผลลัพธ์
|
param?: number | string |
ระบุว่า param ไม่บังคับ แต่ยอมรับตัวเลขหรือสตริงเมื่อระบุ ไวยากรณ์นี้ใช้สำหรับพารามิเตอร์และพร็อพเพอร์ตี้
|
...params: Array<() => void> |
ระบุว่า params เป็น
พารามิเตอร์ส่วนที่เหลือ
ที่ยอมรับฟังก์ชัน พารามิเตอร์ REST ยอมรับจำนวนค่าของประเภทที่ระบุโดยไม่จำกัด
|
คำนิยามประเภท
ประเภท | |
---|---|
|
SingleSize | MultiSize
|
การกำหนดค่าขนาดที่ถูกต้องสำหรับช่องโฆษณา ซึ่งอาจเป็นขนาดเดียวหรือหลายขนาดก็ได้ |
|
|
SingleSize[]
|
รายการขนาดที่ใช้ได้เพียงขนาดเดียว |
|
|
"fluid" | ["fluid"]
|
ขนาดที่มีชื่อซึ่งช่องโฆษณาจะมีได้ ในกรณีส่วนใหญ่ ขนาดจะเป็นสี่เหลี่ยมผืนผ้าขนาดคงที่ แต่ก็มีบางกรณีที่เราต้องการข้อกำหนดเฉพาะสำหรับขนาดประเภทอื่นๆ ขนาดที่มีชื่อที่ถูกต้องมีดังต่อไปนี้
|
|
|
SingleSizeArray | NamedSize
|
ขนาดที่ใช้ได้ช่องเดียว |
|
|
[number, number]
|
อาร์เรย์ของตัวเลข 2 จำนวนที่แสดง [ความกว้าง, ความสูง] |
|
|
[SingleSizeArray, GeneralSize]
|
การแมปขนาดวิวพอร์ตกับขนาดโฆษณา ใช้สำหรับโฆษณาที่ปรับเปลี่ยนตามอุปกรณ์ |
|
|
SizeMapping[]
|
รายการการแมปขนาด |
|
|
"unhideWindow" | "navBar"
|
การเรียกโฆษณาคั่นระหว่างหน้าที่รองรับ |
|
|
"disablePersonalization"
|
การคุ้มครองความเป็นส่วนตัวของผู้เผยแพร่โฆษณาที่รองรับ |
|
|
"IAB_AUDIENCE_1_1" | "IAB_CONTENT_2_2"
|
การจัดหมวดหมู่ที่รองรับสําหรับสัญญาณที่ได้จากผู้เผยแพร่โฆษณา (PPS) |
|
|
BidderSignalProvider | PublisherSignalProvider
|
อินเทอร์เฟซสำหรับการส่งคืนสัญญาณที่ปลอดภัยสำหรับผู้เสนอราคาหรือผู้ให้บริการที่เฉพาะเจาะจง ต้องระบุ |
ประเภทการแจกแจง
Enum | |
---|---|
googletag.enums.OutOfPageFormat
|
รูปแบบโฆษณาที่ไม่อยู่ในขอบเขตหน้าซึ่ง GPT รองรับ
|
googletag.enums.TrafficSource
|
แหล่งที่มาของการเข้าชมที่ GPT รองรับ
|
googletag.enums.OutOfPageFormat
-
รูปแบบโฆษณาที่ไม่อยู่ในขอบเขตหน้าซึ่ง GPT รองรับ
-
- ดูเพิ่มเติม
googletag.enums.TrafficSource
-
แหล่งที่มาของการเข้าชมที่ GPT รองรับ
-
- ดูเพิ่มเติม
-
ค่า ORGANIC
การป้อน URL โดยตรง การค้นหาเว็บไซต์ หรือการดาวน์โหลดแอปPURCHASED
การเข้าชมที่เปลี่ยนเส้นทางจากพร็อพเพอร์ตี้อื่นนอกเหนือจากที่เป็นเจ้าของ (ได้มาหรือกิจกรรมที่จูงใจ)
googletag
เนมสเปซสากลที่แท็กผู้เผยแพร่โฆษณาผ่าน Google ใช้สำหรับ API ของตน
สรุปตัวแปร | |
---|---|
apiReady
|
การแจ้งที่ระบุว่า GPT API โหลดและพร้อมเรียกใช้แล้ว
|
cmd
|
ใช้อ้างอิงคิวคำสั่งส่วนกลางเพื่อเรียกการเรียกใช้ที่เกี่ยวข้องกับ GPT แบบไม่พร้อมกัน
|
pubadsReady
|
การแจ้งที่ระบุว่า
PubAdsService เปิดใช้อยู่ โหลดแล้ว และทำงานได้อย่างสมบูรณ์
|
secureSignalProviders
|
การอ้างอิงอาร์เรย์ผู้ให้บริการสัญญาณที่ปลอดภัย
|
สรุปฟังก์ชัน | |
---|---|
companionAds
|
แสดงผลการอ้างอิงไปยัง
CompanionAdsService
|
defineOutOfPageSlot
|
สร้างช่องโฆษณาที่ไม่อยู่ในขอบเขตหน้าด้วยเส้นทางหน่วยโฆษณาที่ระบุ
|
defineSlot
|
สร้างช่องโฆษณาโดยมีเส้นทางและขนาดของหน่วยโฆษณาตามที่ระบุ และเชื่อมโยงกับรหัสของส่วน div บนหน้าเว็บที่จะใส่โฆษณา
|
destroySlots
|
ทำลายช่องโฆษณาที่ระบุ นำออบเจ็กต์และการอ้างอิงที่เกี่ยวข้องทั้งหมดของช่องเหล่านั้นออกจาก GPT
|
disablePublisherConsole
|
ปิดใช้คอนโซลผู้เผยแพร่โฆษณาของ Google
|
display
|
สั่งให้บริการของสล็อตแสดงผลสล็อต
|
enableServices
|
เปิดใช้บริการ GPT ทั้งหมดที่ได้กำหนดไว้สำหรับช่องโฆษณาในหน้าเว็บ
|
getVersion
|
แสดงผล GPT เวอร์ชันปัจจุบัน
|
openConsole
|
เปิดคอนโซลผู้เผยแพร่โฆษณาของ Google
|
pubads
|
แสดงผลการอ้างอิงไปยัง
PubAdsService
|
setAdIframeTitle
|
ตั้งชื่อสำหรับ iframe ของคอนเทนเนอร์โฆษณาทั้งหมดที่สร้างโดย
PubAdsService ตั้งแต่จุดนี้เป็นต้นไป
|
setConfig
|
ตั้งค่าตัวเลือกการกำหนดค่าทั่วไปสำหรับหน้า
|
sizeMapping
|
สร้าง
SizeMappingBuilder ใหม่
|
googletagapiReady
-
apiReady: boolean | undefined
-
การแจ้งที่ระบุว่า GPT API โหลดและพร้อมเรียกใช้แล้ว พร็อพเพอร์ตี้นี้จะอยู่ใน
undefined
จนกว่า API จะพร้อม
โปรดทราบว่าวิธีที่แนะนำในการจัดการอะซิงโครนัสคือการใช้ googletag.cmd เพื่อจัดคิวโค้ดเรียกกลับเมื่อ GPT พร้อม โค้ดเรียกกลับเหล่านี้ไม่จำเป็นต้องตรวจสอบ googletag.api Ready เนื่องจากมีการรับประกันว่าจะทำงานได้ทันทีเมื่อตั้งค่า API แล้ว -
- ตัวอย่าง
-
JavaScript
if (window.googletag && googletag.apiReady) { // GPT API can be called safely. }
JavaScript (เดิม)
if (window.googletag && googletag.apiReady) { // GPT API can be called safely. }
TypeScript
if (window.googletag && googletag.apiReady) { // GPT API can be called safely. }
googletagcmd
-
cmd: Array<(this: typeof globalThis) => void> | CommandArray
-
ใช้อ้างอิงคิวคำสั่งส่วนกลางเพื่อเรียกเรียกใช้ GPT แบบไม่พร้อมกัน
ตัวแปรgoogletag.cmd
จะกำหนดค่าเริ่มต้นเป็นอาร์เรย์ JavaScript ที่ว่างเปล่าตามไวยากรณ์ของแท็ก GPT ในหน้า และcmd.push
คือเมธอดArray.push
มาตรฐานที่เพิ่มองค์ประกอบต่อท้ายอาร์เรย์ เมื่อโหลด GPT JavaScript จะมีการตรวจดูอาร์เรย์และเรียกใช้ฟังก์ชันทั้งหมดตามลำดับ จากนั้นสคริปต์จะแทนที่cmd
ด้วยออบเจ็กต์CommandArray
ซึ่งมีการกำหนดเมธอด Push เพื่อเรียกใช้อาร์กิวเมนต์ฟังก์ชันที่ส่งมา วิธีนี้จะทำให้ GPT สามารถลดเวลาในการตอบสนองที่รู้สึกได้ โดยการดึง JavaScript แบบไม่พร้อมกันในขณะที่อนุญาตให้เบราว์เซอร์ทำการแสดงหน้าเว็บต่อไป -
- ตัวอย่าง
-
JavaScript
googletag.cmd.push(() => { googletag.defineSlot("/1234567/sports", [160, 600]).addService(googletag.pubads()); });
JavaScript (เดิม)
googletag.cmd.push(function () { googletag.defineSlot("/1234567/sports", [160, 600]).addService(googletag.pubads()); });
TypeScript
googletag.cmd.push(() => { googletag.defineSlot("/1234567/sports", [160, 600])!.addService(googletag.pubads()); });
googletagpubadsReady
-
pubadsReady: boolean | undefined
-
การแจ้งที่ระบุว่า
PubAdsService
เปิดใช้อยู่ โหลดแล้ว และทำงานได้อย่างสมบูรณ์ พร็อพเพอร์ตี้นี้จะทำงานเพียงundefined
จนกว่าจะมีการเรียกใช้enableServices
รวมถึงโหลดและเริ่มต้นPubAdsService
-
googletagsecureSignalProviders
-
secureSignalProviders: SecureSignalProvider[] | SecureSignalProvidersArray | undefined
-
การอ้างอิงอาร์เรย์ผู้ให้บริการสัญญาณที่ปลอดภัย
อาร์เรย์ผู้ให้บริการสัญญาณที่ปลอดภัยจะยอมรับลำดับของฟังก์ชันการสร้างสัญญาณและเรียกใช้ตามลำดับ โดยมีจุดประสงค์เพื่อแทนที่อาร์เรย์มาตรฐานที่ใช้ในการกำหนดคิวฟังก์ชันการสร้างสัญญาณที่จะเรียกใช้เมื่อโหลด GPT แล้ว -
- ตัวอย่าง
-
JavaScript
window.googletag = window.googletag || { cmd: [] }; googletag.secureSignalProviders = googletag.secureSignalProviders || []; googletag.secureSignalProviders.push({ id: "collector123", collectorFunction: () => { return Promise.resolve("signal"); }, });
JavaScript (เดิม)
window.googletag = window.googletag || { cmd: [] }; googletag.secureSignalProviders = googletag.secureSignalProviders || []; googletag.secureSignalProviders.push({ id: "collector123", collectorFunction: function () { return Promise.resolve("signal"); }, });
TypeScript
window.googletag = window.googletag || { cmd: [] }; googletag.secureSignalProviders = googletag.secureSignalProviders || []; googletag.secureSignalProviders.push({ id: "collector123", collectorFunction: () => { return Promise.resolve("signal"); }, });
- ดูเพิ่มเติม
googletagcompanionAds
-
companionAds(): CompanionAdsService
-
แสดงผลการอ้างอิงไปยัง
CompanionAdsService
-
-
การคืนสินค้า CompanionAdsService
บริการโฆษณาที่แสดงร่วมกัน
googletagdefineOutOfPageSlot
-
defineOutOfPageSlot(adUnitPath: string, div?: string | OutOfPageFormat): Slot | null
-
สร้างช่องโฆษณาที่ไม่อยู่ในขอบเขตหน้าด้วยเส้นทางหน่วยโฆษณาที่ระบุ
สำหรับโฆษณาที่ไม่อยู่ในขอบเขตหน้าแบบกำหนดเองdiv
คือรหัสของส่วน div ที่จะมีโฆษณา ดูรายละเอียดเพิ่มเติมได้จากบทความเกี่ยวกับครีเอทีฟโฆษณาที่ไม่อยู่ในขอบเขตหน้า
สำหรับโฆษณาที่ไม่อยู่ในขอบเขตหน้าที่จัดการด้วย GPT นั้นdiv
คือ OutOfPageFormat ที่รองรับ -
- ตัวอย่าง
-
JavaScript
// Define a custom out-of-page ad slot. googletag.defineOutOfPageSlot("/1234567/sports", "div-1"); // Define a GPT managed web interstitial ad slot. googletag.defineOutOfPageSlot("/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL);
JavaScript (เดิม)
// Define a custom out-of-page ad slot. googletag.defineOutOfPageSlot("/1234567/sports", "div-1"); // Define a GPT managed web interstitial ad slot. googletag.defineOutOfPageSlot("/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL);
TypeScript
// Define a custom out-of-page ad slot. googletag.defineOutOfPageSlot("/1234567/sports", "div-1"); // Define a GPT managed web interstitial ad slot. googletag.defineOutOfPageSlot("/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL);
- ดูเพิ่มเติม
-
พารามิเตอร์ adUnitPath: string
เส้นทางหน่วยโฆษณาแบบเต็มที่มีรหัสเครือข่ายและโค้ดหน่วยโฆษณาdiv?: string | OutOfPageFormat
รหัสของ div ที่จะมีหน่วยโฆษณานี้หรือ OutOfPageFormat -
การคืนสินค้า Slot | null
สล็อตที่สร้างใหม่ หรือnull
หากสร้างช่องโฆษณาไม่ได้
googletagdefineSlot
-
defineSlot(adUnitPath: string, size: GeneralSize, div?: string): Slot | null
-
สร้างช่องโฆษณาโดยมีเส้นทางและขนาดของหน่วยโฆษณาตามที่ระบุ และเชื่อมโยงกับรหัสของส่วน div บนหน้าเว็บที่จะใส่โฆษณา
-
- ตัวอย่าง
-
JavaScript
googletag.defineSlot("/1234567/sports", [728, 90], "div-1");
JavaScript (เดิม)
googletag.defineSlot("/1234567/sports", [728, 90], "div-1");
TypeScript
googletag.defineSlot("/1234567/sports", [728, 90], "div-1");
- ดูเพิ่มเติม
-
พารามิเตอร์ adUnitPath: string
เส้นทางหน่วยโฆษณาแบบเต็มที่มีรหัสเครือข่ายและรหัสหน่วยโฆษณาsize: GeneralSize
ความกว้างและความสูงของช่องที่เพิ่ม นี่คือขนาดที่ใช้ในคำขอโฆษณาหากไม่ได้ระบุการแมปขนาดที่ปรับเปลี่ยนตามอุปกรณ์ หรือขนาดของวิวพอร์ตเล็กกว่าขนาดที่เล็กที่สุดที่ให้ไว้ในการแมปdiv?: string
รหัสของ div ที่จะมีหน่วยโฆษณานี้ -
การคืนสินค้า Slot | null
สล็อตที่สร้างใหม่ หรือnull
หากสร้างช่องโฆษณาไม่ได้
googletagdestroySlots
-
destroySlots(slots?: Slot[]): boolean
-
ทำลายช่องโฆษณาที่ระบุ นำออบเจ็กต์และการอ้างอิงที่เกี่ยวข้องทั้งหมดของช่องเหล่านั้นออกจาก GPT API นี้ไม่รองรับช่องรายการส่งคืนและช่องการแสดงร่วม
การเรียก API นี้ในสล็อตจะล้างโฆษณาและนำออบเจ็กต์ของช่องออกจากสถานะภายในที่ GPT ดูแล การเรียกใช้ฟังก์ชันอื่นๆ ในออบเจ็กต์ช่องจะทำให้เกิดลักษณะการทำงานที่ไม่ได้กำหนด โปรดทราบว่าเบราว์เซอร์อาจยังคงเพิ่มหน่วยความจำที่เชื่อมโยงกับช่องนั้นไม่ได้ หากหน้าของผู้เผยแพร่โฆษณาจัดการการอ้างอิงไว้ การเรียก API นี้ทำให้ div ที่เชื่อมโยงกับช่องโฆษณาดังกล่าวใช้ซ้ำได้
ยิ่งไปกว่านั้น การทำลายช่องโฆษณาจะเป็นการนำโฆษณาออกจากการดูหน้าเว็บเป็นระยะเวลานานของ GPT คำขอในอนาคตจึงไม่ได้รับผลกระทบจาก Roadblock หรือการยกเว้นโฆษณาของคู่แข่งที่เกี่ยวข้องกับโฆษณานี้ หากไม่เรียกใช้ฟังก์ชันนี้ก่อนนำ div ของช่องออกจากหน้าจะทำให้เกิดลักษณะการทำงานที่ไม่ได้กำหนด -
- ตัวอย่าง
-
JavaScript
// The calls to construct an ad and display contents. const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1"); googletag.display("div-1"); const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2"); googletag.display("div-2"); // This call to destroy only slot1. googletag.destroySlots([slot1]); // This call to destroy both slot1 and slot2. googletag.destroySlots([slot1, slot2]); // This call to destroy all slots. googletag.destroySlots();
JavaScript (เดิม)
// The calls to construct an ad and display contents. var slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1"); googletag.display("div-1"); var slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2"); googletag.display("div-2"); // This call to destroy only slot1. googletag.destroySlots([slot1]); // This call to destroy both slot1 and slot2. googletag.destroySlots([slot1, slot2]); // This call to destroy all slots. googletag.destroySlots();
TypeScript
// The calls to construct an ad and display contents. const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1")!; googletag.display("div-1"); const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2")!; googletag.display("div-2"); // This call to destroy only slot1. googletag.destroySlots([slot1]); // This call to destroy both slot1 and slot2. googletag.destroySlots([slot1, slot2]); // This call to destroy all slots. googletag.destroySlots();
-
พารามิเตอร์ slots?: Slot[]
อาร์เรย์ของช่องที่จะทำลาย อาร์เรย์เป็นตัวเลือก สล็อตทั้งหมดจะถูกทำลายหากไม่ได้ระบุ -
การคืนสินค้า boolean
true
หากช่องโฆษณาถูกทำลายแล้วfalse
ไม่เช่นนั้น
googletagdisablePublisherConsole
-
disablePublisherConsole(): void
-
ปิดใช้คอนโซลผู้เผยแพร่โฆษณาของ Google
-
- ดูเพิ่มเติม
googletagdisplay
-
display(divOrSlot: string | Element | Slot): void
-
สั่งให้บริการของสล็อตแสดงผลสล็อต ช่องโฆษณาแต่ละช่องจะแสดงได้ครั้งละหนึ่งหน้าเท่านั้น ช่องโฆษณาทั้งหมดต้องได้รับการกำหนดและมีบริการที่เชื่อมโยงกับช่องโฆษณาดังกล่าวก่อนที่จะถูกแสดง การเรียกใช้ Display ต้องไม่เกิดขึ้นจนกว่าจะมีองค์ประกอบใน DOM วิธีทั่วไปที่จะทำให้บรรลุเป้าหมายนี้คือการวางไว้ในบล็อกของสคริปต์ภายในองค์ประกอบ div ที่มีชื่อในการเรียกใช้เมธอด
หากมีการใช้สถาปัตยกรรมแบบคำขอรวมครั้งเดียว (SRA) ระบบจะดึงข้อมูลช่องโฆษณาที่ไม่ได้ดึงข้อมูลทั้งหมดเมื่อมีการเรียกใช้วิธีการนี้พร้อมกัน หากต้องการบังคับไม่ให้แสดงช่องโฆษณา จะต้องนำ div ทั้งหมดออก -
- ตัวอย่าง
-
JavaScript
googletag.cmd.push(() => { googletag.display("div-1"); });
JavaScript (เดิม)
googletag.cmd.push(function () { googletag.display("div-1"); });
TypeScript
googletag.cmd.push(() => { googletag.display("div-1"); });
- ดูเพิ่มเติม
-
พารามิเตอร์ divOrSlot: string | Element | Slot
รหัสของส่วน div ที่มีช่องโฆษณาหรือองค์ประกอบ div หรือออบเจ็กต์ช่อง หากมีการระบุองค์ประกอบ div องค์ประกอบดังกล่าวต้องมีแอตทริบิวต์ "id" ซึ่งตรงกับรหัสที่ส่งผ่านไปยังdefineSlot
googletagenableServices
-
enableServices(): void
-
เปิดใช้บริการ GPT ทั้งหมดที่ได้กำหนดไว้สำหรับช่องโฆษณาในหน้าเว็บ
-
googletaggetVersion
-
getVersion(): string
-
แสดงผล GPT เวอร์ชันปัจจุบัน
-
- ดูเพิ่มเติม
-
การคืนสินค้า string
สตริงเวอร์ชัน GPT ที่กำลังดำเนินการ
googletagopenConsole
-
openConsole(div?: string): void
-
เปิดคอนโซลผู้เผยแพร่โฆษณาของ Google
-
- ตัวอย่าง
-
JavaScript
// Calling with div ID. googletag.openConsole("div-1"); // Calling without div ID. googletag.openConsole();
JavaScript (เดิม)
// Calling with div ID. googletag.openConsole("div-1"); // Calling without div ID. googletag.openConsole();
TypeScript
// Calling with div ID. googletag.openConsole("div-1"); // Calling without div ID. googletag.openConsole();
- ดูเพิ่มเติม
-
พารามิเตอร์ div?: string
รหัส div ของช่องโฆษณา ค่านี้เป็นตัวเลือกที่ไม่บังคับ เมื่อระบุแล้ว คอนโซลผู้เผยแพร่โฆษณาจะพยายามเปิดด้วยรายละเอียดของช่องโฆษณาที่ระบุ
googletagpubads
-
pubads(): PubAdsService
-
แสดงผลการอ้างอิงไปยัง
PubAdsService
-
-
การคืนสินค้า PubAdsService
บริการโฆษณาของผู้เผยแพร่โฆษณา
googletagsetAdIframeTitle
-
setAdIframeTitle(title: string): void
-
ตั้งชื่อสำหรับ iframe ของคอนเทนเนอร์โฆษณาทั้งหมดที่สร้างโดย
PubAdsService
ตั้งแต่จุดนี้เป็นต้นไป -
- ตัวอย่าง
-
JavaScript
googletag.setAdIframeTitle("title");
JavaScript (เดิม)
googletag.setAdIframeTitle("title");
TypeScript
googletag.setAdIframeTitle("title");
-
พารามิเตอร์ title: string
ชื่อใหม่สำหรับ iframe ของคอนเทนเนอร์โฆษณาทั้งหมด
googletagsetConfig
-
setConfig(config: PageSettingsConfig): void
-
ตั้งค่าตัวเลือกการกำหนดค่าทั่วไปสำหรับหน้า
-
-
พารามิเตอร์ config: PageSettingsConfig
googletagsizeMapping
-
sizeMapping(): SizeMappingBuilder
-
สร้าง
SizeMappingBuilder
ใหม่ -
- ดูเพิ่มเติม
-
การคืนสินค้า SizeMappingBuilder
เครื่องมือสร้างใหม่
googletagCommandArray
อาร์เรย์คำสั่งจะยอมรับลำดับของฟังก์ชันและเรียกใช้ตามลำดับ โดยมีจุดประสงค์เพื่อแทนที่อาร์เรย์มาตรฐานที่ใช้ในการกำหนดคิวฟังก์ชันที่จะเรียกใช้เมื่อโหลด GPT แล้ว
ข้อมูลสรุปของเมธอด | |
---|---|
push
|
เรียกใช้ลำดับของฟังก์ชันที่ระบุในอาร์กิวเมนต์ตามลำดับ
|
push
-
push(...f: Array<(this: typeof globalThis) => void>): number
-
เรียกใช้ลำดับของฟังก์ชันที่ระบุในอาร์กิวเมนต์ตามลำดับ
-
- ตัวอย่าง
-
JavaScript
googletag.cmd.push(() => { googletag.defineSlot("/1234567/sports", [160, 600]).addService(googletag.pubads()); });
JavaScript (เดิม)
googletag.cmd.push(function () { googletag.defineSlot("/1234567/sports", [160, 600]).addService(googletag.pubads()); });
TypeScript
googletag.cmd.push(() => { googletag.defineSlot("/1234567/sports", [160, 600])!.addService(googletag.pubads()); });
-
พารามิเตอร์ ...f: Array<(this: typeof globalThis) => void>
ฟังก์ชัน JavaScript ที่จะดำเนินการ การเชื่อมโยงรันไทม์จะเป็นglobalThis
เสมอ ลองส่งฟังก์ชันลูกศรเพื่อรักษาค่าthis
ของบริบททางภาษาที่เกี่ยวข้องไว้ -
การคืนสินค้า number
จำนวนคำสั่งที่ประมวลผลจนถึงปัจจุบัน ซึ่งใช้ได้กับค่าที่แสดงผลของArray.push
(ความยาวปัจจุบันของอาร์เรย์)
googletagCompanionAdsService
ขยายเวลา
โฆษณาร่วม โฆษณาวิดีโอใช้บริการนี้เพื่อแสดงโฆษณาที่แสดงร่วม
ข้อมูลสรุปของเมธอด | |
---|---|
addEventListener
|
บันทึกผู้ฟังที่อนุญาตให้คุณตั้งค่าและเรียกฟังก์ชัน JavaScript เมื่อเกิดเหตุการณ์ GPT หนึ่งขึ้นในหน้า
รับค่าจาก
|
getSlots
|
รับรายการของช่องที่เชื่อมโยงกับบริการนี้
รับค่าจาก
|
removeEventListener
|
นำ Listener ที่ลงทะเบียนก่อนหน้านี้ออก
รับค่าจาก
|
setRefreshUnfilledSlots
|
ตั้งค่าว่าช่องที่แสดงร่วมกันที่ยังไม่ได้เติมโฆษณาจะได้รับการทดแทนโดยอัตโนมัติหรือไม่
|
- ดูเพิ่มเติม
setRefreshUnfilledSlots
-
setRefreshUnfilledSlots(value: boolean): void
-
ตั้งค่าว่าช่องที่แสดงร่วมกันที่ยังไม่ได้เติมโฆษณาจะมีการทดแทนข้อมูลโดยอัตโนมัติหรือไม่
วิธีนี้สามารถเรียกใช้วิธีการนี้ได้หลายครั้งตลอดอายุการใช้งานของหน้าเว็บเพื่อเปิดและปิดการทดแทนข้อมูล เฉพาะช่องที่ลงทะเบียนกับPubAdsService
ด้วยเท่านั้นที่จะมีการทดแทน เนื่องจากข้อจำกัดด้านนโยบาย วิธีการนี้ไม่ได้ออกแบบมาเพื่อเติมช่องการแสดงร่วมที่ว่างเปล่าเมื่อแสดงวิดีโอ Ad Exchange -
- ตัวอย่าง
-
JavaScript
googletag.companionAds().setRefreshUnfilledSlots(true);
JavaScript (เดิม)
googletag.companionAds().setRefreshUnfilledSlots(true);
TypeScript
googletag.companionAds().setRefreshUnfilledSlots(true);
-
พารามิเตอร์ value: boolean
true
เพื่อทดแทนช่องโฆษณาที่ไม่ได้รับโฆษณาโดยอัตโนมัติfalse
เพื่อไม่เปลี่ยนแปลง
googletagPrivacySettingsConfig
ออบเจ็กต์การกำหนดค่าสำหรับการตั้งค่าความเป็นส่วนตัว
สรุปพร็อพเพอร์ตี้ | |
---|---|
childDirectedTreatment
|
ระบุว่าควรปฏิบัติต่อหน้าแบบเหมาะสมกับเด็กหรือไม่
|
limitedAds
|
เปิดใช้การแสดงโฆษณาในโหมดโฆษณาแบบจํากัดได้ เพื่ออำนวยความสะดวกในการปฏิบัติตามกฎระเบียบของผู้เผยแพร่โฆษณา
|
nonPersonalizedAds
|
เปิดใช้การแสดงโฆษณาในโหมดโฆษณาที่ไม่ได้ปรับตามโปรไฟล์ของผู้ใช้เพื่อตอบสนองความต้องการด้านการปฏิบัติตามกฎระเบียบของผู้เผยแพร่โฆษณา
|
restrictDataProcessing
|
เปิดใช้การแสดงโฆษณาในโหมดการประมวลผลแบบจำกัด เพื่ออำนวยความสะดวกในการปฏิบัติตามกฎระเบียบของผู้เผยแพร่โฆษณา
|
trafficSource
|
ระบุว่าคำขอแสดงถึงการเข้าชมที่ซื้อมาหรือการเข้าชมที่เกิดขึ้นเอง
|
underAgeOfConsent
|
ระบุว่าจะทําเครื่องหมายคําขอโฆษณาว่ามาจากผู้ใช้ที่อายุต่ำกว่าอายุที่ให้ความยินยอมได้หรือไม่
|
- ดูเพิ่มเติม
childDirectedTreatment
-
childDirectedTreatment: null | boolean
-
ระบุว่าควรปฏิบัติต่อหน้าแบบเหมาะสมกับเด็กหรือไม่ ตั้งค่าเป็น
null
เพื่อล้างการกำหนดค่า -
limitedAds
-
limitedAds: boolean
-
เปิดใช้การแสดงโฆษณาในโหมดโฆษณาแบบจํากัดได้ เพื่ออำนวยความสะดวกในการปฏิบัติตามกฎระเบียบของผู้เผยแพร่โฆษณา เมื่อเปิดใช้ ระบบอาจขอไลบรารี GPT จาก URL โฆษณาแบบจํากัดที่ไม่มีคุกกี้ (ไม่บังคับ)
-
- ดูเพิ่มเติม
nonPersonalizedAds
-
nonPersonalizedAds: boolean
-
เปิดใช้การแสดงโฆษณาในโหมดโฆษณาที่ไม่ได้ปรับตามโปรไฟล์ของผู้ใช้เพื่อตอบสนองความต้องการด้านการปฏิบัติตามกฎระเบียบของผู้เผยแพร่โฆษณา
-
restrictDataProcessing
-
restrictDataProcessing: boolean
-
เปิดใช้การแสดงโฆษณาในโหมดการประมวลผลแบบจำกัด เพื่ออำนวยความสะดวกในการปฏิบัติตามกฎระเบียบของผู้เผยแพร่โฆษณา
-
trafficSource
-
trafficSource: TrafficSource
-
ระบุว่าคำขอแสดงถึงการเข้าชมที่ซื้อมาหรือการเข้าชมที่เกิดขึ้นเอง ค่านี้จะเติมเป็นมิติข้อมูลแหล่งที่มาของการเข้าชมในการรายงานของ Ad Manager หากไม่ได้ตั้งค่า แหล่งที่มาของการเข้าชมจะมีค่าเริ่มต้นเป็น
undefined
ในการรายงาน -
- ตัวอย่าง
-
JavaScript
// Indicate requests represent organic traffic. googletag.pubads().setPrivacySettings({ trafficSource: googletag.enums.TrafficSource.ORGANIC, }); // Indicate requests represent purchased traffic. googletag.pubads().setPrivacySettings({ trafficSource: googletag.enums.TrafficSource.PURCHASED, });
JavaScript (เดิม)
// Indicate requests represent organic traffic. googletag.pubads().setPrivacySettings({ trafficSource: googletag.enums.TrafficSource.ORGANIC, }); // Indicate requests represent purchased traffic. googletag.pubads().setPrivacySettings({ trafficSource: googletag.enums.TrafficSource.PURCHASED, });
TypeScript
// Indicate requests represent organic traffic. googletag.pubads().setPrivacySettings({ trafficSource: googletag.enums.TrafficSource.ORGANIC, }); // Indicate requests represent purchased traffic. googletag.pubads().setPrivacySettings({ trafficSource: googletag.enums.TrafficSource.PURCHASED, });
underAgeOfConsent
-
underAgeOfConsent: null | boolean
-
ระบุว่าจะทําเครื่องหมายคําขอโฆษณาว่ามาจากผู้ใช้ที่อายุต่ำกว่าอายุที่ให้ความยินยอมได้หรือไม่ ตั้งค่าเป็น
null
เพื่อล้างการกำหนดค่า -
googletagPubAdsService
ขยายเวลา
บริการโฆษณาของผู้เผยแพร่โฆษณา บริการนี้ใช้เพื่อดึงข้อมูลและแสดงโฆษณาจากบัญชี Google Ad Manager ของคุณ
ข้อมูลสรุปของเมธอด | |
---|---|
addEventListener
|
บันทึกผู้ฟังที่อนุญาตให้คุณตั้งค่าและเรียกฟังก์ชัน JavaScript เมื่อเกิดเหตุการณ์ GPT หนึ่งขึ้นในหน้า
รับค่าจาก
|
clear
|
นำโฆษณาออกจากช่องโฆษณาที่ระบุและแทนที่ด้วยเนื้อหาว่าง
|
clearCategoryExclusions
|
ล้างป้ายกำกับการยกเว้นหมวดหมู่โฆษณาระดับหน้าเว็บทั้งหมด
|
clearTargeting
|
ล้างพารามิเตอร์การกำหนดเป้าหมายเองสำหรับคีย์ใดคีย์หนึ่งหรือคีย์ทั้งหมด
|
collapseEmptyDivs
|
เปิดใช้การยุบ div ของช่องเพื่อให้ div ไม่กินพื้นที่ในหน้าเว็บเมื่อไม่มีเนื้อหาโฆษณาที่จะแสดง
|
disableInitialLoad
|
ปิดใช้คำขอโฆษณาเมื่อมีการโหลดหน้าเว็บ แต่อนุญาตให้มีการขอโฆษณาด้วยการเรียก
PubAdsService.refresh
|
display
|
สร้างและแสดงช่องโฆษณาตามเส้นทางและขนาดของหน่วยโฆษณาที่ระบุ
|
enableLazyLoad
|
เปิดใช้การโหลดแบบ Lazy Loading ใน GPT ตามที่กำหนดโดยออบเจ็กต์ config
|
enableSingleRequest
|
เปิดใช้โหมดคำขอรวมครั้งเดียวสำหรับการดึงข้อมูลโฆษณาหลายรายการพร้อมกัน
|
enableVideoAds
|
ส่งสัญญาณไปยัง GPT ว่าโฆษณาวิดีโอจะแสดงในหน้า
|
get
|
แสดงผลค่าสำหรับแอตทริบิวต์ AdSense ที่เชื่อมโยงกับคีย์ที่ระบุ
|
getAttributeKeys
|
แสดงผลคีย์แอตทริบิวต์ที่ตั้งค่าไว้ในบริการนี้
|
getSlots
|
รับรายการของช่องที่เชื่อมโยงกับบริการนี้
รับค่าจาก
|
getTargeting
|
แสดงผลพารามิเตอร์การกำหนดเป้าหมายระดับบริการที่กำหนดเองซึ่งตั้งค่าไว้
|
getTargetingKeys
|
แสดงรายการคีย์การกำหนดเป้าหมายระดับบริการที่กำหนดเองทั้งหมดที่มีการตั้งค่า
|
isInitialLoadDisabled
|
แสดงผลว่าคำขอเริ่มต้นของโฆษณาถูกปิดใช้โดยการเรียก
PubAdsService.disableInitialLoad ก่อนหน้าสำเร็จหรือไม่
|
refresh
|
ดึงและแสดงโฆษณาใหม่สำหรับช่องโฆษณาที่ระบุหรือทั้งหมดบนหน้าเว็บ
|
removeEventListener
|
นำ Listener ที่ลงทะเบียนก่อนหน้านี้ออก
รับค่าจาก
|
set
|
ตั้งค่าแอตทริบิวต์ AdSense ที่จะใช้กับทุกช่องโฆษณาภายใต้บริการโฆษณาของผู้เผยแพร่โฆษณา
|
setCategoryExclusion
|
ตั้งค่าการยกเว้นหมวดหมู่โฆษณาระดับหน้าเว็บสำหรับชื่อป้ายกำกับที่ระบุ
|
setCentering
|
เปิดและปิดใช้การจัดโฆษณากึ่งกลางแนวนอน
|
setForceSafeFrame
|
กำหนดค่าว่าจะบังคับให้แสดงผลโฆษณาทั้งหมดในหน้าโดยใช้คอนเทนเนอร์ SafeFrame หรือไม่
|
setLocation
|
ส่งผ่านข้อมูลตำแหน่งจากเว็บไซต์ต่างๆ เพื่อให้คุณสามารถกำหนดเป้าหมายทางภูมิศาสตร์ของรายการโฆษณาไปยังตำแหน่งที่เฉพาะเจาะจงได้
|
setPrivacySettings
|
อนุญาตให้กำหนดการตั้งค่าความเป็นส่วนตัวทั้งหมดจาก API เดียวโดยใช้ออบเจ็กต์การกำหนดค่า
|
setPublisherProvidedId
|
ตั้งค่ารหัสที่ผู้เผยแพร่โฆษณาระบุ
|
setSafeFrameConfig
|
ตั้งค่ากำหนดระดับหน้าสำหรับการกำหนดค่า SafeFrame
|
setTargeting
|
ตั้งค่าพารามิเตอร์การกำหนดเป้าหมายเองสำหรับคีย์หนึ่งๆ ที่ใช้กับช่องโฆษณาบริการโฆษณาของผู้เผยแพร่โฆษณาทั้งหมด
|
setVideoContent
|
ตั้งค่าข้อมูลเนื้อหาวิดีโอที่จะส่งไปพร้อมกับคำขอโฆษณาโดยมีจุดประสงค์เพื่อการกำหนดเป้าหมายและการยกเว้นเนื้อหา
|
updateCorrelator
|
เปลี่ยนสหสัมพันธ์ที่ส่งพร้อมกับคำขอโฆษณา ซึ่งเป็นการเริ่มต้นการดูหน้าเว็บใหม่อย่างมีประสิทธิภาพ
|
clear
-
clear(slots?: Slot[]): boolean
-
นำโฆษณาออกจากช่องโฆษณาที่ระบุและแทนที่ด้วยเนื้อหาว่าง ระบบจะทำเครื่องหมายช่องโฆษณาว่าไม่ได้ดึงข้อมูล
โดยเฉพาะอย่างยิ่ง การล้างช่องโฆษณาจะเป็นการนำโฆษณาออกจากการดูหน้าเว็บเป็นระยะเวลานานของ GPT ดังนั้นคำขอในอนาคตจะไม่ได้รับผลจาก Roadblock หรือการยกเว้นโฆษณาของคู่แข่งที่เกี่ยวข้องกับโฆษณานี้ -
- ตัวอย่าง
-
JavaScript
const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1"); googletag.display("div-1"); const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2"); googletag.display("div-2"); // This call to clear only slot1. googletag.pubads().clear([slot1]); // This call to clear both slot1 and slot2. googletag.pubads().clear([slot1, slot2]); // This call to clear all slots. googletag.pubads().clear();
JavaScript (เดิม)
var slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1"); googletag.display("div-1"); var slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2"); googletag.display("div-2"); // This call to clear only slot1. googletag.pubads().clear([slot1]); // This call to clear both slot1 and slot2. googletag.pubads().clear([slot1, slot2]); // This call to clear all slots. googletag.pubads().clear();
TypeScript
const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1")!; googletag.display("div-1"); const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2")!; googletag.display("div-2"); // This call to clear only slot1. googletag.pubads().clear([slot1]); // This call to clear both slot1 and slot2. googletag.pubads().clear([slot1, slot2]); // This call to clear all slots. googletag.pubads().clear();
-
พารามิเตอร์ slots?: Slot[]
อาร์เรย์ของช่องที่จะล้าง อาร์เรย์เป็นตัวเลือกที่ไม่บังคับ ช่องทั้งหมดจะถูกล้างหากไม่ได้ระบุ -
การคืนสินค้า boolean
แสดงผลtrue
หากล้างช่องโฆษณาแล้ว มิเช่นนั้นให้แสดงผลfalse
clearCategoryExclusions
-
clearCategoryExclusions(): PubAdsService
-
ล้างป้ายกำกับการยกเว้นหมวดหมู่โฆษณาระดับหน้าเว็บทั้งหมด ซึ่งจะเป็นประโยชน์หากคุณต้องการรีเฟรชช่อง
-
- ตัวอย่าง
-
JavaScript
// Set category exclusion to exclude ads with 'AirlineAd' labels. googletag.pubads().setCategoryExclusion("AirlineAd"); // Make ad requests. No ad with 'AirlineAd' label will be returned. // Clear category exclusions so all ads can be returned. googletag.pubads().clearCategoryExclusions(); // Make ad requests. Any ad can be returned.
JavaScript (เดิม)
// Set category exclusion to exclude ads with 'AirlineAd' labels. googletag.pubads().setCategoryExclusion("AirlineAd"); // Make ad requests. No ad with 'AirlineAd' label will be returned. // Clear category exclusions so all ads can be returned. googletag.pubads().clearCategoryExclusions(); // Make ad requests. Any ad can be returned.
TypeScript
// Set category exclusion to exclude ads with 'AirlineAd' labels. googletag.pubads().setCategoryExclusion("AirlineAd"); // Make ad requests. No ad with 'AirlineAd' label will be returned. // Clear category exclusions so all ads can be returned. googletag.pubads().clearCategoryExclusions(); // Make ad requests. Any ad can be returned.
- ดูเพิ่มเติม
-
การคืนสินค้า PubAdsService
ออบเจ็กต์บริการที่มีการเรียกใช้เมธอด
clearTargeting
-
clearTargeting(key?: string): PubAdsService
-
ล้างพารามิเตอร์การกำหนดเป้าหมายเองสำหรับคีย์ใดคีย์หนึ่งหรือคีย์ทั้งหมด
-
- ตัวอย่าง
-
JavaScript
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().setTargeting("colors", "blue"); googletag.pubads().setTargeting("fruits", "apple"); googletag.pubads().clearTargeting("interests"); // Targeting 'colors' and 'fruits' are still present, while 'interests' // was cleared. googletag.pubads().clearTargeting(); // All targeting has been cleared.
JavaScript (เดิม)
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().setTargeting("colors", "blue"); googletag.pubads().setTargeting("fruits", "apple"); googletag.pubads().clearTargeting("interests"); // Targeting 'colors' and 'fruits' are still present, while 'interests' // was cleared. googletag.pubads().clearTargeting(); // All targeting has been cleared.
TypeScript
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().setTargeting("colors", "blue"); googletag.pubads().setTargeting("fruits", "apple"); googletag.pubads().clearTargeting("interests"); // Targeting 'colors' and 'fruits' are still present, while 'interests' // was cleared. googletag.pubads().clearTargeting(); // All targeting has been cleared.
- ดูเพิ่มเติม
-
พารามิเตอร์ key?: string
คีย์พารามิเตอร์การกำหนดเป้าหมาย คีย์เป็นตัวเลือกที่ไม่บังคับ ระบบจะล้างพารามิเตอร์การกำหนดเป้าหมายทั้งหมดหากไม่ได้ระบุ -
การคืนสินค้า PubAdsService
ออบเจ็กต์บริการที่มีการเรียกใช้เมธอด
collapseEmptyDivs
-
collapseEmptyDivs(collapseBeforeAdFetch?: boolean): boolean
-
เปิดใช้การยุบ div ของช่องเพื่อให้ div ไม่กินพื้นที่ในหน้าเว็บเมื่อไม่มีเนื้อหาโฆษณาที่จะแสดง ต้องตั้งค่าโหมดนี้ก่อนเปิดใช้บริการ
-
- ดูเพิ่มเติม
-
พารามิเตอร์ collapseBeforeAdFetch?: boolean
เลือกว่าจะยุบช่องโฆษณาก่อนที่จะดึงข้อมูลโฆษณาหรือไม่ คุณจะระบุพารามิเตอร์นี้หรือไม่ก็ได้ หากไม่ได้ระบุ ระบบจะใช้false
เป็นค่าเริ่มต้น -
การคืนสินค้า boolean
แสดงผลtrue
หากเปิดใช้โหมดยุบ div และfalse
หากเปิดใช้โหมดยุบไม่ได้ เนื่องจากมีการเรียกใช้เมธอดหลังจากเปิดใช้บริการ
disableInitialLoad
-
disableInitialLoad(): void
-
ปิดใช้คำขอโฆษณาเมื่อมีการโหลดหน้าเว็บ แต่อนุญาตให้มีการขอโฆษณาด้วยการเรียก
PubAdsService.refresh
ควรกำหนดค่านี้ก่อนเปิดใช้บริการ ต้องใช้โหมดอะซิงโครนัส มิฉะนั้นจะขอโฆษณาโดยใช้refresh
ไม่ได้ -
- ดูเพิ่มเติม
display
-
display(adUnitPath: string, size: GeneralSize, div?: string | Element, clickUrl?: string): void
-
สร้างและแสดงช่องโฆษณาตามเส้นทางและขนาดของหน่วยโฆษณาที่ระบุ วิธีนี้ใช้ไม่ได้กับโหมดคำขอรวมครั้งเดียว
หมายเหตุ: เมื่อมีการเรียกใช้เมธอดนี้ ระบบจะสร้างสแนปชอตของช่องและสถานะหน้าเว็บเพื่อให้แน่ใจว่ามีความสอดคล้องกันเมื่อส่งคำขอโฆษณาและแสดงผลการตอบกลับ การเปลี่ยนแปลงที่เกิดขึ้นกับช่องหรือสถานะหน้าเว็บหลังจากเรียกใช้เมธอดนี้ (รวมถึงการกำหนดเป้าหมาย การตั้งค่าความเป็นส่วนตัว การบังคับใช้ SafeFrame ฯลฯ) จะมีผลกับคำขอdisplay()
หรือrefresh()
ที่ตามมาเท่านั้น -
- ตัวอย่าง
-
JavaScript
googletag.pubads().display("/1234567/sports", [728, 90], "div-1");
JavaScript (เดิม)
googletag.pubads().display("/1234567/sports", [728, 90], "div-1");
TypeScript
googletag.pubads().display("/1234567/sports", [728, 90], "div-1");
- ดูเพิ่มเติม
-
พารามิเตอร์ adUnitPath: string
เส้นทางหน่วยโฆษณาของช่องที่จะแสดงผลsize: GeneralSize
ความกว้างและความสูงของช่องdiv?: string | Element
รหัสของ div ที่มีช่องโฆษณาหรือองค์ประกอบ div นั้นclickUrl?: string
URL การคลิกที่จะใช้กับช่องนี้
enableLazyLoad
-
enableLazyLoad(config?: { fetchMarginPercent: number, mobileScaling: number, renderMarginPercent: number }): void
-
เปิดใช้การโหลดแบบ Lazy Loading ใน GPT ตามที่กำหนดโดยออบเจ็กต์ config ดูตัวอย่างโดยละเอียดเพิ่มเติมได้ในตัวอย่างการโหลดแบบ Lazy Loading
หมายเหตุ: การดึงข้อมูลแบบ Lazy Loading ใน SRA จะใช้งานได้เมื่อสล็อตทั้งหมดอยู่นอกระยะขอบการดึงข้อมูล -
- ตัวอย่าง
-
JavaScript
googletag.pubads().enableLazyLoad({ // Fetch slots within 5 viewports. fetchMarginPercent: 500, // Render slots within 2 viewports. renderMarginPercent: 200, // Double the above values on mobile. mobileScaling: 2.0, });
JavaScript (เดิม)
googletag.pubads().enableLazyLoad({ // Fetch slots within 5 viewports. fetchMarginPercent: 500, // Render slots within 2 viewports. renderMarginPercent: 200, // Double the above values on mobile. mobileScaling: 2.0, });
TypeScript
googletag.pubads().enableLazyLoad({ // Fetch slots within 5 viewports. fetchMarginPercent: 500, // Render slots within 2 viewports. renderMarginPercent: 200, // Double the above values on mobile. mobileScaling: 2.0, });
- ดูเพิ่มเติม
-
พารามิเตอร์ config?: { fetchMarginPercent: number, mobileScaling: number, renderMarginPercent: number }
ออบเจ็กต์การกำหนดค่าอนุญาตให้ปรับแต่งลักษณะการทำงานแบบ Lazy Loading ได้ การกําหนดค่าที่ละเว้นไว้จะใช้ค่าเริ่มต้นที่ Google กําหนดไว้ ซึ่งจะปรับแต่งเมื่อเวลาผ่านไป หากต้องการปิดใช้การตั้งค่าบางอย่าง เช่น ระยะขอบในการดึงข้อมูล ให้ตั้งค่านี้เป็น-1
fetchMarginPercent
ระยะห่างขั้นต่ำจากวิวพอร์ตปัจจุบันที่ช่องโฆษณาต้องอยู่ก่อนที่เราจะดึงโฆษณาเป็นเปอร์เซ็นต์ของขนาดวิวพอร์ต ค่า 0 หมายถึง "เมื่อช่องโฆษณาเข้าสู่วิวพอร์ต", 100 หมายถึง "เมื่อโฆษณาอยู่ห่างออกไป 1 วิวพอร์ต" และอื่นๆrenderMarginPercent
ระยะห่างขั้นต่ำจากวิวพอร์ตปัจจุบันที่ช่องโฆษณาต้องอยู่ก่อนที่เราจะแสดงโฆษณา ซึ่งจะช่วยให้สามารถดึงข้อมูลโฆษณาล่วงหน้าได้ แต่กำลังรอแสดงผลและดาวน์โหลดทรัพยากรย่อยอื่นๆ ค่าจะทำงานเหมือนกับfetchMarginPercent
ที่เป็นเปอร์เซ็นต์ของวิวพอร์ตmobileScaling
ตัวคูณที่ใช้กับส่วนต่างกำไรบนอุปกรณ์เคลื่อนที่ ทำให้บนอุปกรณ์เคลื่อนที่เทียบกับเดสก์ท็อปได้ส่วนต่างกำไร เช่น ค่า 2.0 จะคูณระยะขอบทั้งหมดด้วย 2 ในอุปกรณ์เคลื่อนที่ ซึ่งเป็นการเพิ่มระยะห่างขั้นต่ำที่สล็อตก่อนการดึงข้อมูลและแสดงผล
enableSingleRequest
-
enableSingleRequest(): boolean
-
เปิดใช้โหมดคำขอรวมครั้งเดียวสำหรับการดึงข้อมูลโฆษณาหลายรายการพร้อมกัน ซึ่งกำหนดให้ต้องกำหนดและเพิ่มช่องโฆษณาทั้งหมดของผู้เผยแพร่โฆษณาลงใน PubAdsService ก่อนเปิดใช้บริการ ต้องตั้งค่าโหมดคำขอรวมครั้งเดียวก่อนที่จะเปิดใช้งานบริการ
-
การคืนสินค้า boolean
แสดงผลtrue
หากเปิดใช้โหมดคำขอรวมครั้งเดียว และfalse
หากเปิดใช้โหมดคำขอรวมครั้งเดียวไม่ได้ เนื่องจากมีการเรียกใช้เมธอดหลังจากเปิดใช้บริการ
enableVideoAds
-
enableVideoAds(): void
-
ส่งสัญญาณไปยัง GPT ว่าโฆษณาวิดีโอจะแสดงในหน้า ซึ่งจะทําให้เกิดข้อจํากัดด้านการยกเว้นคู่แข่งในโฆษณา Display และโฆษณาวิดีโอ หากเนื้อหาวิดีโอเป็นที่รู้จัก โปรดเรียกใช้
PubAdsService.setVideoContent
เพื่อให้สามารถใช้การยกเว้นเนื้อหาสำหรับโฆษณา Display ได้ -
get
-
get(key: string): null | string
-
แสดงผลค่าสำหรับแอตทริบิวต์ AdSense ที่เชื่อมโยงกับคีย์ที่ระบุ
-
- ตัวอย่าง
-
JavaScript
googletag.pubads().set("adsense_background_color", "#FFFFFF"); googletag.pubads().get("adsense_background_color"); // Returns '#FFFFFF'.
JavaScript (เดิม)
googletag.pubads().set("adsense_background_color", "#FFFFFF"); googletag.pubads().get("adsense_background_color"); // Returns '#FFFFFF'.
TypeScript
googletag.pubads().set("adsense_background_color", "#FFFFFF"); googletag.pubads().get("adsense_background_color"); // Returns '#FFFFFF'.
- ดูเพิ่มเติม
-
พารามิเตอร์ key: string
ชื่อของแอตทริบิวต์ที่จะค้นหา -
การคืนสินค้า null | string
ค่าปัจจุบันสำหรับคีย์แอตทริบิวต์ หรือnull
หากไม่มีคีย์
getAttributeKeys
-
getAttributeKeys(): string[]
-
แสดงผลคีย์แอตทริบิวต์ที่ตั้งค่าไว้ในบริการนี้
-
- ตัวอย่าง
-
JavaScript
googletag.pubads().set("adsense_background_color", "#FFFFFF"); googletag.pubads().set("adsense_border_color", "#AABBCC"); googletag.pubads().getAttributeKeys(); // Returns ['adsense_background_color', 'adsense_border_color'].
JavaScript (เดิม)
googletag.pubads().set("adsense_background_color", "#FFFFFF"); googletag.pubads().set("adsense_border_color", "#AABBCC"); googletag.pubads().getAttributeKeys(); // Returns ['adsense_background_color', 'adsense_border_color'].
TypeScript
googletag.pubads().set("adsense_background_color", "#FFFFFF"); googletag.pubads().set("adsense_border_color", "#AABBCC"); googletag.pubads().getAttributeKeys(); // Returns ['adsense_background_color', 'adsense_border_color'].
-
การคืนสินค้า string[]
อาร์เรย์ของคีย์แอตทริบิวต์ที่ตั้งค่าไว้ในบริการนี้ ไม่ได้ระบุการเรียงลำดับ
getTargeting
-
getTargeting(key: string): string[]
-
แสดงผลพารามิเตอร์การกำหนดเป้าหมายระดับบริการที่กำหนดเองซึ่งตั้งค่าไว้
-
- ตัวอย่าง
-
JavaScript
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().getTargeting("interests"); // Returns ['sports']. googletag.pubads().getTargeting("age"); // Returns [] (empty array).
JavaScript (เดิม)
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().getTargeting("interests"); // Returns ['sports']. googletag.pubads().getTargeting("age"); // Returns [] (empty array).
TypeScript
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().getTargeting("interests"); // Returns ['sports']. googletag.pubads().getTargeting("age"); // Returns [] (empty array).
-
พารามิเตอร์ key: string
คีย์การกำหนดเป้าหมายที่จะค้นหา -
การคืนสินค้า string[]
ค่าที่เชื่อมโยงกับคีย์นี้ หรืออาร์เรย์ว่างเปล่าหากไม่มีคีย์ดังกล่าว
getTargetingKeys
-
getTargetingKeys(): string[]
-
แสดงรายการคีย์การกำหนดเป้าหมายระดับบริการที่กำหนดเองทั้งหมดที่มีการตั้งค่า
-
- ตัวอย่าง
-
JavaScript
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().setTargeting("colors", "blue"); googletag.pubads().getTargetingKeys(); // Returns ['interests', 'colors'].
JavaScript (เดิม)
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().setTargeting("colors", "blue"); googletag.pubads().getTargetingKeys(); // Returns ['interests', 'colors'].
TypeScript
googletag.pubads().setTargeting("interests", "sports"); googletag.pubads().setTargeting("colors", "blue"); googletag.pubads().getTargetingKeys(); // Returns ['interests', 'colors'].
-
การคืนสินค้า string[]
อาร์เรย์ของคีย์การกำหนดเป้าหมาย ไม่ได้ระบุการเรียงลำดับ
isInitialLoadDisabled
-
isInitialLoadDisabled(): boolean
-
แสดงผลว่าคำขอเริ่มต้นของโฆษณาถูกปิดใช้โดยการเรียก
PubAdsService.disableInitialLoad
ก่อนหน้าสำเร็จหรือไม่ -
-
การคืนสินค้า boolean
แสดงผลtrue
หากการโทรไปยังPubAdsService.disableInitialLoad
ก่อนหน้านี้ประสบความสำเร็จfalse
หากไม่เป็นเช่นนั้น
refresh
-
refresh(slots?: null | Slot[], options?: { changeCorrelator: boolean }): void
-
ดึงและแสดงโฆษณาใหม่สำหรับช่องโฆษณาที่ระบุหรือทั้งหมดบนหน้าเว็บ ทำงานได้เฉพาะในโหมดการแสดงผลแบบไม่พร้อมกันเท่านั้น
เพื่อให้ทำงานได้อย่างถูกต้องในเบราว์เซอร์ทั้งหมด การเรียกrefresh
จะต้องอยู่ต่อจากการเรียกdisplay
ช่องโฆษณา หากการเรียกไปยังdisplay
ไม่ได้อยู่ การรีเฟรชอาจแสดงผลโดยไม่คาดคิด คุณสามารถใช้เมธอดPubAdsService.disableInitialLoad
เพื่อหยุดdisplay
ไม่ให้ดึงข้อมูลโฆษณาได้หากต้องการ
การรีเฟรชช่องจะนำโฆษณาเดิมออกจากการดูหน้าเว็บเป็นระยะเวลานานของ GPT ดังนั้นคำขอในอนาคตจะไม่ได้รับผลจาก Roadblock หรือการยกเว้นโฆษณาของคู่แข่งที่เกี่ยวข้องกับโฆษณานั้น -
- ตัวอย่าง
-
JavaScript
const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1"); googletag.display("div-1"); const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2"); googletag.display("div-2"); // This call to refresh fetches a new ad for slot1 only. googletag.pubads().refresh([slot1]); // This call to refresh fetches a new ad for both slot1 and slot2. googletag.pubads().refresh([slot1, slot2]); // This call to refresh fetches a new ad for each slot. googletag.pubads().refresh(); // This call to refresh fetches a new ad for slot1, without changing // the correlator. googletag.pubads().refresh([slot1], { changeCorrelator: false }); // This call to refresh fetches a new ad for each slot, without // changing the correlator. googletag.pubads().refresh(null, { changeCorrelator: false });
JavaScript (เดิม)
var slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1"); googletag.display("div-1"); var slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2"); googletag.display("div-2"); // This call to refresh fetches a new ad for slot1 only. googletag.pubads().refresh([slot1]); // This call to refresh fetches a new ad for both slot1 and slot2. googletag.pubads().refresh([slot1, slot2]); // This call to refresh fetches a new ad for each slot. googletag.pubads().refresh(); // This call to refresh fetches a new ad for slot1, without changing // the correlator. googletag.pubads().refresh([slot1], { changeCorrelator: false }); // This call to refresh fetches a new ad for each slot, without // changing the correlator. googletag.pubads().refresh(null, { changeCorrelator: false });
TypeScript
const slot1 = googletag.defineSlot("/1234567/sports", [728, 90], "div-1")!; googletag.display("div-1"); const slot2 = googletag.defineSlot("/1234567/news", [160, 600], "div-2")!; googletag.display("div-2"); // This call to refresh fetches a new ad for slot1 only. googletag.pubads().refresh([slot1]); // This call to refresh fetches a new ad for both slot1 and slot2. googletag.pubads().refresh([slot1, slot2]); // This call to refresh fetches a new ad for each slot. googletag.pubads().refresh(); // This call to refresh fetches a new ad for slot1, without changing // the correlator. googletag.pubads().refresh([slot1], { changeCorrelator: false }); // This call to refresh fetches a new ad for each slot, without // changing the correlator. googletag.pubads().refresh(null, { changeCorrelator: false });
- ดูเพิ่มเติม
-
พารามิเตอร์ slots?: null | Slot[]
ช่องโฆษณาที่จะรีเฟรช อาร์เรย์เป็นตัวเลือก สล็อตทั้งหมดจะถูกรีเฟรชหากไม่ได้ระบุoptions?: { changeCorrelator: boolean }
ตัวเลือกการกำหนดค่าที่เชื่อมโยงกับการโทรรีเฟรชนี้changeCorrelator
ระบุว่าจะสร้างสหสัมพันธ์ใหม่สำหรับการดึงโฆษณาหรือไม่ เซิร์ฟเวอร์โฆษณาของเราจะยังคงค่าสหสัมพันธ์นี้เป็นระยะเวลาสั้นๆ (ปัจจุบันอยู่ที่ 30 วินาที แต่อาจมีการเปลี่ยนแปลง) คำขอที่มีค่า Correlator เดียวกันซึ่งได้รับในเวลาใกล้ๆ กันจะจัดว่าเป็นการดูหน้าเว็บครั้งเดียว โดยค่าเริ่มต้น ระบบจะสร้างสหสัมพันธ์ใหม่สำหรับทุกการรีเฟรช
หมายเหตุ: ตัวเลือกนี้ไม่มีผลต่อการดูหน้าเว็บเป็นระยะเวลานานของ GPT ซึ่งจะแสดงโฆษณาปัจจุบันบนหน้าเว็บโดยอัตโนมัติและไม่มีเวลาหมดอายุ
set
-
set(key: string, value: string): PubAdsService
-
ตั้งค่าแอตทริบิวต์ AdSense ที่จะใช้กับทุกช่องโฆษณาภายใต้บริการโฆษณาของผู้เผยแพร่โฆษณา
การเรียกคำสั่งนี้มากกว่า 1 ครั้งสำหรับคีย์เดียวกันจะลบล้างค่าที่กำหนดไว้ก่อนหน้านี้สำหรับคีย์นั้น ทุกค่าต้องตั้งค่าก่อนเรียกใช้display
หรือrefresh
-
- ตัวอย่าง
-
JavaScript
googletag.pubads().set("adsense_background_color", "#FFFFFF");
JavaScript (เดิม)
googletag.pubads().set("adsense_background_color", "#FFFFFF");
TypeScript
googletag.pubads().set("adsense_background_color", "#FFFFFF");
- ดูเพิ่มเติม
-
พารามิเตอร์ key: string
ชื่อของแอตทริบิวต์value: string
ค่าแอตทริบิวต์ -
การคืนสินค้า PubAdsService
ออบเจ็กต์บริการที่มีการเรียกใช้เมธอด
setCategoryExclusion
-
setCategoryExclusion(categoryExclusion: string): PubAdsService
-
ตั้งค่าการยกเว้นหมวดหมู่โฆษณาระดับหน้าเว็บสำหรับชื่อป้ายกำกับที่ระบุ
-
- ตัวอย่าง
-
JavaScript
// Label = AirlineAd. googletag.pubads().setCategoryExclusion("AirlineAd");
JavaScript (เดิม)
// Label = AirlineAd. googletag.pubads().setCategoryExclusion("AirlineAd");
TypeScript
// Label = AirlineAd. googletag.pubads().setCategoryExclusion("AirlineAd");
- ดูเพิ่มเติม
-
พารามิเตอร์ categoryExclusion: string
ป้ายกำกับการยกเว้นหมวดหมู่โฆษณาที่จะเพิ่ม -
การคืนสินค้า PubAdsService
ออบเจ็กต์บริการที่มีการเรียกใช้เมธอด
setCentering
-
setCentering(centerAds: boolean): void
-
เปิดและปิดใช้การจัดโฆษณากึ่งกลางแนวนอน การจัดกึ่งกลางจะปิดใช้โดยค่าเริ่มต้น ใน gpt_mobile.js เดิม ระบบจะเปิดใช้การจัดกึ่งกลางโดยค่าเริ่มต้น
วิธีนี้ควรเรียกใช้ก่อนเรียกใช้display
หรือrefresh
เนื่องจากเฉพาะโฆษณาที่ขอหลังจากเรียกใช้เมธอดนี้เท่านั้นที่จะอยู่กึ่งกลาง -
- ตัวอย่าง
-
JavaScript
// Make ads centered. googletag.pubads().setCentering(true);
JavaScript (เดิม)
// Make ads centered. googletag.pubads().setCentering(true);
TypeScript
// Make ads centered. googletag.pubads().setCentering(true);
-
พารามิเตอร์ centerAds: boolean
true
เพื่อจัดโฆษณาให้อยู่กึ่งกลางfalse
เพื่อจัดชิดซ้าย
setForceSafeFrame
-
setForceSafeFrame(forceSafeFrame: boolean): PubAdsService
-
กำหนดค่าว่าจะบังคับให้แสดงผลโฆษณาทั้งหมดในหน้าโดยใช้คอนเทนเนอร์ SafeFrame หรือไม่
โปรดคำนึงถึงสิ่งต่อไปนี้ขณะใช้ API นี้- การตั้งค่านี้จะมีผลกับคำขอโฆษณาที่ตามมาสำหรับช่องที่เกี่ยวข้องเท่านั้น
- การตั้งค่าระดับช่อง (หากระบุไว้) จะลบล้างการตั้งค่าระดับหน้าเว็บเสมอ
- หากตั้งค่าเป็น
true
(ที่ระดับช่องโฆษณาหรือระดับหน้า) โฆษณาจะแสดงผลโดยใช้คอนเทนเนอร์ SafeFrame เสมอโดยไม่ขึ้นกับตัวเลือกที่กำหนดใน UI ของ Google Ad Manager - อย่างไรก็ตาม หากตั้งค่าเป็น
false
หรือไม่ได้ระบุ โฆษณาจะแสดงผลโดยใช้คอนเทนเนอร์ SafeFrame โดยขึ้นอยู่กับประเภทของครีเอทีฟโฆษณาและการเลือกใน UI ของ Google Ad Manager - คุณควรใช้ API นี้อย่างระมัดระวัง เนื่องจากอาจส่งผลต่อลักษณะการทำงานของครีเอทีฟโฆษณาที่พยายามแยก iframe หรือใช้งาน API ที่แสดงผลโดยตรงในหน้าผู้เผยแพร่โฆษณา
-
- ตัวอย่าง
-
JavaScript
googletag.pubads().setForceSafeFrame(true); // The following slot will be opted-out of the page-level force // SafeFrame instruction. googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setForceSafeFrame(false) .addService(googletag.pubads()); // The following slot will have SafeFrame forced. googletag.defineSlot("/1234567/news", [160, 600], "div-2").addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
JavaScript (เดิม)
googletag.pubads().setForceSafeFrame(true); // The following slot will be opted-out of the page-level force // SafeFrame instruction. googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setForceSafeFrame(false) .addService(googletag.pubads()); // The following slot will have SafeFrame forced. googletag.defineSlot("/1234567/news", [160, 600], "div-2").addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
TypeScript
googletag.pubads().setForceSafeFrame(true); // The following slot will be opted-out of the page-level force // SafeFrame instruction. googletag .defineSlot("/1234567/sports", [160, 600], "div-1")! .setForceSafeFrame(false) .addService(googletag.pubads()); // The following slot will have SafeFrame forced. googletag.defineSlot("/1234567/news", [160, 600], "div-2")!.addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
- ดูเพิ่มเติม
-
พารามิเตอร์ forceSafeFrame: boolean
true
เพื่อบังคับให้โฆษณาทั้งหมดในหน้าแสดงผลใน SafeFrame และfalse
เปลี่ยนการตั้งค่าก่อนหน้าเป็นเท็จ การตั้งค่านี้เป็นfalse
เมื่อไม่ได้ระบุก่อนหน้านี้ จะไม่เปลี่ยนแปลงอะไร -
การคืนสินค้า PubAdsService
ออบเจ็กต์บริการที่มีการเรียกใช้ฟังก์ชัน
setLocation
-
setLocation(address: string): PubAdsService
-
ส่งผ่านข้อมูลตำแหน่งจากเว็บไซต์ต่างๆ เพื่อให้คุณสามารถกำหนดเป้าหมายทางภูมิศาสตร์ของรายการโฆษณาไปยังตำแหน่งที่เฉพาะเจาะจงได้
-
- ตัวอย่าง
-
JavaScript
// Postal code: googletag.pubads().setLocation("10001,US");
JavaScript (เดิม)
// Postal code: googletag.pubads().setLocation("10001,US");
TypeScript
// Postal code: googletag.pubads().setLocation("10001,US");
-
พารามิเตอร์ address: string
ที่อยู่รูปแบบอิสระ -
การคืนสินค้า PubAdsService
ออบเจ็กต์บริการที่มีการเรียกใช้เมธอด
setPrivacySettings
-
setPrivacySettings(privacySettings: PrivacySettingsConfig): PubAdsService
-
อนุญาตให้กำหนดการตั้งค่าความเป็นส่วนตัวทั้งหมดจาก API เดียวโดยใช้ออบเจ็กต์การกำหนดค่า
-
- ตัวอย่าง
-
JavaScript
googletag.pubads().setPrivacySettings({ restrictDataProcessing: true, }); // Set multiple privacy settings at the same time. googletag.pubads().setPrivacySettings({ childDirectedTreatment: true, underAgeOfConsent: true, }); // Clear the configuration for childDirectedTreatment. googletag.pubads().setPrivacySettings({ childDirectedTreatment: null, });
JavaScript (เดิม)
googletag.pubads().setPrivacySettings({ restrictDataProcessing: true, }); // Set multiple privacy settings at the same time. googletag.pubads().setPrivacySettings({ childDirectedTreatment: true, underAgeOfConsent: true, }); // Clear the configuration for childDirectedTreatment. googletag.pubads().setPrivacySettings({ childDirectedTreatment: null, });
TypeScript
googletag.pubads().setPrivacySettings({ restrictDataProcessing: true, }); // Set multiple privacy settings at the same time. googletag.pubads().setPrivacySettings({ childDirectedTreatment: true, underAgeOfConsent: true, }); // Clear the configuration for childDirectedTreatment. googletag.pubads().setPrivacySettings({ childDirectedTreatment: null, });
- ดูเพิ่มเติม
-
พารามิเตอร์ privacySettings: PrivacySettingsConfig
ออบเจ็กต์ที่มีการกำหนดค่าการตั้งค่าความเป็นส่วนตัว -
การคืนสินค้า PubAdsService
ออบเจ็กต์บริการที่มีการเรียกใช้ฟังก์ชัน
setPublisherProvidedId
-
setPublisherProvidedId(ppid: string): PubAdsService
-
ตั้งค่ารหัสที่ผู้เผยแพร่โฆษณาระบุ
-
- ตัวอย่าง
-
JavaScript
googletag.pubads().setPublisherProvidedId("12JD92JD8078S8J29SDOAKC0EF230337");
JavaScript (เดิม)
googletag.pubads().setPublisherProvidedId("12JD92JD8078S8J29SDOAKC0EF230337");
TypeScript
googletag.pubads().setPublisherProvidedId("12JD92JD8078S8J29SDOAKC0EF230337");
- ดูเพิ่มเติม
-
พารามิเตอร์ ppid: string
รหัสตัวอักษรและตัวเลขคละกันที่ผู้เผยแพร่โฆษณาให้ไว้ ต้องมีความยาวระหว่าง 32 ถึง 150 อักขระ -
การคืนสินค้า PubAdsService
ออบเจ็กต์บริการที่มีการเรียกใช้เมธอด
setSafeFrameConfig
-
setSafeFrameConfig(config: SafeFrameConfig): PubAdsService
-
ตั้งค่ากำหนดระดับหน้าสำหรับการกำหนดค่า SafeFrame ระบบจะไม่สนใจคีย์ที่ไม่รู้จักในออบเจ็กต์การกำหนดค่า ระบบจะไม่สนใจการกำหนดค่าทั้งหมดหากมีการส่งค่าที่ไม่ถูกต้องสำหรับคีย์ที่รู้จัก
ค่ากำหนดระดับช่องโฆษณาจะลบล้างค่ากำหนดระดับหน้าเว็บเหล่านี้ (หากระบุไว้) -
- ตัวอย่าง
-
JavaScript
googletag.pubads().setForceSafeFrame(true); const pageConfig = { allowOverlayExpansion: true, allowPushExpansion: true, sandbox: true, }; const slotConfig = { allowOverlayExpansion: false }; googletag.pubads().setSafeFrameConfig(pageConfig); // The following slot will not allow for expansion by overlay. googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setSafeFrameConfig(slotConfig) .addService(googletag.pubads()); // The following slot will inherit the page level settings, and hence // would allow for expansion by overlay. googletag.defineSlot("/1234567/news", [160, 600], "div-2").addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
JavaScript (เดิม)
googletag.pubads().setForceSafeFrame(true); var pageConfig = { allowOverlayExpansion: true, allowPushExpansion: true, sandbox: true, }; var slotConfig = { allowOverlayExpansion: false }; googletag.pubads().setSafeFrameConfig(pageConfig); // The following slot will not allow for expansion by overlay. googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setSafeFrameConfig(slotConfig) .addService(googletag.pubads()); // The following slot will inherit the page level settings, and hence // would allow for expansion by overlay. googletag.defineSlot("/1234567/news", [160, 600], "div-2").addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
TypeScript
googletag.pubads().setForceSafeFrame(true); const pageConfig = { allowOverlayExpansion: true, allowPushExpansion: true, sandbox: true, }; const slotConfig = { allowOverlayExpansion: false }; googletag.pubads().setSafeFrameConfig(pageConfig); // The following slot will not allow for expansion by overlay. googletag .defineSlot("/1234567/sports", [160, 600], "div-1")! .setSafeFrameConfig(slotConfig) .addService(googletag.pubads()); // The following slot will inherit the page level settings, and hence // would allow for expansion by overlay. googletag.defineSlot("/1234567/news", [160, 600], "div-2")!.addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
- ดูเพิ่มเติม
-
พารามิเตอร์ config: SafeFrameConfig
ออบเจ็กต์การกำหนดค่า -
การคืนสินค้า PubAdsService
ออบเจ็กต์บริการที่มีการเรียกใช้เมธอด
setTargeting
-
setTargeting(key: string, value: string | string[]): PubAdsService
-
ตั้งค่าพารามิเตอร์การกำหนดเป้าหมายเองสำหรับคีย์หนึ่งๆ ที่ใช้กับช่องโฆษณาบริการโฆษณาของผู้เผยแพร่โฆษณาทั้งหมด การเรียกคำสั่งนี้หลายครั้งสำหรับคีย์เดียวกันจะเขียนทับค่าเก่า คีย์เหล่านี้ได้รับการกำหนดในบัญชี Google Ad Manager ของคุณ
-
- ตัวอย่าง
-
JavaScript
// Example with a single value for a key. googletag.pubads().setTargeting("interests", "sports"); // Example with multiple values for a key inside in an array. googletag.pubads().setTargeting("interests", ["sports", "music"]);
JavaScript (เดิม)
// Example with a single value for a key. googletag.pubads().setTargeting("interests", "sports"); // Example with multiple values for a key inside in an array. googletag.pubads().setTargeting("interests", ["sports", "music"]);
TypeScript
// Example with a single value for a key. googletag.pubads().setTargeting("interests", "sports"); // Example with multiple values for a key inside in an array. googletag.pubads().setTargeting("interests", ["sports", "music"]);
- ดูเพิ่มเติม
-
พารามิเตอร์ key: string
คีย์พารามิเตอร์การกำหนดเป้าหมายvalue: string | string[]
ค่าพารามิเตอร์หรืออาร์เรย์ของค่าการกำหนดเป้าหมาย -
การคืนสินค้า PubAdsService
ออบเจ็กต์บริการที่มีการเรียกใช้เมธอด
setVideoContent
-
setVideoContent(videoContentId: string, videoCmsId: string): void
-
ตั้งค่าข้อมูลเนื้อหาวิดีโอที่จะส่งไปพร้อมกับคำขอโฆษณาโดยมีจุดประสงค์เพื่อการกำหนดเป้าหมายและการยกเว้นเนื้อหา โฆษณาวิดีโอจะเปิดใช้โดยอัตโนมัติเมื่อมีการเรียกใช้วิธีการนี้ สำหรับ
videoContentId
และvideoCmsId
ให้ใช้ค่าที่มีให้ในบริการนำเข้าเนื้อหาของ Google Ad Manager -
- ดูเพิ่มเติม
-
พารามิเตอร์ videoContentId: string
รหัสเนื้อหาวิดีโอvideoCmsId: string
รหัส CMS ของวิดีโอ
updateCorrelator
-
updateCorrelator(): PubAdsService
-
เปลี่ยนสหสัมพันธ์ที่ส่งพร้อมกับคำขอโฆษณา ซึ่งเป็นการเริ่มต้นการดูหน้าเว็บใหม่อย่างมีประสิทธิภาพ ค่าสหสัมพันธ์ของคำขอโฆษณาทั้งหมดที่มาจากการดูหน้าเว็บครั้งเดียวจะเหมือนกันและไม่ซ้ำกันสำหรับการดูหน้าเว็บแต่ละครั้ง ใช้ได้กับโหมดอะซิงโครนัสเท่านั้น
หมายเหตุ: การดำเนินการนี้ไม่มีผลต่อการดูหน้าเว็บเป็นระยะเวลานานของ GPT ซึ่งจะแสดงโฆษณาจริงๆ บนหน้านั้นๆ โดยอัตโนมัติและไม่มีเวลาหมดอายุ -
- ตัวอย่าง
-
JavaScript
// Assume that the correlator is currently 12345. All ad requests made // by this page will currently use that value. // Replace the current correlator with a new correlator. googletag.pubads().updateCorrelator(); // The correlator will now be a new randomly selected value, different // from 12345. All subsequent ad requests made by this page will use // the new value.
JavaScript (เดิม)
// Assume that the correlator is currently 12345. All ad requests made // by this page will currently use that value. // Replace the current correlator with a new correlator. googletag.pubads().updateCorrelator(); // The correlator will now be a new randomly selected value, different // from 12345. All subsequent ad requests made by this page will use // the new value.
TypeScript
// Assume that the correlator is currently 12345. All ad requests made // by this page will currently use that value. // Replace the current correlator with a new correlator. googletag.pubads().updateCorrelator(); // The correlator will now be a new randomly selected value, different // from 12345. All subsequent ad requests made by this page will use // the new value.
-
การคืนสินค้า PubAdsService
ออบเจ็กต์บริการที่มีการเรียกใช้ฟังก์ชัน
googletagResponseInformation
ออบเจ็กต์ที่แสดงการตอบกลับโฆษณารายการเดียว
สรุปพร็อพเพอร์ตี้ | |
---|---|
advertiserId
|
รหัสของผู้ลงโฆษณา
|
campaignId
|
รหัสของแคมเปญ
|
creativeId
|
รหัสของครีเอทีฟโฆษณา
|
creativeTemplateId
|
รหัสเทมเพลตของโฆษณา
|
lineItemId
|
รหัสของรายการโฆษณา
|
- ดูเพิ่มเติม
advertiserId
-
advertiserId: null | number
-
รหัสของผู้ลงโฆษณา
-
campaignId
-
campaignId: null | number
-
รหัสของแคมเปญ
-
creativeId
-
creativeId: null | number
-
รหัสของครีเอทีฟโฆษณา
-
creativeTemplateId
-
creativeTemplateId: null | number
-
รหัสเทมเพลตของโฆษณา
-
lineItemId
-
lineItemId: null | number
-
รหัสของรายการโฆษณา
-
googletagRewardedPayload
ออบเจ็กต์แสดงรางวัลที่เชื่อมโยงกับโฆษณาที่มีการให้รางวัล
สรุปพร็อพเพอร์ตี้ | |
---|---|
amount
|
จำนวนไอเทมที่รวมอยู่ในรางวัล
|
type
|
ประเภทของไอเทมที่รวมอยู่ในรางวัล (เช่น "เหรียญ")
|
- ดูเพิ่มเติม
amount
-
amount: number
-
จำนวนไอเทมที่รวมอยู่ในรางวัล
-
type
-
type: string
-
ประเภทของไอเทมที่รวมอยู่ในรางวัล (เช่น "เหรียญ")
-
googletagSafeFrameConfig
ออบเจ็กต์การกำหนดค่าสำหรับคอนเทนเนอร์ SafeFrame
สรุปพร็อพเพอร์ตี้ | |
---|---|
allowOverlayExpansion
|
SafeFrame ควรอนุญาตให้เนื้อหาโฆษณาขยายโดยวางซ้อนเนื้อหาในหน้าหรือไม่
|
allowPushExpansion
|
SafeFrame ควรอนุญาตให้เนื้อหาโฆษณาขยายโดยการพุชเนื้อหาของหน้าหรือไม่
|
sandbox
|
SafeFrame ควรใช้แอตทริบิวต์แซนด์บ็อกซ์ HTML5 เพื่อป้องกันการนำทางระดับบนสุดโดยไม่มีการโต้ตอบของผู้ใช้หรือไม่
|
useUniqueDomain
|
เลิกใช้งานแล้ว
SafeFrame ควรใช้โดเมนย่อยแบบสุ่มสำหรับครีเอทีฟโฆษณาแบบจองหรือไม่
|
- ดูเพิ่มเติม
allowOverlayExpansion
-
allowOverlayExpansion: boolean
-
SafeFrame ควรอนุญาตให้เนื้อหาโฆษณาขยายโดยวางซ้อนเนื้อหาในหน้าหรือไม่
-
allowPushExpansion
-
allowPushExpansion: boolean
-
SafeFrame ควรอนุญาตให้เนื้อหาโฆษณาขยายโดยการพุชเนื้อหาของหน้าหรือไม่
-
sandbox
-
sandbox: boolean
-
SafeFrame ควรใช้แอตทริบิวต์แซนด์บ็อกซ์ HTML5 เพื่อป้องกันการนำทางระดับบนสุดโดยไม่มีการโต้ตอบของผู้ใช้หรือไม่ ค่าที่ใช้ได้ค่าเดียวคือ
true
(ไม่สามารถบังคับให้เป็นfalse
) โปรดทราบว่าแอตทริบิวต์แซนด์บ็อกซ์จะปิดใช้ปลั๊กอิน (เช่น Flash) -
useUniqueDomain
-
useUniqueDomain: null | boolean
-
SafeFrame ควรใช้โดเมนย่อยแบบสุ่มสำหรับครีเอทีฟโฆษณาแบบจองหรือไม่ ส่งให้
null
เพื่อล้างค่าที่จัดเก็บไว้
หมายเหตุ: ฟีเจอร์นี้จะเปิดใช้โดยค่าเริ่มต้น -
- ดูเพิ่มเติม
googletagService
คลาสบริการพื้นฐานซึ่งมีวิธีการที่ใช้บ่อยสำหรับบริการทั้งหมด
ข้อมูลสรุปของเมธอด | |
---|---|
addEventListener
|
บันทึกผู้ฟังที่อนุญาตให้คุณตั้งค่าและเรียกฟังก์ชัน JavaScript เมื่อเกิดเหตุการณ์ GPT หนึ่งขึ้นในหน้า
|
getSlots
|
รับรายการของช่องที่เชื่อมโยงกับบริการนี้
|
removeEventListener
|
นำ Listener ที่ลงทะเบียนก่อนหน้านี้ออก
|
addEventListener
-
addEventListener<K extends keyof EventTypeMap>(eventType: K, listener: (arg: EventTypeMap[K]) => void): Service
-
บันทึกผู้ฟังที่อนุญาตให้คุณตั้งค่าและเรียกฟังก์ชัน JavaScript เมื่อเกิดเหตุการณ์ GPT หนึ่งขึ้นในหน้า เหตุการณ์ที่รองรับมีดังนี้
ระบบจะส่งออบเจ็กต์ของประเภทเหตุการณ์ที่เหมาะสมไปยัง Listener เมื่อมีการเรียกใช้ -
- ตัวอย่าง
-
JavaScript
// 1. Adding an event listener for the PubAdsService. googletag.pubads().addEventListener("slotOnload", (event) => { console.log("Slot has been loaded:"); console.log(event); }); // 2. Adding an event listener with slot specific logic. // Listeners operate at service level, which means that you cannot add // a listener for an event for a specific slot only. You can, however, // programmatically filter a listener to respond only to a certain ad // slot, using this pattern: const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotOnload", (event) => { if (event.slot === targetSlot) { // Slot specific logic. } });
JavaScript (เดิม)
// 1. Adding an event listener for the PubAdsService. googletag.pubads().addEventListener("slotOnload", function (event) { console.log("Slot has been loaded:"); console.log(event); }); // 2. Adding an event listener with slot specific logic. // Listeners operate at service level, which means that you cannot add // a listener for an event for a specific slot only. You can, however, // programmatically filter a listener to respond only to a certain ad // slot, using this pattern: var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotOnload", function (event) { if (event.slot === targetSlot) { // Slot specific logic. } });
TypeScript
// 1. Adding an event listener for the PubAdsService. googletag.pubads().addEventListener("slotOnload", (event) => { console.log("Slot has been loaded:"); console.log(event); }); // 2. Adding an event listener with slot specific logic. // Listeners operate at service level, which means that you cannot add // a listener for an event for a specific slot only. You can, however, // programmatically filter a listener to respond only to a certain ad // slot, using this pattern: const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotOnload", (event) => { if (event.slot === targetSlot) { // Slot specific logic. } });
- ดูเพิ่มเติม
-
พารามิเตอร์ eventType: K
สตริงที่แสดงประเภทของเหตุการณ์ที่ GPT สร้างขึ้น ประเภทเหตุการณ์จะคำนึงถึงตัวพิมพ์เล็กและตัวพิมพ์ใหญ่listener: (arg: EventTypeMap[K]) => void
ฟังก์ชันที่ใช้อาร์กิวเมนต์ออบเจ็กต์เหตุการณ์เดียว -
การคืนสินค้า Service
ออบเจ็กต์บริการที่มีการเรียกใช้เมธอด
getSlots
removeEventListener
-
removeEventListener<K extends keyof EventTypeMap>(eventType: K, listener: (event: EventTypeMap[K]) => void): void
-
นำ Listener ที่ลงทะเบียนก่อนหน้านี้ออก
-
- ตัวอย่าง
-
JavaScript
googletag.cmd.push(() => { // Define a new ad slot. googletag.defineSlot("/6355419/Travel", [728, 90], "div-for-slot").addService(googletag.pubads()); // Define a new function that removes itself via removeEventListener // after the impressionViewable event fires. const onViewableListener = (event) => { googletag.pubads().removeEventListener("impressionViewable", onViewableListener); setTimeout(() => { googletag.pubads().refresh([event.slot]); }, 30000); }; // Add onViewableListener as a listener for impressionViewable events. googletag.pubads().addEventListener("impressionViewable", onViewableListener); googletag.enableServices(); });
JavaScript (เดิม)
googletag.cmd.push(function () { // Define a new ad slot. googletag.defineSlot("/6355419/Travel", [728, 90], "div-for-slot").addService(googletag.pubads()); // Define a new function that removes itself via removeEventListener // after the impressionViewable event fires. var onViewableListener = function (event) { googletag.pubads().removeEventListener("impressionViewable", onViewableListener); setTimeout(function () { googletag.pubads().refresh([event.slot]); }, 30000); }; // Add onViewableListener as a listener for impressionViewable events. googletag.pubads().addEventListener("impressionViewable", onViewableListener); googletag.enableServices(); });
TypeScript
googletag.cmd.push(() => { // Define a new ad slot. googletag .defineSlot("/6355419/Travel", [728, 90], "div-for-slot")! .addService(googletag.pubads()); // Define a new function that removes itself via removeEventListener // after the impressionViewable event fires. const onViewableListener = (event: googletag.events.ImpressionViewableEvent) => { googletag.pubads().removeEventListener("impressionViewable", onViewableListener); setTimeout(() => { googletag.pubads().refresh([event.slot]); }, 30000); }; // Add onViewableListener as a listener for impressionViewable events. googletag.pubads().addEventListener("impressionViewable", onViewableListener); googletag.enableServices(); });
-
พารามิเตอร์ eventType: K
สตริงที่แสดงประเภทของเหตุการณ์ที่ GPT สร้างขึ้น ประเภทเหตุการณ์จะคำนึงถึงตัวพิมพ์เล็กและตัวพิมพ์ใหญ่listener: (event: EventTypeMap[K]) => void
ฟังก์ชันที่ใช้อาร์กิวเมนต์ออบเจ็กต์เหตุการณ์เดียว
googletagSizeMappingBuilder
เครื่องมือสร้างสำหรับออบเจ็กต์ข้อกำหนดการแมปขนาด เครื่องมือสร้างนี้มีไว้เพื่อช่วยให้สร้างข้อกำหนดเกี่ยวกับขนาดได้อย่างง่ายดาย
ข้อมูลสรุปของเมธอด | |
---|---|
addSize
|
เพิ่มการแมปจากอาร์เรย์ขนาดเดียว (แทนวิวพอร์ต) ไปยังอาร์เรย์ขนาดเดียวหรือหลายขนาดที่แทนช่องโฆษณา
|
build
|
สร้างข้อกำหนดเฉพาะของการแมปขนาดจากการแมปที่เพิ่มลงในเครื่องมือสร้างนี้
|
- ดูเพิ่มเติม
addSize
-
addSize(viewportSize: SingleSizeArray, slotSize: GeneralSize): SizeMappingBuilder
-
เพิ่มการแมปจากอาร์เรย์ขนาดเดียว (แทนวิวพอร์ต) ไปยังอาร์เรย์ขนาดเดียวหรือหลายขนาดที่แทนช่องโฆษณา
-
- ตัวอย่าง
-
JavaScript
// Mapping 1 googletag .sizeMapping() .addSize([1024, 768], [970, 250]) .addSize([980, 690], [728, 90]) .addSize([640, 480], "fluid") .addSize([0, 0], [88, 31]) // All viewports < 640x480 .build(); // Mapping 2 googletag .sizeMapping() .addSize([1024, 768], [970, 250]) .addSize([980, 690], []) .addSize([640, 480], [120, 60]) .addSize([0, 0], []) .build(); // Mapping 2 will not show any ads for the following viewport sizes: // [1024, 768] > size >= [980, 690] and // [640, 480] > size >= [0, 0]
JavaScript (เดิม)
// Mapping 1 googletag .sizeMapping() .addSize([1024, 768], [970, 250]) .addSize([980, 690], [728, 90]) .addSize([640, 480], "fluid") .addSize([0, 0], [88, 31]) // All viewports < 640x480 .build(); // Mapping 2 googletag .sizeMapping() .addSize([1024, 768], [970, 250]) .addSize([980, 690], []) .addSize([640, 480], [120, 60]) .addSize([0, 0], []) .build(); // Mapping 2 will not show any ads for the following viewport sizes: // [1024, 768] > size >= [980, 690] and // [640, 480] > size >= [0, 0]
TypeScript
// Mapping 1 googletag .sizeMapping() .addSize([1024, 768], [970, 250]) .addSize([980, 690], [728, 90]) .addSize([640, 480], "fluid") .addSize([0, 0], [88, 31]) // All viewports < 640x480 .build(); // Mapping 2 googletag .sizeMapping() .addSize([1024, 768], [970, 250]) .addSize([980, 690], []) .addSize([640, 480], [120, 60]) .addSize([0, 0], []) .build(); // Mapping 2 will not show any ads for the following viewport sizes: // [1024, 768] > size >= [980, 690] and // [640, 480] > size >= [0, 0]
-
พารามิเตอร์ viewportSize: SingleSizeArray
ขนาดของวิวพอร์ตสำหรับรายการการแมปนี้slotSize: GeneralSize
ขนาดของสล็อตสำหรับรายการการแมปนี้ -
การคืนสินค้า SizeMappingBuilder
การอ้างอิงถึงเครื่องมือสร้างนี้
build
-
build(): null | SizeMappingArray
-
สร้างข้อกำหนดเฉพาะของการแมปขนาดจากการแมปที่เพิ่มลงในเครื่องมือสร้างนี้
หากมีการระบุการแมปที่ไม่ถูกต้อง วิธีนี้จะแสดงผลnull
มิเช่นนั้น จะแสดงข้อกำหนดในรูปแบบที่ถูกต้องเพื่อส่งไปยังSlot.defineSizeMapping
หมายเหตุ: ไม่มีการระบุลักษณะการทำงานของเครื่องมือสร้างหลังจากเรียกใช้เมธอดนี้ -
-
การคืนสินค้า null | SizeMappingArray
ผลลัพธ์ที่สร้างโดยเครื่องมือสร้างนี้ อาจเป็นค่าว่างหากการแมปขนาดไม่ถูกต้อง
googletagSlot
ช่องโฆษณาเป็นออบเจ็กต์ที่แสดงช่องโฆษณาเดี่ยวในหน้าเว็บ
ข้อมูลสรุปของเมธอด | |
---|---|
addService
|
เพิ่ม
Service ลงในช่องนี้
|
clearCategoryExclusions
|
ล้างป้ายกำกับการยกเว้นหมวดหมู่โฆษณาระดับช่องทั้งหมดสำหรับช่องนี้
|
clearTargeting
|
ล้างพารามิเตอร์การกำหนดเป้าหมายระดับช่องที่เฉพาะเจาะจงหรือที่กำหนดเองทั้งหมดสำหรับช่องนี้
|
defineSizeMapping
|
ตั้งค่าอาร์เรย์ของการแมปจากขนาดวิวพอร์ตขั้นต่ำเป็นขนาดช่องโฆษณาสำหรับช่องโฆษณานี้
|
get
|
แสดงผลค่าสำหรับแอตทริบิวต์ AdSense ที่เชื่อมโยงกับคีย์ที่ระบุสำหรับช่องนี้
|
getAdUnitPath
|
แสดงเส้นทางแบบเต็มของหน่วยโฆษณา พร้อมรหัสเครือข่ายและเส้นทางของหน่วยโฆษณา
|
getAttributeKeys
|
แสดงรายการคีย์แอตทริบิวต์ที่ตั้งค่าไว้ในช่องนี้
|
getCategoryExclusions
|
แสดงป้ายกำกับการยกเว้นหมวดหมู่โฆษณาสำหรับช่องนี้
|
getResponseInformation
|
แสดงข้อมูลการตอบกลับโฆษณา
|
getSlotElementId
|
แสดงผลรหัสของช่อง
div ที่ระบุไว้เมื่อกำหนดช่องโฆษณาแล้ว
|
getTargeting
|
แสดงผลพารามิเตอร์การกำหนดเป้าหมายเองที่เจาะจงซึ่งตั้งค่าลงในช่องนี้
|
getTargetingKeys
|
แสดงรายการคีย์การกำหนดเป้าหมายเองทั้งหมดที่ตั้งค่าไว้ในช่องนี้
|
set
|
ตั้งค่าสำหรับแอตทริบิวต์ AdSense ในช่องโฆษณานี้
|
setCategoryExclusion
|
ตั้งค่าป้ายกำกับการยกเว้นหมวดหมู่โฆษณาระดับช่องในช่องนี้
|
setClickUrl
|
ตั้งค่า URL การคลิกที่จะเปลี่ยนเส้นทางผู้ใช้ไปหลังจากคลิกที่โฆษณา
|
setCollapseEmptyDiv
|
ตั้งค่าว่าควรซ่อนช่อง
div หรือไม่ เมื่อไม่มีโฆษณาในช่อง
|
setConfig
|
ตั้งค่าตัวเลือกการกำหนดค่าทั่วไปสำหรับช่องนี้
|
setForceSafeFrame
|
กำหนดค่าว่าจะบังคับให้โฆษณาในช่องนี้แสดงผลโดยใช้คอนเทนเนอร์ SafeFrame หรือไม่
|
setSafeFrameConfig
|
ตั้งค่ากำหนดระดับช่องสำหรับการกำหนดค่า SafeFrame
|
setTargeting
|
ตั้งค่าพารามิเตอร์การกำหนดเป้าหมายเองสำหรับช่องนี้
|
updateTargetingFromMap
|
ตั้งค่าพารามิเตอร์การกำหนดเป้าหมายเองสำหรับช่องนี้จากแมปคีย์:ค่าในออบเจ็กต์ JSON
|
addService
-
เพิ่ม
Service
ลงในช่องนี้ -
- ตัวอย่าง
-
JavaScript
googletag.defineSlot("/1234567/sports", [160, 600], "div").addService(googletag.pubads());
JavaScript (เดิม)
googletag.defineSlot("/1234567/sports", [160, 600], "div").addService(googletag.pubads());
TypeScript
googletag.defineSlot("/1234567/sports", [160, 600], "div")!.addService(googletag.pubads());
- ดูเพิ่มเติม
-
พารามิเตอร์ service: Service
บริการที่จะเพิ่ม -
การคืนสินค้า Slot
ออบเจ็กต์ช่องที่เรียกใช้เมธอด
clearCategoryExclusions
-
clearCategoryExclusions(): Slot
-
ล้างป้ายกำกับการยกเว้นหมวดหมู่โฆษณาระดับช่องทั้งหมดสำหรับช่องนี้
-
- ตัวอย่าง
-
JavaScript
// Set category exclusion to exclude ads with 'AirlineAd' labels. const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setCategoryExclusion("AirlineAd") .addService(googletag.pubads()); // Make an ad request. No ad with 'AirlineAd' label will be returned // for the slot. // Clear category exclusions so all ads can be returned. slot.clearCategoryExclusions(); // Make an ad request. Any ad can be returned for the slot.
JavaScript (เดิม)
// Set category exclusion to exclude ads with 'AirlineAd' labels. var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setCategoryExclusion("AirlineAd") .addService(googletag.pubads()); // Make an ad request. No ad with 'AirlineAd' label will be returned // for the slot. // Clear category exclusions so all ads can be returned. slot.clearCategoryExclusions(); // Make an ad request. Any ad can be returned for the slot.
TypeScript
// Set category exclusion to exclude ads with 'AirlineAd' labels. const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setCategoryExclusion("AirlineAd") .addService(googletag.pubads()); // Make an ad request. No ad with 'AirlineAd' label will be returned // for the slot. // Clear category exclusions so all ads can be returned. slot.clearCategoryExclusions(); // Make an ad request. Any ad can be returned for the slot.
-
การคืนสินค้า Slot
ออบเจ็กต์ช่องที่เรียกใช้เมธอด
clearTargeting
-
clearTargeting(key?: string): Slot
-
ล้างพารามิเตอร์การกำหนดเป้าหมายระดับช่องที่เฉพาะเจาะจงหรือที่กำหนดเองทั้งหมดสำหรับช่องนี้
-
- ตัวอย่าง
-
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setTargeting("allow_expandable", "true") .setTargeting("interests", ["sports", "music"]) .setTargeting("color", "red") .addService(googletag.pubads()); slot.clearTargeting("color"); // Targeting 'allow_expandable' and 'interests' are still present, // while 'color' was cleared. slot.clearTargeting(); // All targeting has been cleared.
JavaScript (เดิม)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setTargeting("allow_expandable", "true") .setTargeting("interests", ["sports", "music"]) .setTargeting("color", "red") .addService(googletag.pubads()); slot.clearTargeting("color"); // Targeting 'allow_expandable' and 'interests' are still present, // while 'color' was cleared. slot.clearTargeting(); // All targeting has been cleared.
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setTargeting("allow_expandable", "true") .setTargeting("interests", ["sports", "music"]) .setTargeting("color", "red") .addService(googletag.pubads()); slot.clearTargeting("color"); // Targeting 'allow_expandable' and 'interests' are still present, // while 'color' was cleared. slot.clearTargeting(); // All targeting has been cleared.
- ดูเพิ่มเติม
-
พารามิเตอร์ key?: string
คีย์พารามิเตอร์การกำหนดเป้าหมาย คีย์เป็นตัวเลือกที่ไม่บังคับ ระบบจะล้างพารามิเตอร์การกำหนดเป้าหมายทั้งหมดหากไม่ได้ระบุ -
การคืนสินค้า Slot
ออบเจ็กต์ช่องที่เรียกใช้เมธอด
defineSizeMapping
-
defineSizeMapping(sizeMapping: SizeMappingArray): Slot
-
ตั้งค่าอาร์เรย์ของการแมปจากขนาดวิวพอร์ตขั้นต่ำเป็นขนาดช่องโฆษณาสำหรับช่องโฆษณานี้
-
- ตัวอย่าง
-
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); const mapping = googletag .sizeMapping() .addSize([100, 100], [88, 31]) .addSize( [320, 400], [ [320, 50], [300, 50], ] ) .build(); slot.defineSizeMapping(mapping);
JavaScript (เดิม)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); var mapping = googletag .sizeMapping() .addSize([100, 100], [88, 31]) .addSize( [320, 400], [ [320, 50], [300, 50], ] ) .build(); slot.defineSizeMapping(mapping);
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); const mapping = googletag .sizeMapping() .addSize([100, 100], [88, 31]) .addSize( [320, 400], [ [320, 50], [300, 50], ] ) .build(); slot.defineSizeMapping(mapping!);
- ดูเพิ่มเติม
-
พารามิเตอร์ sizeMapping: SizeMappingArray
อาร์เรย์ของการแมปขนาด คุณสามารถใช้SizeMappingBuilder
เพื่อสร้างได้ การแมปขนาดแต่ละรายการจะเป็นอาร์เรย์ขององค์ประกอบ 2 รายการ ได้แก่SingleSizeArray
และGeneralSize
-
การคืนสินค้า Slot
ออบเจ็กต์ช่องที่เรียกใช้เมธอด
get
-
get(key: string): null | string
-
แสดงผลค่าสำหรับแอตทริบิวต์ AdSense ที่เชื่อมโยงกับคีย์ที่ระบุสำหรับช่องนี้ หากต้องการดูแอตทริบิวต์ระดับบริการที่รับค่ามาจากช่องนี้ ให้ใช้
PubAdsService.get
-
- ตัวอย่าง
-
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .set("adsense_background_color", "#FFFFFF") .addService(googletag.pubads()); slot.get("adsense_background_color"); // Returns '#FFFFFF'.
JavaScript (เดิม)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .set("adsense_background_color", "#FFFFFF") .addService(googletag.pubads()); slot.get("adsense_background_color"); // Returns '#FFFFFF'.
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .set("adsense_background_color", "#FFFFFF") .addService(googletag.pubads()); slot.get("adsense_background_color"); // Returns '#FFFFFF'.
- ดูเพิ่มเติม
-
พารามิเตอร์ key: string
ชื่อของแอตทริบิวต์ที่จะค้นหา -
การคืนสินค้า null | string
ค่าปัจจุบันสำหรับคีย์แอตทริบิวต์ หรือnull
หากไม่มีคีย์
getAdUnitPath
-
getAdUnitPath(): string
-
แสดงเส้นทางแบบเต็มของหน่วยโฆษณา พร้อมรหัสเครือข่ายและเส้นทางของหน่วยโฆษณา
-
- ตัวอย่าง
-
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); slot.getAdUnitPath(); // Returns '/1234567/sports'.
JavaScript (เดิม)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); slot.getAdUnitPath(); // Returns '/1234567/sports'.
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); slot.getAdUnitPath(); // Returns '/1234567/sports'.
-
การคืนสินค้า string
เส้นทางหน่วยโฆษณา
getAttributeKeys
-
getAttributeKeys(): string[]
-
แสดงรายการคีย์แอตทริบิวต์ที่ตั้งค่าไว้ในช่องนี้ หากต้องการดูคีย์ของแอตทริบิวต์ระดับการให้บริการที่รับช่วงมาจากช่องนี้ ให้ใช้
PubAdsService.getAttributeKeys
-
- ตัวอย่าง
-
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .set("adsense_background_color", "#FFFFFF") .set("adsense_border_color", "#AABBCC") .addService(googletag.pubads()); slot.getAttributeKeys(); // Returns ['adsense_background_color', 'adsense_border_color'].
JavaScript (เดิม)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .set("adsense_background_color", "#FFFFFF") .set("adsense_border_color", "#AABBCC") .addService(googletag.pubads()); slot.getAttributeKeys(); // Returns ['adsense_background_color', 'adsense_border_color'].
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .set("adsense_background_color", "#FFFFFF") .set("adsense_border_color", "#AABBCC") .addService(googletag.pubads()); slot.getAttributeKeys(); // Returns ['adsense_background_color', 'adsense_border_color'].
-
การคืนสินค้า string[]
อาร์เรย์ของคีย์แอตทริบิวต์ ไม่ได้ระบุการเรียงลำดับ
getCategoryExclusions
-
getCategoryExclusions(): string[]
-
แสดงป้ายกำกับการยกเว้นหมวดหมู่โฆษณาสำหรับช่องนี้
-
- ตัวอย่าง
-
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setCategoryExclusion("AirlineAd") .setCategoryExclusion("TrainAd") .addService(googletag.pubads()); slot.getCategoryExclusions(); // Returns ['AirlineAd', 'TrainAd'].
JavaScript (เดิม)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setCategoryExclusion("AirlineAd") .setCategoryExclusion("TrainAd") .addService(googletag.pubads()); slot.getCategoryExclusions(); // Returns ['AirlineAd', 'TrainAd'].
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setCategoryExclusion("AirlineAd") .setCategoryExclusion("TrainAd") .addService(googletag.pubads()); slot.getCategoryExclusions(); // Returns ['AirlineAd', 'TrainAd'].
-
การคืนสินค้า string[]
ป้ายกำกับการยกเว้นหมวดหมู่โฆษณาสำหรับช่องโฆษณานี้ หรืออาร์เรย์ที่ว่างเปล่าหากไม่ได้ตั้งค่าไว้
getResponseInformation
-
getResponseInformation(): null | ResponseInformation
-
แสดงข้อมูลการตอบกลับโฆษณา โดยอิงจากการตอบกลับโฆษณาล่าสุดสำหรับช่องโฆษณา หากมีการเรียกเมื่อช่องโฆษณาไม่มีโฆษณา ระบบจะแสดงผล
null
-
-
การคืนสินค้า null | ResponseInformation
ข้อมูลการตอบกลับโฆษณาล่าสุด หรือnull
หากช่องโฆษณาไม่มีโฆษณา
getSlotElementId
-
getSlotElementId(): string
-
แสดงผลรหัสของช่อง
div
ที่ระบุไว้เมื่อกำหนดช่องโฆษณาแล้ว -
- ตัวอย่าง
-
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); slot.getSlotElementId(); // Returns 'div-1'.
JavaScript (เดิม)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); slot.getSlotElementId(); // Returns 'div-1'.
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); slot.getSlotElementId(); // Returns 'div-1'.
-
การคืนสินค้า string
รหัสช่องdiv
getTargeting
-
getTargeting(key: string): string[]
-
แสดงผลพารามิเตอร์การกำหนดเป้าหมายเองที่เจาะจงซึ่งตั้งค่าลงในช่องนี้ ไม่รวมพารามิเตอร์การกำหนดเป้าหมายระดับบริการ
-
- ตัวอย่าง
-
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setTargeting("allow_expandable", "true") .addService(googletag.pubads()); slot.getTargeting("allow_expandable"); // Returns ['true']. slot.getTargeting("age"); // Returns [] (empty array).
JavaScript (เดิม)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setTargeting("allow_expandable", "true") .addService(googletag.pubads()); slot.getTargeting("allow_expandable"); // Returns ['true']. slot.getTargeting("age"); // Returns [] (empty array).
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setTargeting("allow_expandable", "true") .addService(googletag.pubads()); slot.getTargeting("allow_expandable"); // Returns ['true']. slot.getTargeting("age"); // Returns [] (empty array).
-
พารามิเตอร์ key: string
คีย์การกำหนดเป้าหมายที่จะค้นหา -
การคืนสินค้า string[]
ค่าที่เชื่อมโยงกับคีย์นี้ หรืออาร์เรย์ว่างเปล่าหากไม่มีคีย์ดังกล่าว
getTargetingKeys
-
getTargetingKeys(): string[]
-
แสดงรายการคีย์การกำหนดเป้าหมายเองทั้งหมดที่ตั้งค่าไว้ในช่องนี้ ไม่รวมคีย์การกำหนดเป้าหมายระดับบริการ
-
- ตัวอย่าง
-
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setTargeting("allow_expandable", "true") .setTargeting("interests", ["sports", "music"]) .addService(googletag.pubads()); slot.getTargetingKeys(); // Returns ['interests', 'allow_expandable'].
JavaScript (เดิม)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .setTargeting("allow_expandable", "true") .setTargeting("interests", ["sports", "music"]) .addService(googletag.pubads()); slot.getTargetingKeys(); // Returns ['interests', 'allow_expandable'].
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setTargeting("allow_expandable", "true") .setTargeting("interests", ["sports", "music"]) .addService(googletag.pubads()); slot.getTargetingKeys(); // Returns ['interests', 'allow_expandable'].
-
การคืนสินค้า string[]
อาร์เรย์ของคีย์การกำหนดเป้าหมาย ไม่ได้ระบุการเรียงลำดับ
set
-
set(key: string, value: string): Slot
-
ตั้งค่าสำหรับแอตทริบิวต์ AdSense ในช่องโฆษณานี้ การดำเนินการนี้จะลบล้างค่าใดๆ ก็ตามที่กำหนดที่ระดับบริการสำหรับคีย์นี้
การเรียกใช้วิธีนี้มากกว่า 1 ครั้งสำหรับคีย์เดียวกันจะลบล้างค่าที่กำหนดไว้ก่อนหน้านี้สำหรับคีย์ดังกล่าว ทุกค่าต้องตั้งค่าก่อนเรียกใช้display
หรือrefresh
-
- ตัวอย่าง
-
JavaScript
// Setting an attribute on a single ad slot. googletag .defineSlot("/1234567/sports", [160, 600], "div") .set("adsense_background_color", "#FFFFFF") .addService(googletag.pubads());
JavaScript (เดิม)
// Setting an attribute on a single ad slot. googletag .defineSlot("/1234567/sports", [160, 600], "div") .set("adsense_background_color", "#FFFFFF") .addService(googletag.pubads());
TypeScript
// Setting an attribute on a single ad slot. googletag .defineSlot("/1234567/sports", [160, 600], "div")! .set("adsense_background_color", "#FFFFFF") .addService(googletag.pubads());
- ดูเพิ่มเติม
-
พารามิเตอร์ key: string
ชื่อของแอตทริบิวต์value: string
ค่าแอตทริบิวต์ -
การคืนสินค้า Slot
ออบเจ็กต์ช่องที่เรียกใช้เมธอด
setCategoryExclusion
-
setCategoryExclusion(categoryExclusion: string): Slot
-
ตั้งค่าป้ายกำกับการยกเว้นหมวดหมู่โฆษณาระดับช่องในช่องนี้
-
- ตัวอย่าง
-
JavaScript
// Label = AirlineAd googletag .defineSlot("/1234567/sports", [160, 600], "div") .setCategoryExclusion("AirlineAd") .addService(googletag.pubads());
JavaScript (เดิม)
// Label = AirlineAd googletag .defineSlot("/1234567/sports", [160, 600], "div") .setCategoryExclusion("AirlineAd") .addService(googletag.pubads());
TypeScript
// Label = AirlineAd googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setCategoryExclusion("AirlineAd") .addService(googletag.pubads());
- ดูเพิ่มเติม
-
พารามิเตอร์ categoryExclusion: string
ป้ายกำกับการยกเว้นหมวดหมู่โฆษณาที่จะเพิ่ม -
การคืนสินค้า Slot
ออบเจ็กต์ช่องที่เรียกใช้เมธอด
setClickUrl
-
setClickUrl(value: string): Slot
-
ตั้งค่า URL การคลิกที่จะเปลี่ยนเส้นทางผู้ใช้ไปหลังจากที่คลิกโฆษณา
เซิร์ฟเวอร์ Google Ad Manager จะยังคงบันทึกการคลิก แม้ว่าจะมีการแทนที่ URL การคลิกแล้วก็ตาม URL ของหน้า Landing Page ใดๆ ที่เชื่อมโยงกับครีเอทีฟโฆษณาที่แสดงจะต่อท้ายค่าที่ระบุ การโทรครั้งต่อๆ ไปจะเขียนทับค่า ซึ่งจะใช้ได้กับคำขอที่ไม่ใช่ SRA เท่านั้น -
- ตัวอย่าง
-
JavaScript
googletag .defineSlot("/1234567/sports", [160, 600], "div") .setClickUrl("http://www.example.com?original_click_url=") .addService(googletag.pubads());
JavaScript (เดิม)
googletag .defineSlot("/1234567/sports", [160, 600], "div") .setClickUrl("http://www.example.com?original_click_url=") .addService(googletag.pubads());
TypeScript
googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setClickUrl("http://www.example.com?original_click_url=") .addService(googletag.pubads());
-
พารามิเตอร์ value: string
URL สำหรับคลิกที่จะตั้งค่า -
การคืนสินค้า Slot
ออบเจ็กต์ช่องที่เรียกใช้เมธอด
setCollapseEmptyDiv
-
setCollapseEmptyDiv(collapse: boolean, collapseBeforeAdFetch?: boolean): Slot
-
ตั้งค่าว่าควรซ่อนช่อง
div
หรือไม่ เมื่อไม่มีโฆษณาในช่อง การดำเนินการนี้จะลบล้างการตั้งค่าระดับบริการ -
- ตัวอย่าง
-
JavaScript
googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setCollapseEmptyDiv(true, true) .addService(googletag.pubads()); // The above will cause the div for this slot to be collapsed // when the page is loaded, before ads are requested. googletag .defineSlot("/1234567/sports", [160, 600], "div-2") .setCollapseEmptyDiv(true) .addService(googletag.pubads()); // The above will cause the div for this slot to be collapsed // only after GPT detects that no ads are available for the slot.
JavaScript (เดิม)
googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setCollapseEmptyDiv(true, true) .addService(googletag.pubads()); // The above will cause the div for this slot to be collapsed // when the page is loaded, before ads are requested. googletag .defineSlot("/1234567/sports", [160, 600], "div-2") .setCollapseEmptyDiv(true) .addService(googletag.pubads()); // The above will cause the div for this slot to be collapsed // only after GPT detects that no ads are available for the slot.
TypeScript
googletag .defineSlot("/1234567/sports", [160, 600], "div-1")! .setCollapseEmptyDiv(true, true) .addService(googletag.pubads()); // The above will cause the div for this slot to be collapsed // when the page is loaded, before ads are requested. googletag .defineSlot("/1234567/sports", [160, 600], "div-2")! .setCollapseEmptyDiv(true) .addService(googletag.pubads()); // The above will cause the div for this slot to be collapsed // only after GPT detects that no ads are available for the slot.
- ดูเพิ่มเติม
-
พารามิเตอร์ collapse: boolean
จะยุบช่องโฆษณาไหมหากไม่มีการแสดงโฆษณาcollapseBeforeAdFetch?: boolean
เลือกว่าจะยุบช่องโฆษณาก่อนที่จะดึงโฆษณาหรือไม่ ละเว้นหากการยุบไม่ใช่true
-
การคืนสินค้า Slot
ออบเจ็กต์ช่องที่เรียกใช้เมธอด
setConfig
-
setConfig(slotConfig: SlotSettingsConfig): void
-
ตั้งค่าตัวเลือกการกำหนดค่าทั่วไปสำหรับช่องนี้
-
-
พารามิเตอร์ slotConfig: SlotSettingsConfig
ออบเจ็กต์การกำหนดค่า
setForceSafeFrame
-
setForceSafeFrame(forceSafeFrame: boolean): Slot
-
กำหนดค่าว่าจะบังคับให้แสดงผลโฆษณาในช่องนี้โดยใช้คอนเทนเนอร์ SafeFrame หรือไม่
โปรดคำนึงถึงสิ่งต่อไปนี้ขณะใช้ API นี้- การตั้งค่านี้จะมีผลกับคำขอโฆษณาที่ตามมาสำหรับช่องที่เกี่ยวข้องเท่านั้น
- การตั้งค่าระดับช่อง (หากระบุไว้) จะลบล้างการตั้งค่าระดับหน้าเว็บเสมอ
- หากตั้งค่าเป็น
true
(ที่ระดับช่องโฆษณาหรือระดับหน้า) โฆษณาจะแสดงผลโดยใช้คอนเทนเนอร์ SafeFrame เสมอโดยไม่ขึ้นกับตัวเลือกที่กำหนดใน UI ของ Google Ad Manager - อย่างไรก็ตาม หากตั้งค่าเป็น
false
หรือไม่ได้ระบุ โฆษณาจะแสดงผลโดยใช้คอนเทนเนอร์ SafeFrame โดยขึ้นอยู่กับประเภทของครีเอทีฟโฆษณาและการเลือกใน UI ของ Google Ad Manager - คุณควรใช้ API นี้อย่างระมัดระวัง เนื่องจากอาจส่งผลต่อลักษณะการทำงานของครีเอทีฟโฆษณาที่พยายามแยก iframe หรือใช้งาน API ที่แสดงผลโดยตรงในหน้าผู้เผยแพร่โฆษณา
-
- ตัวอย่าง
-
JavaScript
googletag .defineSlot("/1234567/sports", [160, 600], "div") .setForceSafeFrame(true) .addService(googletag.pubads());
JavaScript (เดิม)
googletag .defineSlot("/1234567/sports", [160, 600], "div") .setForceSafeFrame(true) .addService(googletag.pubads());
TypeScript
googletag .defineSlot("/1234567/sports", [160, 600], "div")! .setForceSafeFrame(true) .addService(googletag.pubads());
- ดูเพิ่มเติม
-
พารามิเตอร์ forceSafeFrame: boolean
true
เพื่อบังคับให้โฆษณาทั้งหมดในช่องนี้แสดงผลใน SafeFrame และfalse
เพื่อเลือกไม่ใช้การตั้งค่าระดับหน้าเว็บ (หากมี) การตั้งค่านี้เป็นfalse
เมื่อไม่ได้ระบุที่ระดับหน้าเว็บจะไม่เปลี่ยนแปลงอะไร -
การคืนสินค้า Slot
ออบเจ็กต์ช่องที่เรียกใช้เมธอด
setSafeFrameConfig
-
setSafeFrameConfig(config: null | SafeFrameConfig): Slot
-
ตั้งค่ากำหนดระดับช่องสำหรับการกำหนดค่า SafeFrame ระบบจะไม่สนใจคีย์ที่ไม่รู้จักในออบเจ็กต์การกำหนดค่า ระบบจะไม่สนใจการกำหนดค่าทั้งหมดหากมีการส่งค่าที่ไม่ถูกต้องสำหรับคีย์ที่รู้จัก
ค่ากำหนดระดับช่องโฆษณาเหล่านี้ (หากระบุไว้) จะลบล้างค่ากำหนดระดับหน้าเว็บ -
- ตัวอย่าง
-
JavaScript
googletag.pubads().setForceSafeFrame(true); // The following slot will have a sandboxed safeframe that only // disallows top-level navigation. googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setSafeFrameConfig({ sandbox: true }) .addService(googletag.pubads()); // The following slot will inherit page-level settings. googletag.defineSlot("/1234567/news", [160, 600], "div-2").addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
JavaScript (เดิม)
googletag.pubads().setForceSafeFrame(true); // The following slot will have a sandboxed safeframe that only // disallows top-level navigation. googletag .defineSlot("/1234567/sports", [160, 600], "div-1") .setSafeFrameConfig({ sandbox: true }) .addService(googletag.pubads()); // The following slot will inherit page-level settings. googletag.defineSlot("/1234567/news", [160, 600], "div-2").addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
TypeScript
googletag.pubads().setForceSafeFrame(true); // The following slot will have a sandboxed safeframe that only // disallows top-level navigation. googletag .defineSlot("/1234567/sports", [160, 600], "div-1")! .setSafeFrameConfig({ sandbox: true }) .addService(googletag.pubads()); // The following slot will inherit page-level settings. googletag.defineSlot("/1234567/news", [160, 600], "div-2")!.addService(googletag.pubads()); googletag.display("div-1"); googletag.display("div-2");
- ดูเพิ่มเติม
-
พารามิเตอร์ config: null | SafeFrameConfig
ออบเจ็กต์การกำหนดค่า -
การคืนสินค้า Slot
ออบเจ็กต์ช่องที่เรียกใช้เมธอด
setTargeting
-
setTargeting(key: string, value: string | string[]): Slot
-
ตั้งค่าพารามิเตอร์การกำหนดเป้าหมายเองสำหรับช่องนี้ การเรียกใช้เมธอดนี้หลายครั้งสำหรับคีย์เดียวกันจะเขียนทับค่าเก่า ค่าที่ตั้งไว้ที่นี่จะเขียนทับพารามิเตอร์การกำหนดเป้าหมายที่ตั้งไว้ที่ระดับบริการ คีย์เหล่านี้ได้รับการกำหนดในบัญชี Google Ad Manager ของคุณ
-
- ตัวอย่าง
-
JavaScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Example with a single value for a key. slot.setTargeting("allow_expandable", "true"); // Example with multiple values for a key inside in an array. slot.setTargeting("interests", ["sports", "music"]);
JavaScript (เดิม)
var slot = googletag .defineSlot("/1234567/sports", [160, 600], "div") .addService(googletag.pubads()); // Example with a single value for a key. slot.setTargeting("allow_expandable", "true"); // Example with multiple values for a key inside in an array. slot.setTargeting("interests", ["sports", "music"]);
TypeScript
const slot = googletag .defineSlot("/1234567/sports", [160, 600], "div")! .addService(googletag.pubads()); // Example with a single value for a key. slot.setTargeting("allow_expandable", "true"); // Example with multiple values for a key inside in an array. slot.setTargeting("interests", ["sports", "music"]);
- ดูเพิ่มเติม
-
พารามิเตอร์ key: string
คีย์พารามิเตอร์การกำหนดเป้าหมายvalue: string | string[]
ค่าพารามิเตอร์หรืออาร์เรย์ของค่าการกำหนดเป้าหมาย -
การคืนสินค้า Slot
ออบเจ็กต์ช่องที่เรียกใช้เมธอด
updateTargetingFromMap
-
updateTargetingFromMap(map: { [adUnitPath: string]: string | string[] }): Slot
-
ตั้งค่าพารามิเตอร์การกำหนดเป้าหมายเองสำหรับช่องนี้จากแมปคีย์:ค่าในออบเจ็กต์ JSON ซึ่งจะเหมือนกับการเรียกใช้
Slot.setTargeting
สำหรับคีย์-ค่าทั้งหมดของออบเจ็กต์ คีย์เหล่านี้ได้รับการกำหนดไว้ในบัญชี Google Ad Manager ของคุณ
หมายเหตุ- ในกรณีที่เขียนทับ ระบบจะเก็บเฉพาะค่าสุดท้ายไว้เท่านั้น
- หากค่าเป็นอาร์เรย์ ระบบจะเขียนทับค่าก่อนหน้า โดยไม่ผสาน
- ค่าที่ตั้งไว้ที่นี่จะเขียนทับพารามิเตอร์การกำหนดเป้าหมายที่ตั้งไว้ที่ระดับบริการ
-
- ตัวอย่าง
-
JavaScript
const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div"); slot.updateTargetingFromMap({ color: "red", interests: ["sports", "music", "movies"], });
JavaScript (เดิม)
var slot = googletag.defineSlot("/1234567/sports", [160, 600], "div"); slot.updateTargetingFromMap({ color: "red", interests: ["sports", "music", "movies"], });
TypeScript
const slot = googletag.defineSlot("/1234567/sports", [160, 600], "div")!; slot.updateTargetingFromMap({ color: "red", interests: ["sports", "music", "movies"], });
-
พารามิเตอร์ map: { [adUnitPath: string]: string | string[] }
แมปคีย์:ค่าการกำหนดเป้าหมายของพารามิเตอร์ -
การคืนสินค้า Slot
ออบเจ็กต์ช่องที่เรียกใช้เมธอด
googletagconfigAdExpansionConfig
การตั้งค่าเพื่อควบคุมการขยายโฆษณา
สรุปพร็อพเพอร์ตี้ | |
---|---|
enabled
|
การขยายโฆษณาเปิดใช้หรือปิดใช้
|
- ตัวอย่าง
-
JavaScript
// Enable ad slot expansion across the entire page. googletag.setConfig({ adExpansion: { enabled: true }, });
JavaScript (เดิม)
// Enable ad slot expansion across the entire page. googletag.setConfig({ adExpansion: { enabled: true }, });
TypeScript
// Enable ad slot expansion across the entire page. googletag.setConfig({ adExpansion: { enabled: true }, });
enabled
-
enabled: boolean
-
ไม่ว่าจะเปิดใช้หรือปิดใช้การขยายโฆษณา
การตั้งค่านี้จะลบล้างค่าเริ่มต้นที่กำหนดค่าไว้ใน Google Ad Manager
googletagconfigComponentAuctionConfig
ออบเจ็กต์ที่แสดงการประมูลคอมโพเนนต์เดียวในการประมูลเพื่อแสดงโฆษณาในอุปกรณ์
สรุปพร็อพเพอร์ตี้ | |
---|---|
auctionConfig
|
ออบเจ็กต์การกำหนดค่าการประมูลสำหรับการประมูลคอมโพเนนต์นี้
|
configKey
|
คีย์การกำหนดค่าที่เชื่อมโยงกับการประมูลคอมโพเนนต์นี้
|
auctionConfig
-
auctionConfig: null | { auctionSignals: unknown, decisionLogicUrl: string, interestGroupBuyers: string[], perBuyerExperimentGroupIds: { [buyer: string]: number }, perBuyerGroupLimits: { [buyer: string]: number }, perBuyerSignals: { [buyer: string]: unknown }, perBuyerTimeouts: { [buyer: string]: number }, seller: string, sellerExperimentGroupId: number, sellerSignals: unknown, sellerTimeout: number, trustedScoringSignalsUrl: string }
-
ออบเจ็กต์การกำหนดค่าการประมูลสำหรับการประมูลคอมโพเนนต์นี้
หากตั้งค่านี้เป็นnull
ระบบจะลบการกำหนดค่าที่มีอยู่สำหรับconfigKey
ที่ระบุ -
- ตัวอย่าง
-
JavaScript
const componentAuctionConfig = { // Seller URL should be https and the same as decisionLogicUrl's origin seller: "https://testSeller.com", decisionLogicUrl: "https://testSeller.com/ssp/decision-logic.js", interestGroupBuyers: ["https://example-buyer.com"], auctionSignals: { auction_signals: "auction_signals" }, sellerSignals: { seller_signals: "seller_signals" }, perBuyerSignals: { // listed on interestGroupBuyers "https://example-buyer.com": { per_buyer_signals: "per_buyer_signals", }, }, }; const auctionSlot = googletag.defineSlot("/1234567/example", [160, 600]); // To add configKey to the component auction: auctionSlot.setConfig({ componentAuction: [ { configKey: "https://testSeller.com", auctionConfig: componentAuctionConfig, }, ], }); // To remove configKey from the component auction: auctionSlot.setConfig({ componentAuction: [ { configKey: "https://testSeller.com", auctionConfig: null, }, ], });
JavaScript (เดิม)
var componentAuctionConfig = { // Seller URL should be https and the same as decisionLogicUrl's origin seller: "https://testSeller.com", decisionLogicUrl: "https://testSeller.com/ssp/decision-logic.js", interestGroupBuyers: ["https://example-buyer.com"], auctionSignals: { auction_signals: "auction_signals" }, sellerSignals: { seller_signals: "seller_signals" }, perBuyerSignals: { // listed on interestGroupBuyers "https://example-buyer.com": { per_buyer_signals: "per_buyer_signals", }, }, }; var auctionSlot = googletag.defineSlot("/1234567/example", [160, 600]); // To add configKey to the component auction: auctionSlot.setConfig({ componentAuction: [ { configKey: "https://testSeller.com", auctionConfig: componentAuctionConfig, }, ], }); // To remove configKey from the component auction: auctionSlot.setConfig({ componentAuction: [ { configKey: "https://testSeller.com", auctionConfig: null, }, ], });
TypeScript
const componentAuctionConfig = { // Seller URL should be https and the same as decisionLogicUrl's origin seller: "https://testSeller.com", decisionLogicUrl: "https://testSeller.com/ssp/decision-logic.js", interestGroupBuyers: ["https://example-buyer.com"], auctionSignals: { auction_signals: "auction_signals" }, sellerSignals: { seller_signals: "seller_signals" }, perBuyerSignals: { // listed on interestGroupBuyers "https://example-buyer.com": { per_buyer_signals: "per_buyer_signals", }, }, }; const auctionSlot = googletag.defineSlot("/1234567/example", [160, 600])!; // To add configKey to the component auction: auctionSlot.setConfig({ componentAuction: [ { configKey: "https://testSeller.com", auctionConfig: componentAuctionConfig, }, ], }); // To remove configKey from the component auction: auctionSlot.setConfig({ componentAuction: [ { configKey: "https://testSeller.com", auctionConfig: null, }, ], });
- ดูเพิ่มเติม
configKey
-
configKey: string
-
คีย์การกำหนดค่าที่เชื่อมโยงกับการประมูลคอมโพเนนต์นี้
ค่านี้ต้องไม่ว่างเปล่าและต้องไม่ซ้ำกัน หากออบเจ็กต์ComponentAuctionConfig
2 รายการแชร์ค่า configKey เดียวกัน ค่าสุดท้ายที่จะตั้งค่าจะเขียนทับการกำหนดค่าก่อนหน้า -
googletagconfigInterstitialConfig
ออบเจ็กต์ที่กำหนดลักษณะการทำงานของช่องโฆษณาคั่นระหว่างหน้าช่องเดียว
สรุปพร็อพเพอร์ตี้ | |
---|---|
triggers
|
การกำหนดค่าทริกเกอร์โฆษณาคั่นระหว่างหน้าสำหรับโฆษณาคั่นระหว่างหน้านี้
|
triggers
-
triggers: Partial<Record<InterstitialTrigger, boolean>>
-
การกำหนดค่าทริกเกอร์โฆษณาคั่นระหว่างหน้าสำหรับโฆษณาคั่นระหว่างหน้านี้
การตั้งค่าทริกเกอร์โฆษณาคั่นระหว่างหน้าเป็นtrue
จะเปิดใช้และfalse
จะเป็นการปิดใช้ การดำเนินการนี้จะลบล้างค่าเริ่มต้นที่กำหนดค่าใน Google Ad Manager -
- ตัวอย่าง
-
JavaScript
// Define a GPT managed web interstitial ad slot. const interstitialSlot = googletag.defineOutOfPageSlot( "/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL ); // Enable optional interstitial triggers. // Change this value to false to disable. const enableTriggers = true; interstitialSlot.setConfig({ interstitial: { triggers: { navBar: enableTriggers, unhideWindow: enableTriggers, }, }, });
JavaScript (เดิม)
// Define a GPT managed web interstitial ad slot. var interstitialSlot = googletag.defineOutOfPageSlot( "/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL ); // Enable optional interstitial triggers. // Change this value to false to disable. var enableTriggers = true; interstitialSlot.setConfig({ interstitial: { triggers: { navBar: enableTriggers, unhideWindow: enableTriggers, }, }, });
TypeScript
// Define a GPT managed web interstitial ad slot. const interstitialSlot = googletag.defineOutOfPageSlot( "/1234567/sports", googletag.enums.OutOfPageFormat.INTERSTITIAL )!; // Enable optional interstitial triggers. // Change this value to false to disable. const enableTriggers = true; interstitialSlot.setConfig({ interstitial: { triggers: { navBar: enableTriggers, unhideWindow: enableTriggers, }, }, });
- ดูเพิ่มเติม
googletagconfigPageSettingsConfig
อินเทอร์เฟซการกำหนดค่าหลักสำหรับการตั้งค่าระดับหน้าเว็บ
ช่วยให้ตั้งค่าฟีเจอร์หลายรายการด้วยการเรียก API ครั้งเดียว
พร็อพเพอร์ตี้ทั้งหมดที่แสดงด้านล่างเป็นตัวอย่างและไม่ได้แสดงถึงฟีเจอร์จริงที่ใช้ setConfig สำหรับชุดของฟีเจอร์ โปรดดูช่องภายในประเภท PageSettingsConfig ด้านล่าง
ตัวอย่าง
- แก้ไขเฉพาะฟีเจอร์ที่ระบุในการโทร
setConfig
เท่านั้น// Configure feature alpha. googletag.setConfig({ alpha: {...} }); // Configure feature bravo. Feature alpha is unchanged. googletag.setConfig({ bravo: {...} });
- การตั้งค่าทั้งหมดสำหรับฟีเจอร์หนึ่งๆ จะได้รับการอัปเดตทุกครั้งที่เรียกไปยัง
setConfig
// Configure feature charlie to echo = 1, foxtrot = true. googletag.setConfig({ charlie: { echo: 1, foxtrot: true, } }); // Update feature charlie to echo = 2. Since foxtrot was not specified, // the value is cleared. googletag.setConfig({ charlie: { echo: 2 } });
- คุณสามารถล้างการตั้งค่าทั้งหมดสำหรับฟีเจอร์หนึ่งๆ ได้โดยส่งผ่าน
null
// Configure features delta, golf, and hotel. googletag.setConfig({ delta: {...}, golf: {...}, hotel: {...}, }); // Feature delta and hotel are cleared, but feature golf remains set. googletag.setConfig({ delta: null, hotel: null, });
สรุปพร็อพเพอร์ตี้ | |
---|---|
adExpansion
|
การตั้งค่าเพื่อควบคุมการขยายโฆษณา
|
pps
|
การตั้งค่าเพื่อควบคุมสัญญาณที่ได้จากผู้เผยแพร่โฆษณา (PPS)
|
privacyTreatments
|
การตั้งค่าเพื่อควบคุมการดูแลความเป็นส่วนตัวของผู้เผยแพร่โฆษณา
|
adExpansion
-
adExpansion: null | AdExpansionConfig
-
การตั้งค่าเพื่อควบคุมการขยายโฆษณา
-
pps
-
pps: null | PublisherProvidedSignalsConfig
-
การตั้งค่าเพื่อควบคุมสัญญาณที่ได้จากผู้เผยแพร่โฆษณา (PPS)
-
privacyTreatments
-
privacyTreatments: null | PrivacyTreatmentsConfig
-
การตั้งค่าเพื่อควบคุมการดูแลความเป็นส่วนตัวของผู้เผยแพร่โฆษณา
-
googletagconfigPrivacyTreatmentsConfig
การตั้งค่าเพื่อควบคุมการดูแลความเป็นส่วนตัวของผู้เผยแพร่โฆษณา
สรุปพร็อพเพอร์ตี้ | |
---|---|
treatments
|
ตัวเลือกการดูแลความเป็นส่วนตัวของผู้เผยแพร่โฆษณามากมายที่เปิดใช้
|
treatments
-
treatments: "disablePersonalization"[]
-
ตัวเลือกการดูแลความเป็นส่วนตัวของผู้เผยแพร่โฆษณามากมายที่เปิดใช้
-
- ตัวอย่าง
-
JavaScript
// Disable personalization across the entire page. googletag.setConfig({ privacyTreatments: { treatments: ["disablePersonalization"] }, });
JavaScript (เดิม)
// Disable personalization across the entire page. googletag.setConfig({ privacyTreatments: { treatments: ["disablePersonalization"] }, });
TypeScript
// Disable personalization across the entire page. googletag.setConfig({ privacyTreatments: { treatments: ["disablePersonalization"] }, });
googletagconfigPublisherProvidedSignalsConfig
ออบเจ็กต์การกำหนดค่าสัญญาณที่ได้จากผู้เผยแพร่โฆษณา (PPS)
สรุปพร็อพเพอร์ตี้ | |
---|---|
taxonomies
|
ออบเจ็กต์ที่มีการแมปการจัดหมวดหมู่
|
- ตัวอย่าง
-
JavaScript
googletag.setConfig({ pps: { taxonomies: { IAB_AUDIENCE_1_1: { values: ["6", "626"] }, // '6' = 'Demographic | Age Range | 18-20' // '626' = 'Interest | Sports | Darts' IAB_CONTENT_2_2: { values: ["48", "127"] }, // '48' = 'Books and Literature | Fiction' // '127' = 'Careers | Job Search' }, }, });
JavaScript (เดิม)
googletag.setConfig({ pps: { taxonomies: { IAB_AUDIENCE_1_1: { values: ["6", "626"] }, // '6' = 'Demographic | Age Range | 18-20' // '626' = 'Interest | Sports | Darts' IAB_CONTENT_2_2: { values: ["48", "127"] }, // '48' = 'Books and Literature | Fiction' // '127' = 'Careers | Job Search' }, }, });
TypeScript
googletag.setConfig({ pps: { taxonomies: { IAB_AUDIENCE_1_1: { values: ["6", "626"] }, // '6' = 'Demographic | Age Range | 18-20' // '626' = 'Interest | Sports | Darts' IAB_CONTENT_2_2: { values: ["48", "127"] }, // '48' = 'Books and Literature | Fiction' // '127' = 'Careers | Job Search' }, }, });
- ดูเพิ่มเติม
taxonomies
-
taxonomies: Partial<Record<Taxonomy, TaxonomyData>>
-
ออบเจ็กต์ที่มีการแมปการจัดหมวดหมู่
-
googletagconfigSlotSettingsConfig
อินเทอร์เฟซการกำหนดค่าหลักสำหรับการตั้งค่าระดับช่อง
ช่วยให้ตั้งค่าฟีเจอร์หลายรายการด้วยการเรียก API ครั้งเดียวสำหรับช่องเดียว
พร็อพเพอร์ตี้ทั้งหมดที่แสดงด้านล่างเป็นตัวอย่างและไม่ได้แสดงถึงฟีเจอร์จริงที่ใช้ setConfig โปรดดูชุดฟีเจอร์ภายในประเภท SlotSettingsConfig ด้านล่าง
ตัวอย่าง
- แก้ไขเฉพาะฟีเจอร์ที่ระบุในการโทร
Slot.setConfig
เท่านั้นconst slot = googletag.defineSlot("/1234567/example", [160, 600]); // Configure feature alpha. slot.setConfig({ alpha: {...} }); // Configure feature bravo. Feature alpha is unchanged. slot.setConfig({ bravo: {...} });
- การตั้งค่าทั้งหมดสำหรับฟีเจอร์หนึ่งๆ จะได้รับการอัปเดตทุกครั้งที่เรียกไปยัง
Slot.setConfig
// Configure feature charlie to echo = 1, foxtrot = true. slot.setConfig({ charlie: { echo: 1, foxtrot: true, } }); // Update feature charlie to echo = 2. Since foxtrot was not specified, // the value is cleared. slot.setConfig({ charlie: { echo: 2 } });
- คุณสามารถล้างการตั้งค่าทั้งหมดสำหรับฟีเจอร์หนึ่งๆ ได้โดยส่งผ่าน
null
// Configure features delta, golf, and hotel. slot.setConfig({ delta: {...}, golf: {...}, hotel: {...}, }); // Feature delta and hotel are cleared, but feature golf remains set. slot.setConfig({ delta: null, hotel: null, });
สรุปพร็อพเพอร์ตี้ | |
---|---|
adExpansion
|
การตั้งค่าเพื่อควบคุมการขยายโฆษณา
|
componentAuction
|
อาร์เรย์ของการประมูลคอมโพเนนต์ที่จะรวมอยู่ในการประมูลเพื่อแสดงโฆษณาในอุปกรณ์
|
interstitial
|
การตั้งค่าที่ควบคุมลักษณะการทำงานของช่องโฆษณาคั่นระหว่างหน้า
|
adExpansion
-
adExpansion: AdExpansionConfig
-
การตั้งค่าเพื่อควบคุมการขยายโฆษณา
-
componentAuction
-
componentAuction: ComponentAuctionConfig[]
-
อาร์เรย์ของการประมูลคอมโพเนนต์ที่จะรวมอยู่ในการประมูลเพื่อแสดงโฆษณาในอุปกรณ์
-
interstitial
-
interstitial: InterstitialConfig
-
การตั้งค่าที่ควบคุมลักษณะการทำงานของช่องโฆษณาคั่นระหว่างหน้า
-
googletagconfigTaxonomyData
ออบเจ็กต์ที่มีค่าสำหรับการจัดหมวดหมู่เดียว
สรุปพร็อพเพอร์ตี้ | |
---|---|
values
|
รายการค่าการจัดหมวดหมู่
|
values
-
values: string[]
-
รายการค่าการจัดหมวดหมู่
-
googletageventsEvent
อินเทอร์เฟซพื้นฐานสำหรับเหตุการณ์ GPT ทั้งหมด เหตุการณ์ GPT ทั้งหมดด้านล่างจะมีช่องต่อไปนี้
สรุปพร็อพเพอร์ตี้ | |
---|---|
serviceName
|
ชื่อบริการที่ทริกเกอร์เหตุการณ์
|
slot
|
ช่องโฆษณาที่เรียกเหตุการณ์ให้แสดง
|
- ดูเพิ่มเติม
serviceName
-
serviceName: string
-
ชื่อบริการที่ทริกเกอร์เหตุการณ์
-
slot
-
slot: Slot
-
ช่องโฆษณาที่เรียกเหตุการณ์ให้แสดง
-
googletageventsEventTypeMap
ซึ่งเป็นประเภทเทียมที่แมปชื่อเหตุการณ์กับประเภทออบเจ็กต์เหตุการณ์ที่สอดคล้องกันสำหรับ Service.addEventListener
และ Service.removeEventListener
และมีไว้เพื่อการอ้างอิงและพิมพ์เพื่อความปลอดภัยเท่านั้น
สรุปพร็อพเพอร์ตี้ | |
---|---|
impressionViewable
|
ชื่อแทนของ
events.ImpressionViewableEvent
|
rewardedSlotClosed
|
ชื่อแทนของ
events.RewardedSlotClosedEvent
|
rewardedSlotGranted
|
ชื่อแทนของ
events.RewardedSlotGrantedEvent
|
rewardedSlotReady
|
ชื่อแทนของ
events.RewardedSlotReadyEvent
|
slotOnload
|
ชื่อแทนของ
events.SlotOnloadEvent
|
slotRenderEnded
|
ชื่อแทนของ
events.SlotRenderEndedEvent
|
slotRequested
|
ชื่อแทนของ
events.SlotRequestedEvent
|
slotResponseReceived
|
ชื่อแทนของ
events.SlotResponseReceived
|
slotVisibilityChanged
|
ชื่อแทนของ
events.SlotVisibilityChangedEvent
|
impressionViewable
-
impressionViewable: ImpressionViewableEvent
-
ชื่อแทนของ
events.ImpressionViewableEvent
-
rewardedSlotClosed
-
rewardedSlotClosed: RewardedSlotClosedEvent
-
ชื่อแทนของ
events.RewardedSlotClosedEvent
-
rewardedSlotGranted
-
rewardedSlotGranted: RewardedSlotGrantedEvent
-
ชื่อแทนของ
events.RewardedSlotGrantedEvent
-
rewardedSlotReady
-
rewardedSlotReady: RewardedSlotReadyEvent
-
ชื่อแทนของ
events.RewardedSlotReadyEvent
-
slotOnload
-
slotOnload: SlotOnloadEvent
-
ชื่อแทนของ
events.SlotOnloadEvent
-
slotRenderEnded
-
slotRenderEnded: SlotRenderEndedEvent
-
ชื่อแทนของ
events.SlotRenderEndedEvent
-
slotRequested
-
slotRequested: SlotRequestedEvent
-
ชื่อแทนของ
events.SlotRequestedEvent
-
slotResponseReceived
-
slotResponseReceived: SlotResponseReceived
-
ชื่อแทนของ
events.SlotResponseReceived
-
slotVisibilityChanged
-
slotVisibilityChanged: SlotVisibilityChangedEvent
-
ชื่อแทนของ
events.SlotVisibilityChangedEvent
-
googletageventsImpressionViewableEvent
ขยายเวลา
เหตุการณ์นี้จะเริ่มทำงานเมื่อการแสดงผลได้แสดง ตามเกณฑ์มุมมองแอ็กทีฟ
สรุปพร็อพเพอร์ตี้ | |
---|---|
serviceName
|
ชื่อบริการที่ทริกเกอร์เหตุการณ์
รับค่าจาก
|
slot
|
ช่องโฆษณาที่เรียกเหตุการณ์ให้แสดง
รับค่าจาก
|
- ตัวอย่าง
-
JavaScript
// This listener is called when an impression becomes viewable. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("impressionViewable", (event) => { const slot = event.slot; console.log("Impression for slot", slot.getSlotElementId(), "became viewable."); if (slot === targetSlot) { // Slot specific logic. } });
JavaScript (เดิม)
// This listener is called when an impression becomes viewable. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("impressionViewable", function (event) { var slot = event.slot; console.log("Impression for slot", slot.getSlotElementId(), "became viewable."); if (slot === targetSlot) { // Slot specific logic. } });
TypeScript
// This listener is called when an impression becomes viewable. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("impressionViewable", (event) => { const slot = event.slot; console.log("Impression for slot", slot.getSlotElementId(), "became viewable."); if (slot === targetSlot) { // Slot specific logic. } });
- ดูเพิ่มเติม
googletageventsRewardedSlotClosedEvent
ขยายเวลา
เหตุการณ์นี้จะเกิดขึ้นเมื่อผู้ใช้ปิดช่องโฆษณาที่มีการให้รางวัล โดยปุ่มนี้อาจเริ่มทำงานก่อนหรือหลังจากที่มีการมอบรางวัลแล้ว หากต้องการตรวจสอบว่าได้รับรางวัลหรือไม่ ให้ใช้ events.RewardedSlotGrantedEvent
แทน
สรุปพร็อพเพอร์ตี้ | |
---|---|
serviceName
|
ชื่อบริการที่ทริกเกอร์เหตุการณ์
รับค่าจาก
|
slot
|
ช่องโฆษณาที่เรียกเหตุการณ์ให้แสดง
รับค่าจาก
|
- ตัวอย่าง
-
JavaScript
// This listener is called when the user closes a rewarded ad slot. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("rewardedSlotClosed", (event) => { const slot = event.slot; console.log("Rewarded ad slot", slot.getSlotElementId(), "has been closed."); if (slot === targetSlot) { // Slot specific logic. } });
JavaScript (เดิม)
// This listener is called when the user closes a rewarded ad slot. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("rewardedSlotClosed", function (event) { var slot = event.slot; console.log("Rewarded ad slot", slot.getSlotElementId(), "has been closed."); if (slot === targetSlot) { // Slot specific logic. } });
TypeScript
// This listener is called when the user closes a rewarded ad slot. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("rewardedSlotClosed", (event) => { const slot = event.slot; console.log("Rewarded ad slot", slot.getSlotElementId(), "has been closed."); if (slot === targetSlot) { // Slot specific logic. } });
- ดูเพิ่มเติม
googletageventsRewardedSlotGrantedEvent
ขยายเวลา
เหตุการณ์นี้จะเกิดขึ้นเมื่อได้รับรางวัลจากการดูโฆษณาที่มีการให้รางวัล หากโฆษณาปิดไปก่อนที่จะมีคุณสมบัติตรงตามเกณฑ์ในการให้รางวัล กิจกรรมนี้จะไม่เริ่มทํางาน
สรุปพร็อพเพอร์ตี้ | |
---|---|
payload
|
ออบเจ็กต์ที่มีข้อมูลเกี่ยวกับรางวัลที่ได้รับ
|
serviceName
|
ชื่อบริการที่ทริกเกอร์เหตุการณ์
รับค่าจาก
|
slot
|
ช่องโฆษณาที่เรียกเหตุการณ์ให้แสดง
รับค่าจาก
|
- ตัวอย่าง
-
JavaScript
// This listener is called whenever a reward is granted for a // rewarded ad. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("rewardedSlotGranted", (event) => { const slot = event.slot; console.group("Reward granted for slot", slot.getSlotElementId(), "."); // Log details of the reward. console.log("Reward type:", event.payload?.type); console.log("Reward amount:", event.payload?.amount); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } });
JavaScript (เดิม)
// This listener is called whenever a reward is granted for a // rewarded ad. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("rewardedSlotGranted", function (event) { var _a, _b; var slot = event.slot; console.group("Reward granted for slot", slot.getSlotElementId(), "."); // Log details of the reward. console.log("Reward type:", (_a = event.payload) === null || _a === void 0 ? void 0 : _a.type); console.log( "Reward amount:", (_b = event.payload) === null || _b === void 0 ? void 0 : _b.amount ); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } });
TypeScript
// This listener is called whenever a reward is granted for a // rewarded ad. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("rewardedSlotGranted", (event) => { const slot = event.slot; console.group("Reward granted for slot", slot.getSlotElementId(), "."); // Log details of the reward. console.log("Reward type:", event.payload?.type); console.log("Reward amount:", event.payload?.amount); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } });
- ดูเพิ่มเติม
payload
-
payload: null | RewardedPayload
-
ออบเจ็กต์ที่มีข้อมูลเกี่ยวกับรางวัลที่ได้รับ
-
googletageventsRewardedSlotReadyEvent
ขยายเวลา
เหตุการณ์นี้จะเริ่มทำงานเมื่อโฆษณาที่มีการให้รางวัลพร้อมแสดง ผู้เผยแพร่โฆษณามีหน้าที่นำเสนอตัวเลือกแก่ผู้ใช้ในการดูโฆษณาก่อนที่จะแสดง
สรุปพร็อพเพอร์ตี้ | |
---|---|
serviceName
|
ชื่อบริการที่ทริกเกอร์เหตุการณ์
รับค่าจาก
|
slot
|
ช่องโฆษณาที่เรียกเหตุการณ์ให้แสดง
รับค่าจาก
|
ข้อมูลสรุปของเมธอด | |
---|---|
makeRewardedVisible
|
แสดงโฆษณาที่มีการให้รางวัล
|
- ตัวอย่าง
-
JavaScript
// This listener is called when a rewarded ad slot becomes ready to be // displayed. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("rewardedSlotReady", (event) => { const slot = event.slot; console.log("Rewarded ad slot", slot.getSlotElementId(), "is ready to be displayed."); // Replace with custom logic. const userHasConsented = true; if (userHasConsented) { event.makeRewardedVisible(); } if (slot === targetSlot) { // Slot specific logic. } });
JavaScript (เดิม)
// This listener is called when a rewarded ad slot becomes ready to be // displayed. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("rewardedSlotReady", function (event) { var slot = event.slot; console.log("Rewarded ad slot", slot.getSlotElementId(), "is ready to be displayed."); // Replace with custom logic. var userHasConsented = true; if (userHasConsented) { event.makeRewardedVisible(); } if (slot === targetSlot) { // Slot specific logic. } });
TypeScript
// This listener is called when a rewarded ad slot becomes ready to be // displayed. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("rewardedSlotReady", (event) => { const slot = event.slot; console.log("Rewarded ad slot", slot.getSlotElementId(), "is ready to be displayed."); // Replace with custom logic. const userHasConsented = true; if (userHasConsented) { event.makeRewardedVisible(); } if (slot === targetSlot) { // Slot specific logic. } });
- ดูเพิ่มเติม
makeRewardedVisible
-
makeRewardedVisible(): void
-
แสดงโฆษณาที่มีการให้รางวัล ไม่ควรเรียกใช้วิธีนี้จนกว่าผู้ใช้จะยินยอมให้ดูโฆษณา
-
googletageventsSlotOnloadEvent
ขยายเวลา
เหตุการณ์นี้จะเกิดขึ้นเมื่อ iframe ของครีเอทีฟโฆษณาเริ่มการทำงานของเหตุการณ์การโหลด เมื่อแสดงโฆษณาสื่อสมบูรณ์ในโหมดการแสดงผลแบบพร้อมกัน จะไม่มีการใช้ iframe จึงจะไม่มีการเริ่มทำงาน SlotOnloadEvent
สรุปพร็อพเพอร์ตี้ | |
---|---|
serviceName
|
ชื่อบริการที่ทริกเกอร์เหตุการณ์
รับค่าจาก
|
slot
|
ช่องโฆษณาที่เรียกเหตุการณ์ให้แสดง
รับค่าจาก
|
- ตัวอย่าง
-
JavaScript
// This listener is called when a creative iframe load event fires. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotOnload", (event) => { const slot = event.slot; console.log("Creative iframe for slot", slot.getSlotElementId(), "has loaded."); if (slot === targetSlot) { // Slot specific logic. } });
JavaScript (เดิม)
// This listener is called when a creative iframe load event fires. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotOnload", function (event) { var slot = event.slot; console.log("Creative iframe for slot", slot.getSlotElementId(), "has loaded."); if (slot === targetSlot) { // Slot specific logic. } });
TypeScript
// This listener is called when a creative iframe load event fires. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotOnload", (event) => { const slot = event.slot; console.log("Creative iframe for slot", slot.getSlotElementId(), "has loaded."); if (slot === targetSlot) { // Slot specific logic. } });
- ดูเพิ่มเติม
googletageventsSlotRenderEndedEvent
ขยายเวลา
เหตุการณ์นี้จะเกิดขึ้นเมื่อมีการแทรกโค้ดโฆษณาลงในช่อง เหตุการณ์นี้จะเกิดขึ้นก่อนที่จะมีการดึงทรัพยากรของครีเอทีฟโฆษณา ครีเอทีฟโฆษณาจึงอาจยังไม่ปรากฏให้เห็น หากต้องการทราบเวลาที่ทรัพยากรครีเอทีฟโฆษณาทั้งหมดสำหรับช่องโฆษณาโหลดเสร็จแล้ว ให้พิจารณาใช้ events.SlotOnloadEvent
แทน
สรุปพร็อพเพอร์ตี้ | |
---|---|
advertiserId
|
รหัสผู้ลงโฆษณาของโฆษณาที่แสดงผล
|
campaignId
|
รหัสแคมเปญของโฆษณาที่แสดงผล
|
companyIds
|
รหัสของบริษัทที่เสนอราคาในโฆษณาทดแทนที่แสดงผล
|
creativeId
|
รหัสครีเอทีฟโฆษณาของโฆษณาแบบจองที่แสดง
|
creativeTemplateId
|
รหัสเทมเพลตครีเอทีฟโฆษณาของโฆษณาแบบจองที่แสดง
|
isBackfill
|
โฆษณาเป็นโฆษณาทดแทนหรือไม่
|
isEmpty
|
มีการส่งคืนโฆษณาสำหรับช่องหรือไม่
|
labelIds
|
รหัสป้ายกำกับของโฆษณาที่แสดงผล
|
lineItemId
|
รหัสรายการโฆษณาของโฆษณาแบบจองที่แสดง
|
serviceName
|
ชื่อบริการที่ทริกเกอร์เหตุการณ์
รับค่าจาก
|
size
|
ระบุขนาดพิกเซลของครีเอทีฟโฆษณาที่แสดง
|
slot
|
ช่องโฆษณาที่เรียกเหตุการณ์ให้แสดง
รับค่าจาก
|
slotContentChanged
|
เนื้อหาของช่องมีการเปลี่ยนแปลงด้วยโฆษณาที่แสดงผลหรือไม่
|
sourceAgnosticCreativeId
|
รหัสครีเอทีฟโฆษณาของโฆษณาแบบจองหรือโฆษณาทดแทนที่แสดงผล
|
sourceAgnosticLineItemId
|
รหัสรายการโฆษณาของการจองหรือโฆษณาทดแทนที่แสดงผล
|
yieldGroupIds
|
รหัสของกลุ่มผลตอบแทนสำหรับโฆษณาทดแทนที่แสดงผล
|
- ตัวอย่าง
-
JavaScript
// This listener is called when a slot has finished rendering. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotRenderEnded", (event) => { const slot = event.slot; console.group("Slot", slot.getSlotElementId(), "finished rendering."); // Log details of the rendered ad. console.log("Advertiser ID:", event.advertiserId); console.log("Campaign ID:", event.campaignId); console.log("Company IDs:", event.companyIds); console.log("Creative ID:", event.creativeId); console.log("Creative Template ID:", event.creativeTemplateId); console.log("Is backfill?:", event.isBackfill); console.log("Is empty?:", event.isEmpty); console.log("Label IDs:", event.labelIds); console.log("Line Item ID:", event.lineItemId); console.log("Size:", event.size); console.log("Slot content changed?", event.slotContentChanged); console.log("Source Agnostic Creative ID:", event.sourceAgnosticCreativeId); console.log("Source Agnostic Line Item ID:", event.sourceAgnosticLineItemId); console.log("Yield Group IDs:", event.yieldGroupIds); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } });
JavaScript (เดิม)
// This listener is called when a slot has finished rendering. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotRenderEnded", function (event) { var slot = event.slot; console.group("Slot", slot.getSlotElementId(), "finished rendering."); // Log details of the rendered ad. console.log("Advertiser ID:", event.advertiserId); console.log("Campaign ID:", event.campaignId); console.log("Company IDs:", event.companyIds); console.log("Creative ID:", event.creativeId); console.log("Creative Template ID:", event.creativeTemplateId); console.log("Is backfill?:", event.isBackfill); console.log("Is empty?:", event.isEmpty); console.log("Label IDs:", event.labelIds); console.log("Line Item ID:", event.lineItemId); console.log("Size:", event.size); console.log("Slot content changed?", event.slotContentChanged); console.log("Source Agnostic Creative ID:", event.sourceAgnosticCreativeId); console.log("Source Agnostic Line Item ID:", event.sourceAgnosticLineItemId); console.log("Yield Group IDs:", event.yieldGroupIds); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } });
TypeScript
// This listener is called when a slot has finished rendering. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotRenderEnded", (event) => { const slot = event.slot; console.group("Slot", slot.getSlotElementId(), "finished rendering."); // Log details of the rendered ad. console.log("Advertiser ID:", event.advertiserId); console.log("Campaign ID:", event.campaignId); console.log("Company IDs:", event.companyIds); console.log("Creative ID:", event.creativeId); console.log("Creative Template ID:", event.creativeTemplateId); console.log("Is backfill?:", event.isBackfill); console.log("Is empty?:", event.isEmpty); console.log("Label IDs:", event.labelIds); console.log("Line Item ID:", event.lineItemId); console.log("Size:", event.size); console.log("Slot content changed?", event.slotContentChanged); console.log("Source Agnostic Creative ID:", event.sourceAgnosticCreativeId); console.log("Source Agnostic Line Item ID:", event.sourceAgnosticLineItemId); console.log("Yield Group IDs:", event.yieldGroupIds); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } });
- ดูเพิ่มเติม
advertiserId
-
advertiserId: null | number
-
รหัสผู้ลงโฆษณาของโฆษณาที่แสดงผล มีค่าเป็น
null
สำหรับช่องว่าง โฆษณาทดแทน และครีเอทีฟโฆษณาที่แสดงผลโดยบริการอื่นๆ ที่ไม่ใช่PubAdsService
-
campaignId
-
campaignId: null | number
-
รหัสแคมเปญของโฆษณาที่แสดงผล มีค่าเป็น
null
สำหรับช่องว่าง โฆษณาทดแทน และครีเอทีฟโฆษณาที่แสดงผลโดยบริการอื่นๆ ที่ไม่ใช่PubAdsService
-
companyIds
-
companyIds: null | number[]
-
รหัสของบริษัทที่เสนอราคาในโฆษณาทดแทนที่แสดงผล มีค่าเป็น
null
สำหรับช่องว่าง โฆษณาแบบจองล่วงหน้า และครีเอทีฟโฆษณาที่แสดงผลโดยบริการอื่นๆ นอกเหนือจากPubAdsService
-
creativeId
-
creativeId: null | number
-
รหัสครีเอทีฟโฆษณาของโฆษณาแบบจองที่แสดง มีค่าเป็น
null
สำหรับช่องว่าง โฆษณาทดแทน และครีเอทีฟโฆษณาที่แสดงผลโดยบริการอื่นๆ ที่ไม่ใช่PubAdsService
-
creativeTemplateId
-
creativeTemplateId: null | number
-
รหัสเทมเพลตครีเอทีฟโฆษณาของโฆษณาแบบจองที่แสดง มีค่าเป็น
null
สำหรับช่องว่าง โฆษณาทดแทน และครีเอทีฟโฆษณาที่แสดงผลโดยบริการอื่นๆ ที่ไม่ใช่PubAdsService
-
isBackfill
-
isBackfill: boolean
-
โฆษณาเป็นโฆษณาทดแทนหรือไม่ ค่าจะเป็น
true
หากโฆษณาเป็นโฆษณาทดแทน หากเป็นโฆษณาfalse
ในกรณีอื่นๆ -
isEmpty
-
isEmpty: boolean
-
มีการส่งคืนโฆษณาสำหรับช่องหรือไม่ ค่าจะเป็น
true
หากไม่มีการแสดงโฆษณาfalse
มิฉะนั้น -
labelIds
-
labelIds: null | number[]
-
รหัสป้ายกำกับของโฆษณาที่แสดงผล มีค่าเป็น
null
สำหรับช่องว่าง โฆษณาทดแทน และครีเอทีฟโฆษณาที่แสดงผลโดยบริการอื่นๆ ที่ไม่ใช่PubAdsService
-
lineItemId
-
lineItemId: null | number
-
รหัสรายการโฆษณาของโฆษณาแบบจองที่แสดง มีค่าเป็น
null
สำหรับช่องว่าง โฆษณาทดแทน และครีเอทีฟโฆษณาที่แสดงผลโดยบริการอื่นๆ ที่ไม่ใช่PubAdsService
-
size
-
size: null | string | number[]
-
ระบุขนาดพิกเซลของครีเอทีฟโฆษณาที่แสดง ตัวอย่าง:
[728, 90]
มีค่าเป็นnull
สำหรับช่องโฆษณาที่ว่างเปล่า -
slotContentChanged
-
slotContentChanged: boolean
-
เนื้อหาของช่องมีการเปลี่ยนแปลงด้วยโฆษณาที่แสดงผลหรือไม่ ค่าจะเป็น
true
หากเนื้อหามีการเปลี่ยนแปลงfalse
หากมีการเปลี่ยนแปลงเนื้อหา -
sourceAgnosticCreativeId
-
sourceAgnosticCreativeId: null | number
-
รหัสครีเอทีฟโฆษณาของโฆษณาแบบจองหรือโฆษณาทดแทนที่แสดงผล ค่าจะเป็น
null
หากโฆษณาไม่ใช่การจองหรือโฆษณาทดแทนของรายการโฆษณา หรือครีเอทีฟโฆษณาแสดงผลโดยบริการอื่นๆ นอกเหนือจากPubAdsService
-
sourceAgnosticLineItemId
-
sourceAgnosticLineItemId: null | number
-
รหัสรายการโฆษณาของการจองหรือโฆษณาทดแทนที่แสดงผล ค่าจะเป็น
null
หากโฆษณาไม่ใช่การจองหรือโฆษณาทดแทนของรายการโฆษณา หรือครีเอทีฟโฆษณาแสดงผลโดยบริการอื่นๆ นอกเหนือจากPubAdsService
-
yieldGroupIds
-
yieldGroupIds: null | number[]
-
รหัสของกลุ่มผลตอบแทนสำหรับโฆษณาทดแทนที่แสดงผล มีค่าเป็น
null
สำหรับช่องว่าง โฆษณาแบบจองล่วงหน้า และครีเอทีฟโฆษณาที่แสดงผลโดยบริการอื่นๆ นอกเหนือจากPubAdsService
-
googletageventsSlotRequestedEvent
ขยายเวลา
เหตุการณ์นี้จะเกิดขึ้นเมื่อมีการขอโฆษณาสำหรับช่องใดช่องหนึ่ง
สรุปพร็อพเพอร์ตี้ | |
---|---|
serviceName
|
ชื่อบริการที่ทริกเกอร์เหตุการณ์
รับค่าจาก
|
slot
|
ช่องโฆษณาที่เรียกเหตุการณ์ให้แสดง
รับค่าจาก
|
- ตัวอย่าง
-
JavaScript
// This listener is called when the specified service issues an ad // request for a slot. Each slot will fire this event, even though they // may be batched together in a single request if single request // architecture (SRA) is enabled. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotRequested", (event) => { const slot = event.slot; console.log("Slot", slot.getSlotElementId(), "has been requested."); if (slot === targetSlot) { // Slot specific logic. } });
JavaScript (เดิม)
// This listener is called when the specified service issues an ad // request for a slot. Each slot will fire this event, even though they // may be batched together in a single request if single request // architecture (SRA) is enabled. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotRequested", function (event) { var slot = event.slot; console.log("Slot", slot.getSlotElementId(), "has been requested."); if (slot === targetSlot) { // Slot specific logic. } });
TypeScript
// This listener is called when the specified service issues an ad // request for a slot. Each slot will fire this event, even though they // may be batched together in a single request if single request // architecture (SRA) is enabled. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotRequested", (event) => { const slot = event.slot; console.log("Slot", slot.getSlotElementId(), "has been requested."); if (slot === targetSlot) { // Slot specific logic. } });
- ดูเพิ่มเติม
googletageventsSlotResponseReceived
ขยายเวลา
เหตุการณ์นี้จะเกิดขึ้นเมื่อได้รับการตอบกลับโฆษณาจากช่องโฆษณาหนึ่งๆ
สรุปพร็อพเพอร์ตี้ | |
---|---|
serviceName
|
ชื่อบริการที่ทริกเกอร์เหตุการณ์
รับค่าจาก
|
slot
|
ช่องโฆษณาที่เรียกเหตุการณ์ให้แสดง
รับค่าจาก
|
- ตัวอย่าง
-
JavaScript
// This listener is called when an ad response has been received // for a slot. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotResponseReceived", (event) => { const slot = event.slot; console.log("Ad response for slot", slot.getSlotElementId(), "received."); if (slot === targetSlot) { // Slot specific logic. } });
JavaScript (เดิม)
// This listener is called when an ad response has been received // for a slot. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotResponseReceived", function (event) { var slot = event.slot; console.log("Ad response for slot", slot.getSlotElementId(), "received."); if (slot === targetSlot) { // Slot specific logic. } });
TypeScript
// This listener is called when an ad response has been received // for a slot. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotResponseReceived", (event) => { const slot = event.slot; console.log("Ad response for slot", slot.getSlotElementId(), "received."); if (slot === targetSlot) { // Slot specific logic. } });
- ดูเพิ่มเติม
googletageventsSlotVisibilityChangedEvent
ขยายเวลา
เหตุการณ์นี้จะเกิดขึ้นเมื่อเปอร์เซ็นต์บนหน้าจอของพื้นที่ช่องโฆษณาเปลี่ยนแปลง ระบบจะควบคุมเหตุการณ์และจะไม่เริ่มทำงานบ่อยเกินกว่า 1 ครั้งในทุก 200 มิลลิวินาที
สรุปพร็อพเพอร์ตี้ | |
---|---|
inViewPercentage
|
เปอร์เซ็นต์ของพื้นที่ในโฆษณาที่แสดงให้เห็น
|
serviceName
|
ชื่อบริการที่ทริกเกอร์เหตุการณ์
รับค่าจาก
|
slot
|
ช่องโฆษณาที่เรียกเหตุการณ์ให้แสดง
รับค่าจาก
|
- ตัวอย่าง
-
JavaScript
// This listener is called whenever the on-screen percentage of an // ad slot's area changes. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotVisibilityChanged", (event) => { const slot = event.slot; console.group("Visibility of slot", slot.getSlotElementId(), "changed."); // Log details of the event. console.log("Visible area:", `${event.inViewPercentage}%`); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } });
JavaScript (เดิม)
// This listener is called whenever the on-screen percentage of an // ad slot's area changes. var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotVisibilityChanged", function (event) { var slot = event.slot; console.group("Visibility of slot", slot.getSlotElementId(), "changed."); // Log details of the event. console.log("Visible area:", "".concat(event.inViewPercentage, "%")); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } });
TypeScript
// This listener is called whenever the on-screen percentage of an // ad slot's area changes. const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]); googletag.pubads().addEventListener("slotVisibilityChanged", (event) => { const slot = event.slot; console.group("Visibility of slot", slot.getSlotElementId(), "changed."); // Log details of the event. console.log("Visible area:", `${event.inViewPercentage}%`); console.groupEnd(); if (slot === targetSlot) { // Slot specific logic. } });
- ดูเพิ่มเติม
inViewPercentage
-
inViewPercentage: number
-
เปอร์เซ็นต์ของพื้นที่ในโฆษณาที่แสดงให้เห็น ค่าคือตัวเลขระหว่าง 0 ถึง 100
-
googletagsecureSignalsBidderSignalProvider
แสดงผลสัญญาณที่ปลอดภัยสำหรับผู้เสนอราคาเฉพาะราย
ผู้ให้บริการสัญญาณที่ปลอดภัยสำหรับผู้เสนอราคาประกอบด้วย 2 ส่วนดังนี้
- ฟังก์ชันเครื่องมือรวบรวมซึ่งแสดงผล
Promise
ที่แปลค่าเป็นสัญญาณที่ปลอดภัย id
ซึ่งระบุผู้เสนอราคาที่เชื่อมโยงกับสัญญาณ
secureSignals.PublisherSignalProvider
แทน
สรุปพร็อพเพอร์ตี้ | |
---|---|
collectorFunction
|
|
id
|
ตัวระบุที่ไม่ซ้ำสำหรับผู้รวบรวมที่เชื่อมโยงกับสัญญาณที่ปลอดภัยนี้ ตามที่จดทะเบียนใน Google Ad Manager
|
- ตัวอย่าง
-
JavaScript
// id is provided googletag.secureSignalProviders.push({ id: "collector123", collectorFunction: () => { // ...custom signal generation logic... return Promise.resolve("signal"); }, });
JavaScript (เดิม)
// id is provided googletag.secureSignalProviders.push({ id: "collector123", collectorFunction: function () { // ...custom signal generation logic... return Promise.resolve("signal"); }, });
TypeScript
// id is provided googletag.secureSignalProviders!.push({ id: "collector123", collectorFunction: () => { // ...custom signal generation logic... return Promise.resolve("signal"); }, });
- ดูเพิ่มเติม
collectorFunction
-
collectorFunction: () => Promise<string>
-
id
-
id: string
-
ตัวระบุที่ไม่ซ้ำสำหรับผู้รวบรวมที่เชื่อมโยงกับสัญญาณที่ปลอดภัยนี้ ตามที่จดทะเบียนใน Google Ad Manager
-
googletagsecureSignalsPublisherSignalProvider
แสดงผลสัญญาณที่ปลอดภัยสำหรับผู้เผยแพร่โฆษณาที่เฉพาะเจาะจง
ผู้ให้บริการสัญญาณของผู้เผยแพร่โฆษณาประกอบด้วย 2 ส่วน ได้แก่
- ฟังก์ชันเครื่องมือรวบรวมซึ่งแสดงผล
Promise
ที่แปลค่าเป็นสัญญาณที่ปลอดภัย networkCode
ซึ่งระบุผู้เผยแพร่โฆษณาที่เชื่อมโยงกับสัญญาณ
secureSignals.BidderSignalProvider
แทน
สรุปพร็อพเพอร์ตี้ | |
---|---|
collectorFunction
|
|
networkCode
|
รหัสเครือข่าย (ตามที่เห็นในเส้นทางหน่วยโฆษณา) ของผู้เผยแพร่โฆษณาที่เชื่อมโยงกับสัญญาณที่ปลอดภัยนี้
|
- ตัวอย่าง
-
JavaScript
// networkCode is provided googletag.secureSignalProviders.push({ networkCode: "123456", collectorFunction: () => { // ...custom signal generation logic... return Promise.resolve("signal"); }, });
JavaScript (เดิม)
// networkCode is provided googletag.secureSignalProviders.push({ networkCode: "123456", collectorFunction: function () { // ...custom signal generation logic... return Promise.resolve("signal"); }, });
TypeScript
// networkCode is provided googletag.secureSignalProviders!.push({ networkCode: "123456", collectorFunction: () => { // ...custom signal generation logic... return Promise.resolve("signal"); }, });
- ดูเพิ่มเติม
collectorFunction
-
collectorFunction: () => Promise<string>
-
networkCode
-
networkCode: string
-
รหัสเครือข่าย (ตามที่เห็นในเส้นทางหน่วยโฆษณา) ของผู้เผยแพร่โฆษณาที่เชื่อมโยงกับสัญญาณที่ปลอดภัยนี้
-
googletagsecureSignalsSecureSignalProvidersArray
อินเทอร์เฟซสำหรับการจัดการสัญญาณที่ปลอดภัย
ข้อมูลสรุปของเมธอด | |
---|---|
clearAllCache
|
ล้างสัญญาณที่แคชไว้ทั้งหมดจากพื้นที่เก็บข้อมูลในเครื่อง
|
push
|
เพิ่ม
secureSignals.SecureSignalProvider ใหม่ลงในอาร์เรย์ผู้ให้บริการสัญญาณและเริ่มกระบวนการสร้างสัญญาณ
|
clearAllCache
-
clearAllCache(): void
-
ล้างสัญญาณที่แคชไว้ทั้งหมดจากพื้นที่เก็บข้อมูลในเครื่อง
-
push
-
push(provider: SecureSignalProvider): void
-
เพิ่ม
secureSignals.SecureSignalProvider
ใหม่ลงในอาร์เรย์ผู้ให้บริการสัญญาณและเริ่มกระบวนการสร้างสัญญาณ -
-
พารามิเตอร์ provider: SecureSignalProvider
ออบเจ็กต์secureSignals.SecureSignalProvider
ที่จะเพิ่มไปยังอาร์เรย์