ข้อมูลอ้างอิงเกี่ยวกับ GPT

การอ้างอิงนี้ใช้สัญลักษณ์ 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"]

ขนาดที่มีชื่อช่องหนึ่งๆ ได้ ในกรณีส่วนใหญ่ ขนาดจะเป็นสี่เหลี่ยมผืนผ้าขนาดคงที่ แต่มีบางกรณีที่เราต้องการข้อกำหนดเกี่ยวกับขนาดประเภทอื่นๆ ต่อไปนี้เป็นขนาดที่มีชื่อที่ถูกต้องเท่านั้น

  • แบบไหล: คอนเทนเนอร์โฆษณาใช้ความกว้าง 100% ของ div ระดับบนสุด จากนั้นปรับขนาดความสูงให้พอดีกับเนื้อหาครีเอทีฟโฆษณา คล้ายกับลักษณะการทำงานขององค์ประกอบบล็อกทั่วไปในหน้า ใช้สำหรับโฆษณาเนทีฟ (ดูบทความที่เกี่ยวข้อง) โปรดทราบว่าทั้ง fluid และ ['fluid'] เป็นรูปแบบที่ยอมรับเพื่อประกาศขนาดช่องโฆษณาเป็น "แบบไหล"

SingleSizeArray | NamedSize

ขนาดเดียวที่ใช้ได้สำหรับช่องโฆษณา

[number, number]

อาร์เรย์ของตัวเลข 2 ตัวที่แสดงถึง [width, height]

[SingleSizeArray, GeneralSize]

การแมปขนาดวิวพอร์ตกับขนาดโฆษณา ใช้กับโฆษณาที่ปรับเปลี่ยนตามพื้นที่โฆษณา

SizeMapping[]

รายการการแมปขนาด

"unhideWindow" | "navBar"

การเรียกโฆษณาคั่นระหว่างหน้าที่รองรับ

"disablePersonalization"

การดูแลความเป็นส่วนตัวของผู้เผยแพร่โฆษณาที่รองรับ

"IAB_AUDIENCE_1_1" | "IAB_CONTENT_2_2"

การจัดหมวดหมู่ที่รองรับสำหรับสัญญาณที่ได้จากผู้เผยแพร่โฆษณา (PPS)

BidderSignalProvider | PublisherSignalProvider

อินเทอร์เฟซสำหรับการส่งคืนสัญญาณที่ปลอดภัยสำหรับผู้เสนอราคาหรือผู้ให้บริการเฉพาะ ต้องระบุ id หรือ networkCode อย่างใดอย่างหนึ่ง แต่ไม่ใช่ทั้ง 2 อย่าง

ประเภท Enum

Enum
googletag.enums.OutOfPageFormat
รูปแบบที่ไม่อยู่ในขอบเขตหน้าซึ่ง GPT รองรับ
googletag.enums.TrafficSource


googletag.enums.OutOfPageFormat

  • รูปแบบที่ไม่อยู่ในขอบเขตหน้าซึ่ง GPT รองรับ

  • ดูเพิ่มเติม
  • ค่า
    BOTTOM_ANCHOR
    รูปแบบจุดยึดที่ช่องจะอยู่ติดด้านล่างของวิวพอร์ต
    INTERSTITIAL
    รูปแบบโฆษณาคั่นระหว่างหน้าในเว็บ
    LEFT_SIDE_RAIL
    รูปแบบโฆษณาที่แถบข้างด้านซ้าย
    REWARDED
    รูปแบบที่มีการให้รางวัล
    RIGHT_SIDE_RAIL
    รูปแบบโฆษณาที่แถบข้างด้านขวา
    TOP_ANCHOR
    รูปแบบจุดยึดที่ช่องจะอยู่ติดด้านบนสุดของวิวพอร์ต


googletag.enums.TrafficSource

  • ดูเพิ่มเติม
  • ค่า
    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 เพื่อจัดคิว Callback เมื่อ GPT พร้อม Callback เหล่านี้ไม่จำเป็นต้องตรวจสอบ googletag.apiReady เนื่องจากมั่นใจว่าจะทำงานเมื่อตั้งค่า 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 โหลดขึ้นมา 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


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


googletagdisplay

  • display(divOrSlot: string | Element | Slot): void
  • สั่งให้บริการสล็อตแสดงผลช่องโฆษณา ช่องโฆษณาแต่ละช่องจะแสดงได้ครั้งละหนึ่งหน้าเท่านั้น ช่องโฆษณาทั้งหมดต้องได้รับการกำหนดไว้และมีบริการที่เชื่อมโยงกับช่องโฆษณาดังกล่าวก่อนที่จะถูกแสดง การเรียกใช้การแสดงผลจะต้องไม่เกิดขึ้นจนกว่าองค์ประกอบจะอยู่ใน DOM วิธีทั่วไปในการบรรลุเป้าหมายคือการวางภายในบล็อกสคริปต์ภายในองค์ประกอบ div ที่มีชื่อในการเรียกเมธอด

    หากมีการใช้สถาปัตยกรรมคำขอรวมครั้งเดียว (SRA) ช่องโฆษณาที่ไม่ได้ดึงข้อมูลทั้งหมดในขณะที่เรียกใช้วิธีนี้จะมีการดึงข้อมูลพร้อมกัน ในการบังคับไม่ให้แสดงช่องโฆษณา จะต้องลบ div ทั้งหมดออก

  • ตัวอย่าง

    JavaScript

    googletag.cmd.push(() => {
      googletag.display("div-1");
    });
    

    JavaScript (เดิม)

    googletag.cmd.push(function () {
      googletag.display("div-1");
    });
    

    TypeScript

    googletag.cmd.push(() => {
      googletag.display("div-1");
    });
    
    ดูเพิ่มเติม
  • พารามิเตอร์
    divOrSlot: string | Element | Slot
    รหัสของส่วน div ที่มีช่องโฆษณาหรือส่วน div หรือออบเจ็กต์ช่อง หากมีการระบุองค์ประกอบ div องค์ประกอบนั้นต้องมีแอตทริบิวต์ "id" ซึ่งตรงกับรหัสที่ส่งไปยัง defineSlot


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


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

ขยายเวลา Service

โฆษณาที่แสดงร่วม โฆษณาวิดีโอใช้บริการนี้เพื่อแสดงโฆษณาที่แสดงร่วม

สรุปเมธอด
addEventListener
บันทึก Listener ที่อนุญาตให้คุณตั้งค่าและเรียกฟังก์ชัน 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


limitedAds

  • limitedAds: boolean
  • เปิดใช้การแสดงโฆษณาในโหมดโฆษณาแบบจํากัดเพื่อช่วยให้ปฏิบัติตามกฎระเบียบของผู้เผยแพร่โฆษณาได้

    คุณสามารถสั่งให้ GPT ขอโฆษณาแบบจำกัดได้ 2 วิธีดังนี้

    • โดยอัตโนมัติโดยใช้สัญญาณจากแพลตฟอร์มการจัดการความยินยอม TCF เวอร์ชัน 2.0 ของ IAB
    • ด้วยตนเอง โดยตั้งค่าของช่องนี้เป็น true
    คุณจะกำหนดค่าโฆษณาแบบจำกัดด้วยตนเองได้ก็ต่อเมื่อโหลด GPT จาก URL ของโฆษณาแบบจำกัด การพยายามแก้ไขการตั้งค่านี้เมื่อโหลด GPT จาก URL มาตรฐานจะสร้างคําเตือนของคอนโซลผู้เผยแพร่โฆษณา

    โปรดทราบว่าไม่จําเป็นต้องเปิดใช้โฆษณาแบบจํากัดด้วยตนเองเมื่อใช้ CMP

  • ตัวอย่าง

    JavaScript

    // Manually enable limited ads serving.
    // GPT must be loaded from the limited ads URL to configure this setting.
    googletag.pubads().setPrivacySettings({
      limitedAds: true,
    });
    

    JavaScript (เดิม)

    // Manually enable limited ads serving.
    // GPT must be loaded from the limited ads URL to configure this setting.
    googletag.pubads().setPrivacySettings({
      limitedAds: true,
    });
    

    TypeScript

    // Manually enable limited ads serving.
    // GPT must be loaded from the limited ads URL to configure this setting.
    googletag.pubads().setPrivacySettings({
      limitedAds: true,
    });
    
    ดูเพิ่มเติม


nonPersonalizedAds


restrictDataProcessing


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


googletagPubAdsService

ขยายเวลา Service

บริการโฆษณาของผู้เผยแพร่โฆษณา บริการนี้ใช้เพื่อดึงและแสดงโฆษณาจากบัญชี Google Ad Manager

สรุปเมธอด
addEventListener
บันทึก Listener ที่อนุญาตให้คุณตั้งค่าและเรียกฟังก์ชัน JavaScript เมื่อเกิดเหตุการณ์ GPT หนึ่งขึ้นในหน้า
clear
นำโฆษณาออกจากช่องโฆษณาที่กำหนดและแทนที่ด้วยเนื้อหาว่าง
clearCategoryExclusions
ล้างป้ายกำกับการยกเว้นหมวดหมู่โฆษณาระดับหน้าทั้งหมด
clearTargeting
ล้างพารามิเตอร์การกำหนดเป้าหมายเองสำหรับคีย์ที่เฉพาะเจาะจงหรือคีย์ทั้งหมด
collapseEmptyDivs
เปิดใช้การยุบ div ของช่องเพื่อไม่ให้ใช้พื้นที่บนหน้าเว็บเมื่อไม่มีเนื้อหาโฆษณาที่จะแสดง
disableInitialLoad
ปิดใช้คำขอสำหรับโฆษณาในการโหลดหน้าเว็บ แต่อนุญาตให้ขอโฆษณาด้วยการเรียก PubAdsService.refresh
display
สร้างและแสดงช่องโฆษณาที่มีเส้นทางและขนาดหน่วยโฆษณาที่ระบุ
enableLazyLoad
เปิดใช้การโหลดแบบ Lazy Loading ใน GPT ตามที่กำหนดโดยออบเจ็กต์การกำหนดค่า
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
เปลี่ยน Correlator ที่ส่งไปพร้อมกับคำขอโฆษณา ซึ่งเริ่มต้นการดูหน้าเว็บใหม่ได้อย่างมีประสิทธิภาพ


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 ของช่องเพื่อไม่ให้ใช้พื้นที่บนหน้าเว็บเมื่อไม่มีเนื้อหาโฆษณาที่จะแสดง ต้องตั้งค่าโหมดนี้ก่อนที่จะเปิดใช้บริการ

  • ดูเพิ่มเติม
  • พารามิเตอร์
    collapseBeforeAdFetch?: boolean
    เลือกว่าจะยุบช่องก่อนที่จะดึงโฆษณาหรือไม่ คุณจะระบุพารามิเตอร์นี้หรือไม่ก็ได้ หากไม่ได้ระบุไว้ ระบบจะใช้ false เป็นค่าเริ่มต้น
  • การคืนสินค้า
    boolean
    แสดงผล true หากเปิดใช้โหมดยุบ div และ false หากเปิดใช้โหมดยุบไม่ได้เนื่องจากมีการเรียกเมธอดหลังจากเปิดใช้บริการ


disableInitialLoad


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 ตามที่กำหนดโดยออบเจ็กต์การกำหนดค่า ดูตัวอย่างโดยละเอียดเพิ่มเติมได้ที่ตัวอย่างการโหลดแบบ 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 วินาที แต่อาจมีการเปลี่ยนแปลง) ดังนั้น คำขอที่มีค่าสหสัมพันธ์เดียวกันได้รับเป็นระยะเวลาใกล้กันจะถือว่าเป็นการดูหน้าเว็บครั้งเดียว โดยค่าเริ่มต้น ระบบจะสร้างสหสัมพันธ์ใหม่สำหรับทุกการรีเฟรช

      หมายเหตุ: ตัวเลือกนี้ไม่มีผลกับการดูหน้าเว็บที่มีระยะเวลานานของ 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 ออกหรือพึ่งพาการแสดงผลโดยตรงในหน้าเว็บของผู้เผยแพร่โฆษณา

  • ตัวอย่าง

    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
  • เปลี่ยน Correlator ที่ส่งไปพร้อมกับคำขอโฆษณา ซึ่งเริ่มต้นการดูหน้าเว็บใหม่ได้อย่างมีประสิทธิภาพ ค่าสหสัมพันธ์จะเหมือนกันสำหรับคำขอโฆษณาทั้งหมดที่มาจากการดูหน้าเว็บครั้งหนึ่ง และไม่ซ้ำกันในการดูหน้าเว็บแต่ละครั้ง ใช้กับโหมดอะซิงโครนัสเท่านั้น

    หมายเหตุ: โหมดนี้ไม่ส่งผลต่อการดูหน้าเว็บเป็นระยะเวลานานของ 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
บันทึก Listener ที่อนุญาตให้คุณตั้งค่าและเรียกฟังก์ชัน JavaScript เมื่อเกิดเหตุการณ์ GPT หนึ่งขึ้นในหน้า
getSlots
รับรายการสล็อตที่เชื่อมโยงกับบริการนี้
removeEventListener
นำ Listener ที่ลงทะเบียนไว้ก่อนหน้าออก


addEventListener

  • addEventListener<K extends keyof EventTypeMap>(eventType: K, listener: (arg: EventTypeMap[K]) => void): Service
  • บันทึก Listener ที่อนุญาตให้คุณตั้งค่าและเรียกฟังก์ชัน 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

  • getSlots(): Slot[]
  • รับรายการสล็อตที่เชื่อมโยงกับบริการนี้

  • การคืนสินค้า
    Slot[]
    สล็อตในลำดับที่เพิ่มไปยังบริการ


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
    ผลลัพธ์ที่สร้างโดยเครื่องมือสร้างนี้ อาจเป็น Null หากระบุการแมปขนาดไม่ถูกต้อง


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


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'.
    

    JavaScript (เดิม)

    var slot = googletag
      .defineSlot("/1234567/sports", [160, 600], "div")
      .addService(googletag.pubads());
    
    slot.getSlotElementId();
    // Returns 'div'.
    

    TypeScript

    const slot = googletag
      .defineSlot("/1234567/sports", [160, 600], "div")!
      .addService(googletag.pubads());
    
    slot.getSlotElementId();
    // Returns 'div'.
    
  • การคืนสินค้า
    string
    รหัสช่อง 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 ออกหรือพึ่งพาการแสดงผลโดยตรงในหน้าเว็บของผู้เผยแพร่โฆษณา

  • ตัวอย่าง

    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
    ออบเจ็กต์ช่องที่เรียกใช้เมธอด


googletag.configAdExpansionConfig

การตั้งค่าเพื่อควบคุมการขยายโฆษณา

ข้อมูลสรุปเกี่ยวกับพร็อพเพอร์ตี้
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


googletag.configComponentAuctionConfig

ออบเจ็กต์ที่แสดงการประมูลคอมโพเนนต์เดียวในการประมูลเพื่อแสดงโฆษณาในอุปกรณ์

ข้อมูลสรุปเกี่ยวกับพร็อพเพอร์ตี้
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 เดียวกัน ค่าล่าสุดที่จะตั้งค่าจะเขียนทับการกำหนดค่าก่อนหน้านี้


googletag.configInterstitialConfig

ออบเจ็กต์ที่กำหนดลักษณะการทำงานของช่องโฆษณาคั่นระหว่างหน้าช่องเดียว

ข้อมูลสรุปเกี่ยวกับพร็อพเพอร์ตี้
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,
        },
      },
    });
    
    ดูเพิ่มเติม


googletag.configPageSettingsConfig

อินเทอร์เฟซการกำหนดค่าหลักสำหรับการตั้งค่าระดับหน้าเว็บ

ช่วยให้ตั้งค่าฟีเจอร์หลายรายการได้ด้วยการเรียก 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)


privacyTreatments

  • privacyTreatments: null | PrivacyTreatmentsConfig
  • การตั้งค่าเพื่อควบคุมการดูแลความเป็นส่วนตัวของผู้เผยแพร่โฆษณา


googletag.configPrivacyTreatmentsConfig

การตั้งค่าเพื่อควบคุมการดูแลความเป็นส่วนตัวของผู้เผยแพร่โฆษณา

ข้อมูลสรุปเกี่ยวกับพร็อพเพอร์ตี้
treatments
อาร์เรย์ของการจัดการความเป็นส่วนตัวของผู้เผยแพร่เนื้อหา


treatments

  • treatments: "disablePersonalization"[]
  • อาร์เรย์ของการจัดการความเป็นส่วนตัวของผู้เผยแพร่เนื้อหา

  • ตัวอย่าง

    JavaScript

    // Disable personalization across the entire page.
    googletag.setConfig({
      privacyTreatments: { treatments: ["disablePersonalization"] },
    });
    

    JavaScript (เดิม)

    // Disable personalization across the entire page.
    googletag.setConfig({
      privacyTreatments: { treatments: ["disablePersonalization"] },
    });
    

    TypeScript

    // Disable personalization across the entire page.
    googletag.setConfig({
      privacyTreatments: { treatments: ["disablePersonalization"] },
    });
    


googletag.configPublisherProvidedSignalsConfig

ออบเจ็กต์การกำหนดค่าสัญญาณที่ได้จากผู้เผยแพร่โฆษณา (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


googletag.configSlotSettingsConfig

อินเทอร์เฟซการกำหนดค่าหลักสำหรับการตั้งค่าระดับช่อง

ช่วยให้ตั้งค่าฟีเจอร์หลายรายการด้วยการเรียก 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
  • การตั้งค่าที่ควบคุมลักษณะการทำงานของช่องโฆษณาคั่นระหว่างหน้า


googletag.configTaxonomyData

ออบเจ็กต์ที่มีค่าสำหรับการจัดหมวดหมู่รายการเดียว

ข้อมูลสรุปเกี่ยวกับพร็อพเพอร์ตี้
values
รายการค่าการจัดหมวดหมู่


values


googletag.eventsEvent

อินเทอร์เฟซฐานสําหรับเหตุการณ์ GPT ทั้งหมด เหตุการณ์ GPT ทั้งหมดด้านล่างจะมีช่องต่อไปนี้

ข้อมูลสรุปเกี่ยวกับพร็อพเพอร์ตี้
serviceName
ชื่อของบริการที่เรียกเหตุการณ์ให้แสดง
slot
ช่องโฆษณาที่เรียกเหตุการณ์ให้แสดง
ดูเพิ่มเติม


serviceName

  • serviceName: string
  • ชื่อของบริการที่เรียกเหตุการณ์ให้แสดง


slot

  • slot: Slot
  • ช่องโฆษณาที่เรียกเหตุการณ์ให้แสดง


googletag.eventsEventTypeMap

นี่เป็นประเภทสมมติที่แมปชื่อเหตุการณ์กับประเภทออบเจ็กต์เหตุการณ์ที่สอดคล้องกันสำหรับ 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


rewardedSlotClosed


rewardedSlotGranted


rewardedSlotReady


slotOnload


slotRenderEnded


slotRequested


slotResponseReceived


slotVisibilityChanged


googletag.eventsImpressionViewableEvent

ขยายเวลา Event

เหตุการณ์นี้จะเริ่มทำงานเมื่อการแสดงผลมองเห็นได้ตามเกณฑ์ของมุมมองแอ็กทีฟ

ข้อมูลสรุปเกี่ยวกับพร็อพเพอร์ตี้
serviceName
ชื่อของบริการที่เรียกเหตุการณ์ให้แสดง
slot
ช่องโฆษณาที่เรียกเหตุการณ์ให้แสดง
ตัวอย่าง

JavaScript

// This listener is called when an impression becomes viewable.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("impressionViewable", (event) => {
  const slot = event.slot;
  console.log("Impression for slot", slot.getSlotElementId(), "became viewable.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

JavaScript (เดิม)

// This listener is called when an impression becomes viewable.
var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("impressionViewable", function (event) {
  var slot = event.slot;
  console.log("Impression for slot", slot.getSlotElementId(), "became viewable.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

TypeScript

// This listener is called when an impression becomes viewable.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("impressionViewable", (event) => {
  const slot = event.slot;
  console.log("Impression for slot", slot.getSlotElementId(), "became viewable.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});
ดูเพิ่มเติม


googletag.eventsRewardedSlotClosedEvent

ขยายเวลา Event

เหตุการณ์นี้จะเริ่มทำงานเมื่อผู้ใช้ปิดช่องโฆษณาที่มีการให้รางวัล โดยอาจเริ่มทำงานก่อนหรือหลังจากที่มอบรางวัลแล้ว หากต้องการตรวจสอบว่าได้รับรางวัลหรือไม่ ให้ใช้ events.RewardedSlotGrantedEvent แทน

ข้อมูลสรุปเกี่ยวกับพร็อพเพอร์ตี้
serviceName
ชื่อของบริการที่เรียกเหตุการณ์ให้แสดง
slot
ช่องโฆษณาที่เรียกเหตุการณ์ให้แสดง
ตัวอย่าง

JavaScript

// This listener is called when the user closes a rewarded ad slot.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("rewardedSlotClosed", (event) => {
  const slot = event.slot;
  console.log("Rewarded ad slot", slot.getSlotElementId(), "has been closed.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

JavaScript (เดิม)

// This listener is called when the user closes a rewarded ad slot.
var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("rewardedSlotClosed", function (event) {
  var slot = event.slot;
  console.log("Rewarded ad slot", slot.getSlotElementId(), "has been closed.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

TypeScript

// This listener is called when the user closes a rewarded ad slot.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("rewardedSlotClosed", (event) => {
  const slot = event.slot;
  console.log("Rewarded ad slot", slot.getSlotElementId(), "has been closed.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});
ดูเพิ่มเติม


googletag.eventsRewardedSlotGrantedEvent

ขยายเวลา Event

กิจกรรมนี้จะเริ่มทำงานเมื่อได้รับรางวัลจากการดูโฆษณาที่มีการให้รางวัล หากโฆษณาปิดก่อนที่จะมีคุณสมบัติตามเกณฑ์การมอบรางวัล กิจกรรมนี้จะไม่เริ่มทำงาน

ข้อมูลสรุปเกี่ยวกับพร็อพเพอร์ตี้
payload
ออบเจ็กต์ที่มีข้อมูลเกี่ยวกับรางวัลที่ได้รับ
serviceName
ชื่อของบริการที่เรียกเหตุการณ์ให้แสดง
slot
ช่องโฆษณาที่เรียกเหตุการณ์ให้แสดง
ตัวอย่าง

JavaScript

// This listener is called whenever a reward is granted for a
// rewarded ad.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("rewardedSlotGranted", (event) => {
  const slot = event.slot;
  console.group("Reward granted for slot", slot.getSlotElementId(), ".");

  // Log details of the reward.
  console.log("Reward type:", event.payload?.type);
  console.log("Reward amount:", event.payload?.amount);
  console.groupEnd();

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

JavaScript (เดิม)

// This listener is called whenever a reward is granted for a
// rewarded ad.
var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("rewardedSlotGranted", function (event) {
  var _a, _b;
  var slot = event.slot;
  console.group("Reward granted for slot", slot.getSlotElementId(), ".");

  // Log details of the reward.
  console.log("Reward type:", (_a = event.payload) === null || _a === void 0 ? void 0 : _a.type);
  console.log(
    "Reward amount:",
    (_b = event.payload) === null || _b === void 0 ? void 0 : _b.amount
  );
  console.groupEnd();

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

TypeScript

// This listener is called whenever a reward is granted for a
// rewarded ad.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("rewardedSlotGranted", (event) => {
  const slot = event.slot;
  console.group("Reward granted for slot", slot.getSlotElementId(), ".");

  // Log details of the reward.
  console.log("Reward type:", event.payload?.type);
  console.log("Reward amount:", event.payload?.amount);
  console.groupEnd();

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});
ดูเพิ่มเติม


payload

  • payload: null | RewardedPayload
  • ออบเจ็กต์ที่มีข้อมูลเกี่ยวกับรางวัลที่ได้รับ


googletag.eventsRewardedSlotReadyEvent

ขยายเวลา Event

เหตุการณ์นี้จะเกิดขึ้นเมื่อโฆษณาที่มีการให้รางวัลพร้อมแสดง ผู้เผยแพร่โฆษณามีหน้าที่รับผิดชอบในการแสดงตัวเลือกให้ผู้ใช้ดูโฆษณาก่อนที่จะแสดงโฆษณา

ข้อมูลสรุปเกี่ยวกับพร็อพเพอร์ตี้
serviceName
ชื่อของบริการที่เรียกเหตุการณ์ให้แสดง
slot
ช่องโฆษณาที่เรียกเหตุการณ์ให้แสดง
สรุปเมธอด
makeRewardedVisible
แสดงโฆษณาที่มีการให้รางวัล
ตัวอย่าง

JavaScript

// This listener is called when a rewarded ad slot becomes ready to be
// displayed.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("rewardedSlotReady", (event) => {
  const slot = event.slot;
  console.log("Rewarded ad slot", slot.getSlotElementId(), "is ready to be displayed.");

  // Replace with custom logic.
  const userHasConsented = true;
  if (userHasConsented) {
    event.makeRewardedVisible();
  }

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

JavaScript (เดิม)

// This listener is called when a rewarded ad slot becomes ready to be
// displayed.
var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("rewardedSlotReady", function (event) {
  var slot = event.slot;
  console.log("Rewarded ad slot", slot.getSlotElementId(), "is ready to be displayed.");

  // Replace with custom logic.
  var userHasConsented = true;
  if (userHasConsented) {
    event.makeRewardedVisible();
  }

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

TypeScript

// This listener is called when a rewarded ad slot becomes ready to be
// displayed.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("rewardedSlotReady", (event) => {
  const slot = event.slot;
  console.log("Rewarded ad slot", slot.getSlotElementId(), "is ready to be displayed.");

  // Replace with custom logic.
  const userHasConsented = true;
  if (userHasConsented) {
    event.makeRewardedVisible();
  }

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});
ดูเพิ่มเติม


makeRewardedVisible

  • makeRewardedVisible(): void
  • แสดงโฆษณาที่มีการให้รางวัล ไม่ควรเรียกใช้วิธีการนี้จนกว่าผู้ใช้จะให้ความยินยอมในการดูโฆษณา


googletag.eventsSlotOnloadEvent

ขยายเวลา Event

เหตุการณ์นี้จะเริ่มทำงานเมื่อ iframe ของครีเอทีฟโฆษณาเริ่มเหตุการณ์การโหลด เมื่อแสดงโฆษณาสื่อสมบูรณ์ในโหมดการแสดงผลแบบพร้อมกัน จะไม่มีการใช้ iframe ดังนั้นจะไม่มีการเริ่มการทำงานของ SlotOnloadEvent

ข้อมูลสรุปเกี่ยวกับพร็อพเพอร์ตี้
serviceName
ชื่อของบริการที่เรียกเหตุการณ์ให้แสดง
slot
ช่องโฆษณาที่เรียกเหตุการณ์ให้แสดง
ตัวอย่าง

JavaScript

// This listener is called when a creative iframe load event fires.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotOnload", (event) => {
  const slot = event.slot;
  console.log("Creative iframe for slot", slot.getSlotElementId(), "has loaded.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

JavaScript (เดิม)

// This listener is called when a creative iframe load event fires.
var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotOnload", function (event) {
  var slot = event.slot;
  console.log("Creative iframe for slot", slot.getSlotElementId(), "has loaded.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

TypeScript

// This listener is called when a creative iframe load event fires.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotOnload", (event) => {
  const slot = event.slot;
  console.log("Creative iframe for slot", slot.getSlotElementId(), "has loaded.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});
ดูเพิ่มเติม


googletag.eventsSlotRenderEndedEvent

ขยายเวลา Event

เหตุการณ์นี้จะเริ่มทำงานเมื่อมีการใส่โค้ดโฆษณาลงในช่องโฆษณา เหตุการณ์นี้จะเกิดขึ้นก่อนที่จะดึงทรัพยากรของครีเอทีฟโฆษณา ครีเอทีฟโฆษณาจึงอาจยังไม่ปรากฏ หากต้องการทราบว่าทรัพยากรครีเอทีฟโฆษณาทั้งหมดสำหรับช่องโฆษณาหนึ่งๆ โหลดเสร็จแล้วเมื่อใด ให้พิจารณาใช้ events.SlotOnloadEvent แทน

ข้อมูลสรุปเกี่ยวกับพร็อพเพอร์ตี้
advertiserId
รหัสผู้ลงโฆษณาของโฆษณาที่แสดงผล
campaignId
รหัสแคมเปญของโฆษณาที่แสดงผล
companyIds
รหัสของบริษัทที่เสนอราคาในโฆษณาทดแทนที่แสดงผล
creativeId
รหัสครีเอทีฟโฆษณาของโฆษณาแบบจองล่วงหน้าที่แสดงผล
creativeTemplateId
รหัสเทมเพลตครีเอทีฟโฆษณาของโฆษณาแบบจองล่วงหน้าที่แสดงผล
isBackfill
โฆษณาเป็นโฆษณาทดแทนหรือไม่
isEmpty
มีการส่งโฆษณาสำหรับช่องดังกล่าวหรือไม่
labelIds
รหัสป้ายกำกับของโฆษณาที่แสดงผล
lineItemId
รหัสรายการโฆษณาของโฆษณาแบบจองล่วงหน้าที่แสดงผล
serviceName
ชื่อของบริการที่เรียกเหตุการณ์ให้แสดง
size
ระบุขนาดพิกเซลของครีเอทีฟโฆษณาที่แสดงผล
slot
ช่องโฆษณาที่เรียกเหตุการณ์ให้แสดง
slotContentChanged
มีการเปลี่ยนแปลงเนื้อหาของช่องด้วยโฆษณาที่แสดงผลหรือไม่
sourceAgnosticCreativeId
รหัสครีเอทีฟโฆษณาของการจองที่แสดงผลหรือโฆษณาทดแทน
sourceAgnosticLineItemId
รหัสรายการโฆษณาของการจองที่แสดงผลหรือโฆษณาทดแทน
yieldGroupIds
รหัสของกลุ่มผลตอบแทนสำหรับโฆษณาทดแทนที่แสดงผล
ตัวอย่าง

JavaScript

// This listener is called when a slot has finished rendering.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotRenderEnded", (event) => {
  const slot = event.slot;
  console.group("Slot", slot.getSlotElementId(), "finished rendering.");

  // Log details of the rendered ad.
  console.log("Advertiser ID:", event.advertiserId);
  console.log("Campaign ID:", event.campaignId);
  console.log("Company IDs:", event.companyIds);
  console.log("Creative ID:", event.creativeId);
  console.log("Creative Template ID:", event.creativeTemplateId);
  console.log("Is backfill?:", event.isBackfill);
  console.log("Is empty?:", event.isEmpty);
  console.log("Label IDs:", event.labelIds);
  console.log("Line Item ID:", event.lineItemId);
  console.log("Size:", event.size);
  console.log("Slot content changed?", event.slotContentChanged);
  console.log("Source Agnostic Creative ID:", event.sourceAgnosticCreativeId);
  console.log("Source Agnostic Line Item ID:", event.sourceAgnosticLineItemId);
  console.log("Yield Group IDs:", event.yieldGroupIds);
  console.groupEnd();

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

JavaScript (เดิม)

// This listener is called when a slot has finished rendering.
var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotRenderEnded", function (event) {
  var slot = event.slot;
  console.group("Slot", slot.getSlotElementId(), "finished rendering.");

  // Log details of the rendered ad.
  console.log("Advertiser ID:", event.advertiserId);
  console.log("Campaign ID:", event.campaignId);
  console.log("Company IDs:", event.companyIds);
  console.log("Creative ID:", event.creativeId);
  console.log("Creative Template ID:", event.creativeTemplateId);
  console.log("Is backfill?:", event.isBackfill);
  console.log("Is empty?:", event.isEmpty);
  console.log("Label IDs:", event.labelIds);
  console.log("Line Item ID:", event.lineItemId);
  console.log("Size:", event.size);
  console.log("Slot content changed?", event.slotContentChanged);
  console.log("Source Agnostic Creative ID:", event.sourceAgnosticCreativeId);
  console.log("Source Agnostic Line Item ID:", event.sourceAgnosticLineItemId);
  console.log("Yield Group IDs:", event.yieldGroupIds);
  console.groupEnd();

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

TypeScript

// This listener is called when a slot has finished rendering.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotRenderEnded", (event) => {
  const slot = event.slot;
  console.group("Slot", slot.getSlotElementId(), "finished rendering.");

  // Log details of the rendered ad.
  console.log("Advertiser ID:", event.advertiserId);
  console.log("Campaign ID:", event.campaignId);
  console.log("Company IDs:", event.companyIds);
  console.log("Creative ID:", event.creativeId);
  console.log("Creative Template ID:", event.creativeTemplateId);
  console.log("Is backfill?:", event.isBackfill);
  console.log("Is empty?:", event.isEmpty);
  console.log("Label IDs:", event.labelIds);
  console.log("Line Item ID:", event.lineItemId);
  console.log("Size:", event.size);
  console.log("Slot content changed?", event.slotContentChanged);
  console.log("Source Agnostic Creative ID:", event.sourceAgnosticCreativeId);
  console.log("Source Agnostic Line Item ID:", event.sourceAgnosticLineItemId);
  console.log("Yield Group IDs:", event.yieldGroupIds);
  console.groupEnd();

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});
ดูเพิ่มเติม


advertiserId

  • advertiserId: null | number
  • รหัสผู้ลงโฆษณาของโฆษณาที่แสดงผล ค่าเป็น null สำหรับช่องที่ว่างเปล่า โฆษณาทดแทน และครีเอทีฟโฆษณาที่แสดงผลโดยบริการอื่นๆ นอกเหนือจาก PubAdsService


campaignId

  • campaignId: null | number
  • รหัสแคมเปญของโฆษณาที่แสดงผล ค่าเป็น null สำหรับช่องที่ว่างเปล่า โฆษณาทดแทน และครีเอทีฟโฆษณาที่แสดงผลโดยบริการอื่นๆ นอกเหนือจาก PubAdsService


companyIds

  • companyIds: null | number[]
  • รหัสของบริษัทที่เสนอราคาในโฆษณาทดแทนที่แสดงผล ค่านี้คือ null สำหรับช่องที่ว่างเปล่า โฆษณาแบบจองล่วงหน้า และครีเอทีฟโฆษณาที่แสดงผลโดยบริการอื่นๆ นอกเหนือจาก PubAdsService


creativeId

  • creativeId: null | number
  • รหัสครีเอทีฟโฆษณาของโฆษณาแบบจองล่วงหน้าที่แสดงผล ค่าเป็น null สำหรับช่องที่ว่างเปล่า โฆษณาทดแทน และครีเอทีฟโฆษณาที่แสดงผลโดยบริการอื่นๆ นอกเหนือจาก PubAdsService


creativeTemplateId

  • creativeTemplateId: null | number
  • รหัสเทมเพลตครีเอทีฟโฆษณาของโฆษณาแบบจองล่วงหน้าที่แสดงผล ค่าเป็น null สำหรับช่องที่ว่างเปล่า โฆษณาทดแทน และครีเอทีฟโฆษณาที่แสดงผลโดยบริการอื่นๆ นอกเหนือจาก PubAdsService


isBackfill

  • isBackfill: boolean
  • โฆษณาเป็นโฆษณาทดแทนหรือไม่ ค่าจะเป็น true หากโฆษณาเป็นโฆษณาทดแทน false หากไม่ใช่


isEmpty

  • isEmpty: boolean
  • มีการส่งโฆษณาสำหรับช่องดังกล่าวหรือไม่ ค่าจะเป็น true หากไม่มีการแสดงโฆษณา มิฉะนั้นจะเป็น false


labelIds

  • labelIds: null | number[]
  • รหัสป้ายกำกับของโฆษณาที่แสดงผล ค่าเป็น null สำหรับช่องที่ว่างเปล่า โฆษณาทดแทน และครีเอทีฟโฆษณาที่แสดงผลโดยบริการอื่นๆ นอกเหนือจาก PubAdsService


lineItemId

  • lineItemId: null | number
  • รหัสรายการโฆษณาของโฆษณาแบบจองล่วงหน้าที่แสดงผล ค่าเป็น null สำหรับช่องที่ว่างเปล่า โฆษณาทดแทน และครีเอทีฟโฆษณาที่แสดงผลโดยบริการอื่นๆ นอกเหนือจาก PubAdsService


size

  • size: null | string | number[]
  • ระบุขนาดพิกเซลของครีเอทีฟโฆษณาที่แสดงผล ตัวอย่าง: [728, 90] ค่าคือ null สำหรับช่องโฆษณาที่ว่างเปล่า


slotContentChanged

  • slotContentChanged: boolean
  • มีการเปลี่ยนแปลงเนื้อหาของช่องด้วยโฆษณาที่แสดงผลหรือไม่ ค่าจะเป็น true หากมีการเปลี่ยนแปลงเนื้อหา มิฉะนั้นจะเป็น false


sourceAgnosticCreativeId

  • sourceAgnosticCreativeId: null | number
  • รหัสครีเอทีฟโฆษณาของการจองที่แสดงผลหรือโฆษณาทดแทน ค่าจะเป็น null หากโฆษณาไม่ใช่การจองหรือโฆษณาทดแทนของรายการโฆษณา หรือโฆษณาแสดงผลโดยบริการอื่นๆ ที่ไม่ใช่ PubAdsService


sourceAgnosticLineItemId

  • sourceAgnosticLineItemId: null | number
  • รหัสรายการโฆษณาของการจองที่แสดงผลหรือโฆษณาทดแทน ค่าจะเป็น null หากโฆษณาไม่ใช่การจองหรือโฆษณาทดแทนของรายการโฆษณา หรือโฆษณาแสดงผลโดยบริการอื่นๆ ที่ไม่ใช่ PubAdsService


yieldGroupIds

  • yieldGroupIds: null | number[]
  • รหัสของกลุ่มผลตอบแทนสำหรับโฆษณาทดแทนที่แสดงผล ค่านี้คือ null สำหรับช่องที่ว่างเปล่า โฆษณาแบบจองล่วงหน้า และครีเอทีฟโฆษณาที่แสดงผลโดยบริการอื่นๆ นอกเหนือจาก PubAdsService


googletag.eventsSlotRequestedEvent

ขยายเวลา Event

เหตุการณ์นี้จะเกิดขึ้นเมื่อมีคำขอโฆษณาสำหรับช่องหนึ่งๆ

ข้อมูลสรุปเกี่ยวกับพร็อพเพอร์ตี้
serviceName
ชื่อของบริการที่เรียกเหตุการณ์ให้แสดง
slot
ช่องโฆษณาที่เรียกเหตุการณ์ให้แสดง
ตัวอย่าง

JavaScript

// This listener is called when the specified service issues an ad
// request for a slot. Each slot will fire this event, even though they
// may be batched together in a single request if single request
// architecture (SRA) is enabled.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotRequested", (event) => {
  const slot = event.slot;
  console.log("Slot", slot.getSlotElementId(), "has been requested.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

JavaScript (เดิม)

// This listener is called when the specified service issues an ad
// request for a slot. Each slot will fire this event, even though they
// may be batched together in a single request if single request
// architecture (SRA) is enabled.
var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotRequested", function (event) {
  var slot = event.slot;
  console.log("Slot", slot.getSlotElementId(), "has been requested.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

TypeScript

// This listener is called when the specified service issues an ad
// request for a slot. Each slot will fire this event, even though they
// may be batched together in a single request if single request
// architecture (SRA) is enabled.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotRequested", (event) => {
  const slot = event.slot;
  console.log("Slot", slot.getSlotElementId(), "has been requested.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});
ดูเพิ่มเติม


googletag.eventsSlotResponseReceived

ขยายเวลา Event

เหตุการณ์นี้จะเริ่มทำงานเมื่อมีการตอบกลับโฆษณาสำหรับช่องใดช่องหนึ่ง

ข้อมูลสรุปเกี่ยวกับพร็อพเพอร์ตี้
serviceName
ชื่อของบริการที่เรียกเหตุการณ์ให้แสดง
slot
ช่องโฆษณาที่เรียกเหตุการณ์ให้แสดง
ตัวอย่าง

JavaScript

// This listener is called when an ad response has been received
// for a slot.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotResponseReceived", (event) => {
  const slot = event.slot;
  console.log("Ad response for slot", slot.getSlotElementId(), "received.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

JavaScript (เดิม)

// This listener is called when an ad response has been received
// for a slot.
var targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotResponseReceived", function (event) {
  var slot = event.slot;
  console.log("Ad response for slot", slot.getSlotElementId(), "received.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});

TypeScript

// This listener is called when an ad response has been received
// for a slot.
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
googletag.pubads().addEventListener("slotResponseReceived", (event) => {
  const slot = event.slot;
  console.log("Ad response for slot", slot.getSlotElementId(), "received.");

  if (slot === targetSlot) {
    // Slot specific logic.
  }
});
ดูเพิ่มเติม


googletag.eventsSlotVisibilityChangedEvent

ขยายเวลา Event

เหตุการณ์นี้จะเริ่มทำงานเมื่อเปอร์เซ็นต์บนหน้าจอของพื้นที่ช่องโฆษณามีการเปลี่ยนแปลง ระบบจะควบคุมเหตุการณ์และจะไม่เริ่มทำงานบ่อยครั้งกว่า 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
  • เปอร์เซ็นต์พื้นที่ของโฆษณาที่มองเห็นได้ Value ต้องเป็นตัวเลขระหว่าง 0 ถึง 100


googletag.secureSignalsBidderSignalProvider

แสดงผลสัญญาณที่ปลอดภัยสำหรับผู้เสนอราคาเฉพาะ

ผู้ให้บริการสัญญาณที่ปลอดภัยของผู้เสนอราคาประกอบด้วย 2 ส่วนดังนี้

  1. ฟังก์ชันผู้รวบรวม ซึ่งจะแสดงผล Promise ที่เปลี่ยนเป็นสัญญาณที่ปลอดภัย
  2. 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


googletag.secureSignalsPublisherSignalProvider

จะแสดงสัญญาณที่ปลอดภัยสำหรับผู้เผยแพร่โฆษณาที่เจาะจง

ผู้ให้บริการสัญญาณผู้เผยแพร่โฆษณาประกอบด้วย 2 ส่วนคือ

  1. ฟังก์ชันผู้รวบรวม ซึ่งจะแสดงผล Promise ที่เปลี่ยนเป็นสัญญาณที่ปลอดภัย
  2. networkCode ซึ่งระบุผู้เผยแพร่โฆษณาที่เชื่อมโยงกับสัญญาณ
หากต้องการส่งสัญญาณที่ปลอดภัยให้กับผู้เสนอราคา ให้ใช้ secureSignals.BidderSignalProvider แทน

ข้อมูลสรุปเกี่ยวกับพร็อพเพอร์ตี้
collectorFunction
networkCode
รหัสเครือข่าย (ตามที่เห็นในเส้นทางหน่วยโฆษณา) สำหรับผู้เผยแพร่โฆษณาที่เชื่อมโยงกับสัญญาณที่ปลอดภัยนี้
ตัวอย่าง

JavaScript

// networkCode is provided
googletag.secureSignalProviders.push({
  networkCode: "123456",
  collectorFunction: () => {
    // ...custom signal generation logic...
    return Promise.resolve("signal");
  },
});

JavaScript (เดิม)

// networkCode is provided
googletag.secureSignalProviders.push({
  networkCode: "123456",
  collectorFunction: function () {
    // ...custom signal generation logic...
    return Promise.resolve("signal");
  },
});

TypeScript

// networkCode is provided
googletag.secureSignalProviders!.push({
  networkCode: "123456",
  collectorFunction: () => {
    // ...custom signal generation logic...
    return Promise.resolve("signal");
  },
});
ดูเพิ่มเติม


collectorFunction

  • collectorFunction: () => Promise<string>


networkCode

  • networkCode: string
  • รหัสเครือข่าย (ตามที่เห็นในเส้นทางหน่วยโฆษณา) สำหรับผู้เผยแพร่โฆษณาที่เชื่อมโยงกับสัญญาณที่ปลอดภัยนี้


googletag.secureSignalsSecureSignalProvidersArray

อินเทอร์เฟซสำหรับการจัดการสัญญาณที่ปลอดภัย

สรุปเมธอด
clearAllCache
ล้างสัญญาณทั้งหมดของผู้รวบรวมทั้งหมดออกจากแคช และอาจลดโอกาสที่สัญญาณจะรวมอยู่ในคำขอโฆษณาสำหรับการดูหน้าเว็บนี้และที่อาจเกิดขึ้นในภายหลัง
push
เพิ่ม secureSignals.SecureSignalProvider ใหม่ไปยังอาร์เรย์ผู้ให้บริการสัญญาณและเริ่มกระบวนการสร้างสัญญาณ


clearAllCache

  • clearAllCache(): void
  • ล้างสัญญาณทั้งหมดของผู้รวบรวมทั้งหมดออกจากแคช และอาจลดโอกาสที่สัญญาณจะรวมอยู่ในคำขอโฆษณาสำหรับการดูหน้าเว็บนี้และที่อาจเกิดขึ้นในภายหลัง ควรใช้เฉพาะกับการเปลี่ยนแปลงสถานะที่มีความหมาย เช่น เหตุการณ์ที่ระบุผู้ใช้ใหม่ (เช่น เข้าสู่ระบบ ออกจากระบบ ลงชื่อสมัครใช้)


push