บทนำ
API นี้มีเครื่องมือสำหรับโต้ตอบกับข้อความที่แท็บความเป็นส่วนตัวและการรับส่งข้อความนำเสนอ ซึ่งช่วยให้คุณทำสิ่งต่อไปนี้ได้
- ระงับการรับส่งข้อความสำหรับผู้ใช้ที่กำหนด
- ค้นหาสถานะตัวบล็อกโฆษณาของผู้ใช้
- แสดงจุดแรกเข้าเพื่อให้ผู้ใช้เพิกถอนความยินยอมตามกฎระเบียบของสหภาพยุโรป
- ลบล้างลิงก์ "ไม่อนุญาตให้ขาย" เริ่มต้นสำหรับกฎระเบียบของรัฐในสหรัฐอเมริกา
- โหลดแท็ก Google Ads และ Analytics แบบมีเงื่อนไขตามสถานะโหมดความยินยอมของ Google ตามกฎระเบียบของสหภาพยุโรปของผู้ใช้
และอื่นๆ
นอกจากนี้ คุณยังใช้เครื่องมือเหล่านี้เพื่อรวบรวมความยินยอมของผู้ใช้โดยใช้โปรโตคอลมาตรฐานอุตสาหกรรมได้ด้วย
- ความยินยอมตาม GDPR โดยใช้ข้อกำหนด TCF เวอร์ชัน 2 ของ IAB
- การเลือกไม่ใช้ตามกฎระเบียบของรัฐในสหรัฐอเมริกาโดยใช้ข้อกำหนด GPP ของ IAB
ในกรณีเหล่านี้ ระบบจะสื่อสารสถานะความยินยอมผ่าน API เหล่านั้น
คุณสามารถติดตั้งใช้งานฟังก์ชันการรับส่งข้อความของผู้ใช้ในเว็บไซต์ได้ 2 วิธี ดังนี้
- ในกรณีส่วนใหญ่ คุณไม่จำเป็นต้องติดแท็กใหม่เลย เนื่องจากแท็กผู้เผยแพร่โฆษณาผ่าน Google หรือแท็ก AdSense ที่มีอยู่จะติดตั้งใช้งานข้อความสำหรับผู้ใช้เมื่อมีการเผยแพร่ข้อความในผลิตภัณฑ์ที่เกี่ยวข้อง
- หากใช้ข้อความการกู้คืนรายได้จากการบล็อกโฆษณา คุณต้องเพิ่มแท็กการบล็อกโฆษณาลงในหน้าเว็บอย่างชัดเจน ดูข้อมูลเพิ่มเติมได้ที่วิธีการติดแท็ก Ad Manager และ AdSense
googlefc คือเนมสเปซส่วนกลางที่ฟังก์ชันการรับส่งข้อความของผู้ใช้ใช้สำหรับ API ใน JavaScript Window
สรุปข้อมูลภาคสนาม
| ชื่อ | ประเภท | คำจำกัดความ |
|---|---|---|
googlefc.controlledMessagingFunction
|
function(!Object) | ฟังก์ชันที่กำหนดว่าจะดำเนินการต่อด้วยการรับส่งข้อความหรือไม่ ฟังก์ชันนี้รองรับข้อความทุกประเภท |
googlefc.callbackQueue
|
!Array<!Object<string, function()>> | !Array<function()> | !googlefc.CallbackQueue | การอ้างอิงคิว Callback สำหรับการดำเนินการแบบอะซิงโครนัสของคำค้นหาการรับส่งข้อความของผู้ใช้ |
googlefc.CallbackQueue
|
!Object | ประเภทของออบเจ็กต์คิว Callback |
googlefc.AdBlockerStatusEnum
|
!Object<string, number> | Enum เพื่อแสดงสถานะตัวบล็อกโฆษณาของผู้ใช้ |
googlefc.AllowAdsStatusEnum
|
!Object<string, number> | Enum เพื่อแสดงสถานะการอนุญาตโฆษณาของผู้ใช้ |
googlefc.usstatesoptout.InitialUsStatesOptOutStatusEnum
|
!Object<string, number> | Enum เพื่อแสดงสถานะการเลือกไม่ให้ความยินยอมของรัฐในสหรัฐอเมริกาเริ่มต้นของผู้ใช้ ซึ่งจะพิจารณารัฐในสหรัฐอเมริกาที่ผู้ใช้อาศัยอยู่ |
googlefc.GoogleFcConsentModeUserStatus
|
!Object |
ประเภทการแสดงผลสำหรับ googlefc.getGoogleConsentModeValues
|
googlefc.ConsentModePurposeStatusEnum
|
!Object<string, number> | Enum ที่แสดงถึงการตัดสินใจของผู้ใช้ปลายทางสำหรับวัตถุประสงค์ของโหมดความยินยอม |
googlefc.usstatesoptout.overrideDnsLink
|
undefined|boolean | บูลีนที่ตั้งค่าเป็น "จริง" ได้เพื่อใช้ลิงก์ "ไม่อนุญาตให้ขายหรือแชร์" ที่กำหนดเอง |
googlefc.ccpa.InitialCcpaStatusEnum
เดิม แนะนำ googlefc.usstatesoptout.InitialUsStatesOptOutStatusEnum
|
!Object<string, number> | Enum ที่แสดงสถานะกฎระเบียบของรัฐในสหรัฐอเมริกาเริ่มต้นของผู้ใช้ |
googlefc.ccpa.overrideDnsLink
เดิม แนะนำ googlefc.usstatesoptout.overrideDnsLink
|
undefined|boolean | บูลีนที่ตั้งค่าเป็น "จริง" ได้เพื่อใช้ลิงก์ "ไม่อนุญาตให้ขายหรือแชร์" ที่กำหนดเอง |
สรุปวิธีการ
| ชื่อ | ประเภทการแสดงผล | คำจำกัดความ |
|---|---|---|
googlefc.showRevocationMessage()
|
ไม่ได้กำหนด |
ล้างบันทึกความยินยอมและโหลดสคริปต์ googlefc ซ้ำเพื่อแสดงข้อความขอความยินยอมที่เกี่ยวข้องกับผู้ใช้
|
googlefc.getAdBlockerStatus()
|
ตัวเลข |
แสดงผลค่าใน AdBlockerStatusEnum โดยขึ้นอยู่กับสถานะการบล็อกโฆษณาของผู้ใช้
|
googlefc.getAllowAdsStatus()
|
ตัวเลข |
แสดงผลค่าใน AllowAdsStatusEnum โดยขึ้นอยู่กับสถานะการอนุญาตโฆษณาของผู้ใช้
|
googlefc.usstatesoptout.getInitialUsStatesOptOutStatus()
|
ตัวเลข |
แสดงผลค่าใน InitialUsStatesOptOutStatusEnum โดยขึ้นอยู่กับสถานะการเลือกไม่รับตามกฎระเบียบของรัฐในสหรัฐอเมริกาเริ่มต้นของผู้ใช้ ซึ่งจะพิจารณากฎระเบียบที่มีผลบังคับใช้กับผู้ใช้ตามตำแหน่งปัจจุบันของผู้ใช้
|
googlefc.usstatesoptout.openConfirmationDialog(function(boolean))
|
ไม่ได้กำหนด | เปิดกล่องโต้ตอบการยืนยันการเลือกไม่ใช้ตามกฎระเบียบของรัฐในสหรัฐอเมริกาหากมีการลบล้างลิงก์ "ไม่อนุญาตให้ขายหรือแชร์" เริ่มต้น |
googlefc.getGoogleConsentModeValues()
|
!Object |
แสดงผลออบเจ็กต์ googlefc.GoogleFcConsentModeUserStatus ที่มีค่าโหมดความยินยอมปัจจุบันของผู้ใช้ โดยมีค่า 1 ค่าสำหรับวัตถุประสงค์ของโหมดความยินยอมที่ใช้ได้แต่ละรายการ
|
googlefc.ccpa.getInitialCcpaStatus()
เดิม แนะนำ googlefc.usstatesoptout.getInitialUsStatesOptOutStatus()
|
ตัวเลข |
แสดงผลค่าใน InitialCcpaStatusEnum โดยขึ้นอยู่กับสถานะการเลือกไม่รับตามกฎระเบียบของรัฐในสหรัฐอเมริกาเริ่มต้นของผู้ใช้
|
googlefc.ccpa.openConfirmationDialog(function(boolean))
เดิม แนะนำ googlefc.usstatesoptout.openConfirmationDialog()
|
ไม่ได้กำหนด | เปิดกล่องโต้ตอบการยืนยันการเลือกไม่ใช้ตามกฎระเบียบของรัฐในสหรัฐอเมริกาหากมีการลบล้างลิงก์ "ไม่อนุญาตให้ขายหรือแชร์" เริ่มต้น |
การทดสอบและการแก้ไขข้อบกพร่องในเว็บไซต์
ความเป็นส่วนตัวและการแสดงข้อความแจ้งผู้ใช้มีฟังก์ชันการแก้ไขข้อบกพร่องและการทดสอบที่ช่วยให้คุณเห็นลักษณะของข้อความที่เฉพาะเจาะจง ข้อความประเภทย่อย หรือชุดข้อความต่างๆ ในเว็บไซต์จริง
สิ่งที่ต้องมีก่อน
- ข้อความที่ต้องการดูตัวอย่างต้องเผยแพร่ในเว็บไซต์ที่คุณกำลังทดสอบ
คุณดูตัวอย่างแบบเรียลไทม์ในเว็บไซต์ได้โดยใช้พารามิเตอร์ของ URL สำหรับการแก้ไขข้อบกพร่องต่อไปนี้
| พารามิเตอร์การแก้ไขข้อบกพร่อง | ค่าที่อนุญาต |
|---|---|
fc |
alwaysshow (เพื่อเรียกใช้โหมดแก้ไขข้อบกพร่อง/แสดงตัวอย่าง) |
fctype |
ab (ข้อความแจ้งว่ามีการบล็อกโฆษณา), ccpa (ข้อความแสดงการไม่ให้ความยินยอมตามกฎระเบียบของรัฐในสหรัฐอเมริกา), gdpr (ข้อความขอความยินยอมตาม GDPR), monetization (ข้อความ Offerwall), usfl (ข้อความแสดงการไม่ให้ความยินยอมตามกฎระเบียบของรัฐในสหรัฐอเมริกา เฉพาะฟลอริดา), usnat (ข้อความแสดงการไม่ให้ความยินยอมตามกฎระเบียบของรัฐในสหรัฐอเมริกา รัฐที่รองรับทั้งหมด ยกเว้นฟลอริดา เทียบเท่ากับ ccpa) |
ตัวอย่างวิธีใช้เพื่อแสดงตัวอย่างในเว็บไซต์ (foo.com) มีดังนี้
- ทดสอบการแสดงข้อความการเลือกไม่รับตามกฎระเบียบของรัฐในสหรัฐอเมริกา --
http://foo.com/?fc=alwaysshow&fctype=ccpa - ทดสอบการรับส่งข้อความ GDPR --
http://foo.com/?fc=alwaysshow&fctype=gdpr
ฟิลด์: คำอธิบายและตัวอย่าง
googlefc.controlledMessagingFunction {function(!Object)}
ฟังก์ชันที่กำหนดว่าจะแสดงข้อความหรือไม่ โดยสามารถใช้เพื่อจำกัดการแสดงผลข้อความตามเงื่อนไขที่ผู้เผยแพร่โฆษณาระบุ เช่น สถานะผู้สมัครใช้บริการหรือ URL ของหน้าเว็บ
เมื่อคุณกำหนด googlefc.controlledMessagingFunction ในหน้าต่างก่อนที่สคริปต์อื่นๆ จะโหลด ข้อความจะไม่แสดงจนกว่าคุณจะเรียกใช้ message.proceed(boolean) การเรียก message.proceed(true) จะทำให้การรับส่งข้อความดำเนินต่อไปตามปกติ ส่วนการเรียก message.proceed(false) จะป้องกันไม่ให้ข้อความแสดงสำหรับการดูหน้าเว็บ
ตัวอย่าง: สมมติว่าคุณมีสคริปต์นี้ในหน้าเว็บซึ่งกำหนดฟังก์ชัน determineIfUserIsSubscriber() แบบไม่พร้อมกันที่ตรวจสอบว่าผู้ใช้ที่เข้าสู่ระบบเป็นผู้สมัครใช้บริการหรือไม่
<head>
<script>
window.isSubscriber = undefined;
function determineIfUserIsSubscriber() {
if (isSubscriber !== undefined) {
return isSubscriber;
}
return new Promise(resolve => {
setTimeout(() => {
// Change this to true if you want to test what subscribers would see.
window.isSubscriber = false;
resolve(window.isSubscriber);
}, 1000);
});
}
</script>
</head>
นี่คือตัวอย่างวิธีใช้ googlefc.controlledMessagingFunction เพื่อแสดงข้อความต่อผู้ที่ไม่ได้เป็นสมาชิกเท่านั้น
<head>
<script>
// Define googlefc and the controlled messaging function on the Window.
window.googlefc = window.googlefc || {};
googlefc.controlledMessagingFunction = async (message) => {
// Determine if the user is a subscriber asynchronously.
const isSubscriber = await determineIfUserIsSubscriber();
if (isSubscriber) {
// If the user is a subscriber, don't show any messages.
message.proceed(false);
} else {
// Otherwise, show messages as usual.
message.proceed(true);
}
}
</script>
</head>
นอกจากนี้ยังมีส่วนขยายของฟีเจอร์นี้ที่ช่วยให้ผู้เผยแพร่โฆษณาระบุได้ว่าควรระงับเฉพาะข้อความบางประเภทเท่านั้น ใช้ส่วนขยายฟีเจอร์นี้เพื่อระงับข้อความบางประเภทโดยไม่ระงับข้อความประเภทอื่นๆ
การรับส่งข้อความที่มีการควบคุมเฉพาะประเภทข้อความทำได้โดยการส่งพารามิเตอร์เพิ่มเติมไปยัง message.proceed() ซึ่งเป็น Array ของประเภท googlefc.MessageTypeEnum
ตัวอย่าง: ตัวอย่างการใช้ googlefc.controlledMessagingFunction เพื่อระงับการแสดง Offerwall สำหรับสมาชิกเท่านั้น โดยไม่ระงับข้อความประเภทอื่นๆ
<head>
<script>
// Define googlefc and the controlled messaging function on the Window.
window.googlefc = window.googlefc || {};
googlefc.controlledMessagingFunction = async (message) => {
// Determine if the Offerwall should display or not.
const shouldDisplayOfferwall = await determineIfUserIsSubscriber();
const applicableMessageTypes = [];
if (!shouldDisplayOfferwall) {
// Do not show the Offerwall, but allow other message types to display.
applicableMessageTypes.push(window.googlefc.MessageTypeEnum.OFFERWALL);
message.proceed(false, applicableMessageTypes);
} else {
// Otherwise, show messages as usual.
message.proceed(true);
}
}
</script>
</head>
การอ้างอิงคิว Callback ทั่วโลกสำหรับการดำเนินการแบบอะซิงโครนัสของการเรียกที่เกี่ยวข้องกับการรับส่งข้อความ วิธีเดียวที่รองรับในการเรียกใช้ฟังก์ชันคือการเพิ่มฟังก์ชันลงใน callbackQueue
เนื่องจากข้อมูลประเภทต่างๆ จะพร้อมใช้งานในเวลาที่ต่างกัน จึงควรเพิ่มฟังก์ชันเป็นแผนที่ โดยใช้สตริงใดสตริงหนึ่งต่อไปนี้เป็นคีย์และฟังก์ชันที่จะดำเนินการเป็นค่า
คีย์ที่รองรับมีดังนี้
| ชื่อคีย์ | การใช้งาน | เวลาในการตอบสนองแบบสัมพัทธ์ |
|---|---|---|
CONSENT_API_READY
|
ระบบจะเรียกใช้ฟังก์ชันที่พุชไปยังคิว Callback ด้วยคีย์ CONSENT_API_READY เมื่อมีการกำหนด API สำหรับเฟรมเวิร์กความยินยอมที่รองรับและเรียกใช้ได้ จากจุดนี้เป็นต้นไป การดำเนินการของฟังก์ชันที่ใช้คีย์ CONSENT_API_READY ซึ่งเพิ่มเข้ามาในภายหลังจะเป็นแบบซิงโครนัส ดูรายละเอียดเฉพาะเฟรมเวิร์กได้ในส่วน เฟรมเวิร์กของ IAB
|
ต่ำ |
CONSENT_DATA_READY
|
ระบบจะเรียกใช้ฟังก์ชันที่พุชไปยังคิว Callback ด้วยคีย์ CONSENT_DATA_READY เมื่อทราบความยินยอมของผู้ใช้ที่รวบรวมภายใต้เฟรมเวิร์กความยินยอมที่รองรับ (จากการเรียกใช้ก่อนหน้าหรือเมื่อผู้ใช้โต้ตอบกับข้อความขอความยินยอม) จากจุดนี้เป็นต้นไป การดำเนินการของฟังก์ชันที่ใช้คีย์ CONSENT_DATA_READY ซึ่งเพิ่มเข้ามาในภายหลังจะเป็นแบบซิงโครนัส
|
สูง |
AD_BLOCK_DATA_READY
|
ระบบจะเรียกใช้ฟังก์ชันที่พุชไปยังคิว Callback ด้วยคีย์ AD_BLOCK_DATA_READY เมื่อข้อมูลการบล็อกโฆษณาพร้อมใช้งานในขั้นตอน จากจุดนี้เป็นต้นไป การดำเนินการของฟังก์ชันที่ใช้คีย์ AD_BLOCK_DATA_READY ซึ่งเพิ่มเข้ามาในภายหลังจะเป็นแบบซิงโครนัส
|
สูง |
CONSENT_MODE_DATA_READY
|
ระบบจะเรียกใช้ฟังก์ชันที่พุชไปยังคิว Callback ด้วยคีย์ CONSENT_MODE_DATA_READY เมื่อข้อมูล[โหมดความยินยอม](https://support.google.com/google-ads/answer/10000067)ของ Google (สําหรับใช้กับแท็ก Google Ads และ Analytics) พร้อมใช้งานในขั้นตอน เมื่อข้อมูลโหมดความยินยอมพร้อมแล้ว คุณจะเข้าถึงค่าโหมดความยินยอมได้ทุกเมื่อโดยใช้ googlefc.getGoogleConsentModeValues
|
ปานกลาง |
INITIAL_US_STATES_OPT_OUT_DATA_READY
|
ระบบจะเรียกใช้ฟังก์ชันที่พุชไปยังคิว Callback ด้วยคีย์ INITIAL_US_STATES_OPT_OUT_DATA_READY เมื่อข้อมูลกฎระเบียบของรัฐในสหรัฐอเมริกาพร้อมใช้งานในขั้นตอน โปรดทราบว่าคำขอข้อมูลกฎระเบียบของรัฐในสหรัฐอเมริกาที่ตามมาควรได้รับโดยการเรียกใช้ GPP API (__gpp) โดยตรง
|
ปานกลาง |
INITIAL_CCPA_DATA_READY
|
คีย์เดิมสำหรับกฎระเบียบของรัฐในสหรัฐอเมริกา แนะนำ INITIAL_US_STATES_OPT_OUT_DATA_READY ระบบจะเรียกใช้ฟังก์ชันที่พุชไปยังคิว Callback ด้วยคีย์ INITIAL_CCPA_DATA_READY เมื่อข้อมูลกฎระเบียบของรัฐในสหรัฐอเมริกาพร้อมใช้งานในขั้นตอน โปรดทราบว่าคำขอข้อมูลกฎระเบียบของรัฐในสหรัฐอเมริกาที่ตามมาควรได้รับโดยการเรียกใช้ GPP API (__gpp) โดยตรง
|
ปานกลาง |
googlefc.CallbackQueue {!Object}
สรุปวิธีการ:
| ชื่อ | ประเภท | พารามิเตอร์ | ประเภทการแสดงผล | บทบาท |
|---|---|---|---|---|
push(data)
|
ตัวเลข |
data: คู่คีย์-ค่าที่มีคีย์เป็นประเภทความพร้อมใช้งานของข้อมูลประเภทใดประเภทหนึ่ง และค่าเป็นฟังก์ชัน JavaScript ที่จะดำเนินการ
คีย์ความพร้อมใช้งานของข้อมูลที่ยอมรับได้คือ CONSENT_API_READY, CONSENT_DATA_READY, AD_BLOCK_DATA_READY, INITIAL_US_STATES_OPT_OUT_DATA_READY, CONSENT_MODE_DATA_READY และ (เดิม) INITIAL_CCPA_DATA_READY
|
จำนวนคำสั่งที่เพิ่มจนถึงตอนนี้ ซึ่งจะแสดงผลความยาวปัจจุบันของอาร์เรย์ | เรียกใช้ฟังก์ชันที่ส่งเข้ามาตามลำดับที่ข้อมูลพร้อมใช้งาน จากนั้นตามลำดับที่มีการเพิ่มฟังก์ชันเหล่านี้ลงในคิว |
ตัวอย่าง
<script>
// Make sure that the properties exist on the window.
window.googlefc = window.googlefc || {};
window.googlefc.usstatesoptout = window.googlefc.usstatesoptout || {};
window.googlefc.callbackQueue = window.googlefc.callbackQueue || [];
// Queue the callback on the callbackQueue.
googlefc.callbackQueue.push({
'AD_BLOCK_DATA_READY':
() => {
if (googlefc.getAdBlockerStatus() == googlefc.AdBlockerStatusEnum.NO_AD_BLOCKER) {
// Handle a non-ad blocking user.
}
}
});
</script>
googlefc.AdBlockerStatusEnum {!Object<string, number>}
แสดงสถานะการบล็อกโฆษณาต่างๆ ของผู้ใช้ สถานะต่างๆ มีดังนี้
googlefc.AdBlockerStatusEnum = {
// Something failed, in an unknown state.
UNKNOWN: 0,
// The user was running an extension level ad blocker.
EXTENSION_AD_BLOCKER: 1,
// The user was running a network level ad blocker.
NETWORK_LEVEL_AD_BLOCKER: 2,
// The user was not blocking ads.
NO_AD_BLOCKER: 3,
};
googlefc.AllowAdsStatusEnum {!Object<string, number>}
แสดงสถานะการอนุญาตโฆษณาที่แตกต่างกันของผู้ใช้ที่บล็อกโฆษณา สถานะต่างๆ มีดังนี้
googlefc.AllowAdsStatusEnum = {
// Something failed, in an unknown state.
UNKNOWN: 0,
// User is currently using an ad blocker, was never using an ad blocker, or
// allowed ads, but not because they saw the Privacy & messaging message.
ADS_NOT_ALLOWED: 1,
// User is no longer using an ad blocker after seeing the ad blocking message.
ADS_ALLOWED: 2,
};
googlefc.usstatesoptout.InitialUsStatesOptOutStatusEnum{!Object<string, number>}
แสดงสถานะการเลือกไม่ให้ความยินยอมตามกฎระเบียบของรัฐในสหรัฐอเมริกาของผู้ใช้ สถานะต่างๆ มีดังนี้
googlefc.usstatesoptout.InitialUsStatesOptOutStatusEnum = {
// Something failed, status unknown.
UNKNOWN: 0,
// No US state regulation applies to this user.
DOES_NOT_APPLY: 1,
// A US state regulation applies to this user, and the user has not opted out yet.
NOT_OPTED_OUT: 2,
// A US state regulation applies to this user, and the user has opted out.
OPTED_OUT: 3,
};
googlefc.GoogleFcConsentModeUserStatus{!Object}
ประเภทของออบเจ็กต์ที่แสดงผลโดย googlefc.getGoogleConsentModeValues
interface GoogleFcConsentModeUserStatus {
// End user consent decision value for the ad_storage consent mode purpose.
adStoragePurposeConsentStatus: number;
// End user consent decision value for the ad_user_data consent mode purpose.
adUserDataPurposeConsentStatus: number;
// End user consent decision value for the ad_personalization consent mode purpose.
adPersonalizationPurposeConsentStatus: number;
// End user consent decision value for the analytics_storage consent mode purpose.
analyticsStoragePurposeConsentStatus: number;
}
ค่าของแต่ละฟิลด์คือตัวเลขที่สอดคล้องกับค่า enum ของ googlefc.ConsentModePurposeStatusEnum
googlefc.ConsentModePurposeStatusEnum{!Object<string, number>}
แสดงค่าความยินยอมของผู้ใช้ปลายทางที่เป็นไปได้ต่างๆ สำหรับวัตถุประสงค์ของโหมดความยินยอม ค่าต่างๆ มีดังนี้
googlefc.ConsentModePurposeStatusEnum = {
// Indicates either an error state, or that consent mode data is not ready
// yet.
UNKNOWN: 0,
// Consent is granted for the given consent mode purpose.
GRANTED: 1,
// Consent is denied for the given consent mode purpose.
DENIED: 2,
// Consent is not applicable for the given consent mode purpose.
NOT_APPLICABLE: 3,
// The consent mode purpose has not been configured for use in the Privacy &
// messaging UI.
NOT_CONFIGURED: 4
};
googlefc.usstatesoptout.overrideDnsLink{undefined|boolean}
ตั้งค่าช่องนี้เป็น "จริง" เพื่อซ่อนลิงก์ "ห้ามขายหรือแชร์" เริ่มต้น และใช้ลิงก์ "ห้ามขายหรือแชร์" ที่กำหนดเอง โปรดทราบว่าฟังก์ชันการทำงานนี้ ใช้ได้ใน Ad Manager เท่านั้น
ตัวอย่าง
<script>
// Make sure that the properties exist on the window.
window.googlefc = window.googlefc || {};
window.googlefc.usstatesoptout = window.googlefc.usstatesoptout || {};
// Signals that the default DNS link will be overridden.
googlefc.usstatesoptout.overrideDnsLink = true;
</script>
googlefc.ccpa.InitialCcpaStatusEnum{!Object<string, number>}
แสดงสถานะการเลือกไม่ให้ความยินยอมตามกฎระเบียบของรัฐในสหรัฐอเมริกาของผู้ใช้ สถานะต่างๆ มีดังนี้
googlefc.ccpa.InitialCcpaStatusEnum = {
// Something failed, in an unknown state.
UNKNOWN: 0,
// No US state regulation applies to this user.
CCPA_DOES_NOT_APPLY: 1,
// A US state regulation applies to this user, and the user has not opted out yet.
NOT_OPTED_OUT: 2,
// A US state regulation applies to this user, and the user has opted out.
OPTED_OUT: 3,
};
googlefc.ccpa.overrideDnsLink{undefined|boolean}
ตั้งค่าช่องนี้เป็น "จริง" เพื่อซ่อนลิงก์ "ห้ามขายหรือแชร์" เริ่มต้น และใช้ลิงก์ "ห้ามขายหรือแชร์" ที่กำหนดเอง โปรดทราบว่าหากตั้งค่าช่องนี้เป็น "จริง" คุณจะต้องรับผิดชอบในการแสดงผลลิงก์ "ห้ามขายหรือแชร์" ในเว็บไซต์ ควรใช้ช่องนี้ร่วมกับ openConfirmationDialog นอกจากนี้ Ad Manager ยังรองรับเฉพาะการใช้ลิงก์ "ไม่อนุญาตให้ขายหรือแชร์" ที่กำหนดเองสำหรับฟังก์ชันการรับส่งข้อความ "กฎระเบียบของรัฐในสหรัฐอเมริกา" เท่านั้น
ตัวอย่าง
<script>
// Make sure that the properties exist on the window.
window.googlefc = window.googlefc || {};
window.googlefc.ccpa = window.googlefc.ccpa || {};
// Signals that the default DNS link will be overridden.
googlefc.ccpa.overrideDnsLink = true;
</script>
วิธีการ: คำอธิบายและตัวอย่าง
googlefc.getConsentStatus(): {number}
googlefc.getConsentedProviderIds(): {!Array<string>}
- ตอนนี้เมธอดนี้จะแสดงรายการว่างเสมอเมื่อมีการเรียกใช้
googlefc.showRevocationMessage(): {undefined}
ล้างบันทึกความยินยอมตามกฎระเบียบของสหภาพยุโรปในปัจจุบัน (หากมี) และแสดงข้อความเกี่ยวกับกฎระเบียบของสหภาพยุโรปอีกครั้งเพื่อให้ผู้ใช้เปลี่ยนการตัดสินใจให้ความยินยอมได้
ตัวอย่างที่ 1: ตัวอย่างง่ายๆ ของการตั้งค่าลิงก์ที่จะแสดงข้อความเพิกถอนเมื่อคลิก
<a href="javascript:window.googlefc.showRevocationMessage();">Privacy and cookie settings</a>
<a href="javascript:window.googlefc.showRevocationMessage();" style="display: none;" id="revocation-link">Privacy and cookie settings</a>
<script>
window.googlefc = window.googlefc || {};
window.googlefc.callbackQueue = window.googlefc.callbackQueue || [];
window.googlefc.callbackQueue.push({
'CONSENT_API_READY':
() => {
// Update the revocation link so that it shows on the page.
const revocationLink = document.getElementById('revocation-link');
revocationLink.style.display = 'block';
}
});
</script>
ตัวอย่างที่ 2: หากต้องการให้ลิงก์ปรากฏเฉพาะเมื่อกฎระเบียบของสหภาพยุโรปมีผลกับผู้ใช้ปัจจุบัน คุณสามารถใช้คิว Callback ของ googlefc กับ TCF API เพื่ออัปเดตการแสดงปุ่มตามเงื่อนไขโดยอิงตามค่า gdprApplies เมื่อกำหนดแล้ว โดยใช้คีย์ API ของ CONSENT_API_READY
<a href="javascript:window.googlefc.showRevocationMessage();" style="display: none;" id="revocation-link">Privacy and cookie settings</a>
<script>
window.googlefc = window.googlefc || {};
window.googlefc.callbackQueue = window.googlefc.callbackQueue || [];
window.googlefc.callbackQueue.push({
'CONSENT_API_READY':
// Specifying "0" for the version parameter will result in the API call
// using the latest version of the TCF spec.
() => __tcfapi('addEventListener', 0, (tcdata, success) => {
const revocationLink = document.getElementById('revocation-link');
if (!success || !tcdata) {
// Something went wrong, don't show the revocation link.
revocationLink.style.display = 'none';
}
else if (tcdata.gdprApplies) {
revocationLink.style.display = 'block';
} else {
// GDPR does not apply so don't show the revocation link.
revocationLink.style.display = 'none';
}
})
});
</script>
googlefc.getAdBlockerStatus(): {number}
แสดงค่าใน AdBlockerStatusEnum โดยขึ้นอยู่กับสถานะการบล็อกโฆษณาของผู้ใช้ คีย์ที่ควรระบุสำหรับฟังก์ชันนี้คือ AD_BLOCK_DATA_READY
ตัวอย่าง
<script>
// Make sure that the properties exist on the window.
window.googlefc = window.googlefc || {};
window.googlefc.usstatesoptout = window.googlefc.usstatesoptout || {};
window.googlefc.callbackQueue = window.googlefc.callbackQueue || [];
// Queue the callback on the callbackQueue.
googlefc.callbackQueue.push({
'AD_BLOCK_DATA_READY':
() => {
switch (googlefc.getAdBlockerStatus()) {
case googlefc.AdBlockerStatusEnum.EXTENSION_LEVEL_AD_BLOCKER:
case googlefc.AdBlockerStatusEnum.NETWORK_LEVEL_AD_BLOCKER:
// Insert handling for cases where the user is blocking ads.
break;
case googlefc.AdBlockerStatusEnum.NO_AD_BLOCKER:
// Insert handling for cases where the user is not blocking ads.
break;
case googlefc.AdBlockerStatusEnum.UNKNOWN:
// Insert handling for unknown cases.
break;
}
}
});
</script>
googlefc.getAllowAdsStatus(): {number}
แสดงผลค่าใน AllowAdsStatusEnum โดยขึ้นอยู่กับสถานะการอนุญาตโฆษณาของผู้ใช้ คีย์ที่ควรระบุสำหรับฟังก์ชันนี้คือ AD_BLOCK_DATA_READY
ตัวอย่าง
<script>
// Make sure that the properties exist on the window.
window.googlefc = window.googlefc || {};
window.googlefc.usstatesoptout = window.googlefc.usstatesoptout || {};
window.googlefc.callbackQueue = window.googlefc.callbackQueue || [];
// Queue the callback on the callbackQueue.
googlefc.callbackQueue.push({
'AD_BLOCK_DATA_READY':
() => {
switch (googlefc.getAllowAdsStatus()) {
case googlefc.AllowAdsStatusEnum.ADS_NOT_ALLOWED:
// Insert handling for cases where the user has not allowed ads.
// The user may have never been an ad blocker.
break;
case googlefc.AllowAdsStatusEnum.ADS_ALLOWED:
// Insert handling for cases where the user saw the ad blocking
// message and allowed ads on the site.
break;
case googlefc.AllowAdsStatusEnum.UNKNOWN:
// Insert handling for unknown cases.
break;
}
}
});
</script>
googlefc.usstatesoptout.getInitialUsStatesOptOutStatus(): {number}
แสดงผลค่าใน InitialUsStatesOptOutStatusEnum โดยขึ้นอยู่กับสถานะการเลือกไม่ใช้ตามกฎระเบียบของรัฐในสหรัฐอเมริกาของผู้ใช้ คีย์ที่ควรระบุสำหรับฟังก์ชันนี้คือ INITIAL_US_STATES_OPT_OUT_DATA_READY โปรดทราบว่าคำขอข้อมูลเกี่ยวกับกฎระเบียบของรัฐในสหรัฐอเมริกาที่ตามมาควรได้รับจากการเรียกใช้ GPP API (__gpp) โดยตรง
หากคุณลบล้างลิงก์ "ห้ามขายหรือแชร์" คุณสามารถใช้วิธีนี้เพื่อกำหนดเวลาที่จะรวมลิงก์ในเว็บไซต์ได้
ตัวอย่าง
<script>
// Make sure that the properties exist on the window.
window.googlefc = window.googlefc || {};
window.googlefc.usstatesoptout = window.googlefc.usstatesoptout || {}
window.googlefc.callbackQueue = window.googlefc.callbackQueue || [];
// Queue the callback on the callbackQueue.
googlefc.callbackQueue.push({
'INITIAL_US_STATES_OPT_OUT_DATA_READY':
() => {
switch (googlefc.usstatesoptout.getInitialUsStatesOptOutStatus()) {
case googlefc.usstatesoptout.InitialUsStatesOptOutStatusEnum.DOES_NOT_APPLY:
// Insert handling for cases where no US state regulation applies to
// the user.
break;
case googlefc.usstatesoptout.InitialUsStatesOptOutStatusEnum.NOT_OPTED_OUT:
// Insert handling for cases where a US state regulation applies to
// the user, and the user has not opted out.
break;
case googlefc.usstatesoptout.InitialUsStatesOptOutStatusEnum.OPTED_OUT:
// Insert handling for cases where a US state regulation applies to the
// user, and the user has opted out.
break;
}
}
});
</script>
googlefc.usstatesoptout.openConfirmationDialog(function(boolean)): {undefined}
เปิดกล่องโต้ตอบการยืนยันการเลือกไม่ใช้ตามกฎระเบียบของรัฐในสหรัฐอเมริกาหากมีการลบล้างลิงก์ "ไม่ขาย" เริ่มต้น เมื่อผู้ใช้โต้ตอบกับกล่องโต้ตอบการยืนยัน ระบบจะเรียกใช้ฟังก์ชัน Callback ที่ระบุด้วย true หากผู้ใช้ตัดสินใจเลือกไม่ใช้ และ false ในกรณีอื่นๆ
ตัวอย่าง
<script>
// This callback will be called with the user's US state regulation opt-out
// decision.
const usStateRegCompletionCallback = (userOptedOut) => {
// Insert handling for user opt-out status here.
}
// Invoke the US state regulations confirmation dialog when the user clicks the
// link.
document.getElementById("your-custom-do-not-sell-link").addEventListener(
"click", () => googlefc.usstatesoptout.openConfirmationDialog(usStateRegCompletionCallback));
</script>
googlefc.getGoogleConsentModeValues(): {!Object}
แสดงผลออบเจ็กต์ googlefc.GoogleFcConsentModeUserStatus ที่มีค่าปัจจุบันของวัตถุประสงค์ของโหมดความยินยอมแต่ละรายการ โดยอิงตามการตัดสินใจให้ความยินยอมของผู้ใช้
ดูการใช้งานที่ต้องการได้ที่การใช้โซลูชันการจัดการความยินยอมของ Google ที่รองรับโหมดความยินยอมสำหรับกฎระเบียบของสหภาพยุโรป
googlefc.ccpa.getInitialCcpaStatus(): {number}
แสดงผลค่าใน InitialCcpaStatusEnum โดยขึ้นอยู่กับสถานะการเลือกไม่ใช้กฎระเบียบของรัฐในสหรัฐอเมริกาของผู้ใช้ คีย์ที่ควรระบุสำหรับฟังก์ชันนี้คือ INITIAL_CCPA_DATA_READY โปรดทราบว่าคำขอข้อมูลกฎระเบียบของรัฐในสหรัฐอเมริกาที่ตามมาควรได้รับโดยการเรียกใช้ GPP API (__gpp) โดยตรง
ตัวอย่าง
<script>
// Make sure that the properties exist on the window.
window.googlefc = window.googlefc || {};
window.googlefc.ccpa = window.googlefc.ccpa || {}
window.googlefc.callbackQueue = window.googlefc.callbackQueue || [];
// Queue the callback on the callbackQueue.
googlefc.callbackQueue.push({
'INITIAL_CCPA_DATA_READY':
() => {
switch (googlefc.ccpa.getInitialCcpaStatus()) {
case googlefc.ccpa.InitialCcpaStatusEnum.CCPA_DOES_NOT_APPLY:
// Insert handling for cases where no US state regulation applies to
// the user.
break;
case googlefc.ccpa.InitialCcpaStatusEnum.NOT_OPTED_OUT:
// Insert handling for cases where a US state regulation applies to
// the user, and the user has not opted out.
break;
case googlefc.ccpa.InitialCcpaStatusEnum.OPTED_OUT:
// Insert handling for cases where a US state regulation applies to the
// user, and the user has opted out.
break;
}
}
});
</script>
googlefc.ccpa.openConfirmationDialog(function(boolean)): {undefined}
เปิดกล่องโต้ตอบการยืนยันการเลือกไม่ใช้ตามกฎระเบียบของรัฐในสหรัฐอเมริกาหากมีการลบล้างลิงก์ "ไม่ขาย" เริ่มต้น เมื่อผู้ใช้โต้ตอบกับกล่องโต้ตอบการยืนยัน ระบบจะเรียกใช้ฟังก์ชัน Callback ที่ระบุด้วย true หากผู้ใช้เลือกไม่รับ และ false ในกรณีอื่นๆ
ตัวอย่าง
<script>
// This callback will be called with the user's US state regulation opt-out
// decision.
const usStateRegCompletionCallback = (userOptedOut) => {
// Insert handling for user opt-out status here.
}
// Invoke the US state regulations confirmation dialog when the user clicks the
// link.
document.getElementById("your-custom-ccpa-do-not-sell-link").addEventListener(
"click", () => googlefc.ccpa.openConfirmationDialog(ccpaCompletionCallback));
</script>
การใช้โซลูชันการจัดการความยินยอมของ Google กับ TCF เวอร์ชัน 2 ของ IAB สำหรับ GDPR
หากคุณใช้โซลูชันการจัดการความยินยอมของ Google เพื่อรวบรวมความยินยอมตาม GDPR ภายใต้กรอบ TCF เวอร์ชัน 2 ของ IAB คุณควรใช้ API ของ TCF เวอร์ชัน 2 ของ IAB
คุณสามารถใช้คีย์คิว Callback CONSENT_API_READY เพื่อให้แน่ใจว่าระบบจะเรียกใช้ Callback ที่เกี่ยวข้องเฉพาะเมื่อมีการกำหนด API ของ TCF เวอร์ชัน 2 ของ IAB ในหน้าเว็บ ซึ่งควรใช้ร่วมกับคำสั่ง 'addEventListener' ของ API ของ TCF เวอร์ชัน 2 ของ IAB
ตัวอย่าง
<script>
// Make sure that the properties exist on the window.
window.googlefc = window.googlefc || {};
window.googlefc.callbackQueue = window.googlefc.callbackQueue || [];
// Queue the callback using the CONSENT_API_READY key on the callbackQueue.
window.googlefc.callbackQueue.push({
'CONSENT_API_READY':
() => __tcfapi('addEventListener', 2.2, (data, success) => {
// Do something with consent data value; this callback may be invoked
// multiple times as user completes consent flow.
})
});
</script>
คุณสามารถใช้คีย์คิว Callback CONSENT_DATA_READY
เพื่อให้แน่ใจว่าระบบจะเรียกใช้ Callback ที่เกี่ยวข้องเมื่อรวบรวมความยินยอมของผู้ใช้และเข้าถึงได้โดยใช้ API ของ TCF เวอร์ชัน 2 ของ IAB เท่านั้น
ซึ่งสามารถใช้ร่วมกับคำสั่ง 'addEventListener' ได้ โดยข้อมูลที่ระบุในการเรียกใช้ครั้งแรกของ Callback ที่คุณระบุจะมีตัวเลือกความยินยอมของผู้ใช้ (ตราบใดที่ TCF เวอร์ชัน 2 มีผลกับผู้ใช้รายนี้) โปรดทราบว่าเมื่อมีการเปิดตัว TCF เวอร์ชัน 2.2 เราจะเลิกใช้งานคำสั่ง 'getTCData'
ตัวอย่าง
<script>
// Make sure that the properties exist on the window.
window.googlefc = window.googlefc || {};
window.googlefc.callbackQueue = window.googlefc.callbackQueue || [];
// Queue the callback using the CONSENT_DATA_READY key on the callbackQueue.
window.googlefc.callbackQueue.push({
'CONSENT_DATA_READY':
() => __tcfapi('addEventListener', 2.2, (data, success) => {
// Do something with consent data value; this callback may be invoked
// multiple times if user consent selections change.
})
});
</script>
การใช้โซลูชันการจัดการความยินยอมของ Google ที่รองรับโหมดความยินยอมสำหรับกฎระเบียบของสหภาพยุโรป
โซลูชันการจัดการความยินยอมของ Google สามารถตีความตัวเลือกความยินยอมตามกฎระเบียบของสหภาพยุโรปของผู้ใช้สำหรับโหมดความยินยอมของ Google (ดูข้อมูลเพิ่มเติมได้ในศูนย์ช่วยเหลือ)
คุณสามารถใช้โหมดความยินยอมได้ทั้งในโหมดพื้นฐานหรือโหมดขั้นสูงตามที่อธิบายไว้ในเอกสารประกอบของ Google Ads และ Analytics คุณควรปรึกษาฝ่ายกฎหมายเกี่ยวกับโหมดความยินยอมที่จะใช้เพื่อให้เป็นไปตามข้อกำหนดทางกฎหมาย
ระบบรองรับโหมดความยินยอมขั้นสูงโดยค่าเริ่มต้น เมื่อเปิดใช้โหมดความยินยอมใน UI ความเป็นส่วนตัวและการแสดงข้อความแจ้งผู้ใช้แล้ว คุณไม่จำเป็นต้องดำเนินการใดๆ เพิ่มเติม
หากต้องการใช้โหมดความยินยอมพื้นฐานโดยใช้โซลูชันการจัดการความยินยอมของ Google คุณสามารถใช้คีย์คิว Callback CONSENT_MODE_DATA_READY เพื่อโหลดแท็ก Google Ads และ Analytics แบบมีเงื่อนไขเมื่อมีข้อมูลโหมดความยินยอม
ข้อมูลโหมดความยินยอมจะพร้อมใช้งานหลังจาก Funding Choices พิจารณาแล้วว่าโหมดความยินยอมไม่มีผลกับคำขอนี้ (เช่น เนื่องจากกฎระเบียบของสหภาพยุโรปไม่มีผลกับคำขอนี้) หรือหลังจากที่ผู้ใช้ได้ตัดสินใจให้ความยินยอมตามกฎระเบียบของสหภาพยุโรปแล้ว คุณควรปรึกษาฝ่ายกฎหมายเกี่ยวกับเกณฑ์ที่จะใช้เพื่อพิจารณาว่าสามารถโหลดแท็กได้หรือไม่เมื่อโหมดความยินยอมพร้อมใช้งาน
ตัวอย่างเช่น หากต้องการโหลดแท็กเมื่อมีข้อมูลโหมดความยินยอม ไม่ว่าผู้ใช้ปลายทางจะตัดสินใจให้ความยินยอมหรือไม่ก็ตาม ให้ใช้โค้ดต่อไปนี้
<script>
// Make sure that the properties exist on the window.
window.googlefc = window.googlefc || {};
window.googlefc.callbackQueue = window.googlefc.callbackQueue || [];
// Helper function to load Google Ads/Analytics tags once consent mode data is
// ready.
const loadGtagScript = () => {
// Load gtag.js script - code taken from
// https://developers.google.com/tag-platform/security/guides/consent?consentmode=basic#set_up_consent_mode
var gtagScript = document.createElement('script');
gtagScript.async = true;
gtagScript.src = 'https://www.googletagmanager.com/gtag/js?id=<Google tag ID>';
var firstScript = document.getElementsByTagName('script')[0];
firstScript.parentNode.insertBefore(gtagScript,firstScript);
}
// Queue the callback using the CONSENT_MODE_DATA_READY key on the callbackQueue.
window.googlefc.callbackQueue.push({
'CONSENT_MODE_DATA_READY':
() => {
loadGtagScript();
},
});
</script>
นอกจากนี้ คุณยังใช้ googlefc.getGoogleConsentModeValues() API เพื่อรับค่าของวัตถุประสงค์ของโหมดความยินยอมแต่ละรายการได้เมื่อมีข้อมูลโหมดความยินยอม
API นี้จะแสดงผลออบเจ็กต์ GoogleFcConsentModeUserStatus ที่มี 1 ช่องสำหรับวัตถุประสงค์ของโหมดความยินยอมแต่ละรายการที่รองรับ และค่าของแต่ละช่องจะเป็นค่า enum ที่ระบุค่าของวัตถุประสงค์ของโหมดความยินยอมนั้น
เช่น คุณสามารถใช้ googlefc.getGoogleConsentModeValues() เพื่อเลิกบล็อกแท็ก Google Ads และ Analytics ได้เฉพาะในกรณีต่อไปนี้
- ผู้ใช้ปลายทางตัดสินใจให้ความยินยอมตามกฎระเบียบของสหภาพยุโรป ซึ่งส่งผลให้มีการให้ความยินยอมสำหรับวัตถุประสงค์ทั้งหมดของโหมดความยินยอม หรือ
- วัตถุประสงค์ทั้งหมดของโหมดความยินยอมไม่เกี่ยวข้องกับคำขอปัจจุบัน (ซึ่งอาจเกิดขึ้นได้หากกฎระเบียบของสหภาพยุโรปไม่มีผลบังคับใช้หรือไม่ได้กำหนดค่าโหมดความยินยอมสำหรับวัตถุประสงค์อย่างน้อย 1 รายการในความเป็นส่วนตัวและการแสดงข้อความแจ้งผู้ใช้)
<script>
// Make sure that the properties exist on the window.
window.googlefc = window.googlefc || {};
window.googlefc.callbackQueue = window.googlefc.callbackQueue || [];
// Helper function to determine whether Google Ads and Analytics tags can be
// unblocked. Returns true if all consent mode purposes are set to GRANTED,
// NOT_APPLICABLE, or NOT_CONFIGURED.
const shouldUnblockConsentTags = (googleFcConsentModeStatus) => {
const allConsentModeValues = [
googleFcConsentModeStatus.adStoragePurposeConsentStatus,
googleFcConsentModeStatus.adUserDataPurposeConsentStatus,
googleFcConsentModeStatus.adPersonalizationPurposeConsentStatus,
googleFcConsentModeStatus.analyticsStoragePurposeConsentStatus
];
for (const consentModeValue of allConsentModeValues) {
switch (consentModeValue) {
case googlefc.ConsentModePurposeStatusEnum.CONSENT_MODE_PURPOSE_STATUS_UNKNOWN:
// Indicates either an error case or that consent mode data is not
// ready yet. Cannot unblock tags until consent data is ready and valid,
// so return false.
return false;
case googlefc.ConsentModePurposeStatusEnum.CONSENT_MODE_PURPOSE_STATUS_GRANTED:
// Consent is granted for this consent mode purpose.
break;
case googlefc.ConsentModePurposeStatusEnum.CONSENT_MODE_PURPOSE_STATUS_DENIED:
// Consent is denied for this consent mode purpose. Do not unblock tags.
return false;
case googlefc.ConsentModePurposeStatusEnum.CONSENT_MODE_PURPOSE_STATUS_NOT_APPLICABLE:
// Consent mode does not apply for this purpose.
break;
case googlefc.ConsentModePurposeStatusEnum.CONSENT_MODE_PURPOSE_STATUS_NOT_CONFIGURED:
// Consent mode not configured for this purpose.
// If you configured support for Ads purposes but not Analytics purposes in the
// Privacy & messaging UI, the value of `analyticsStoragePurposeConsentStatus` will
// always be set to NOT_CONFIGURED. If you do not enable any Consent Mode support
// in the Privacy & messaging UI, the values of all purposes will always be set to
// NOT_CONFIGURED.
break;
default:
console.log("Unexpected consent mode value encountered");
}
}
// If all prior checks pass, all consent mode values are either GRANTED,
// NOT_APPLICABLE, or NOT_CONFIGURED.
return true;
};
// Helper function to load Google Ads/Analytics tags.
const loadGtagScript = () => {
// Load gtag.js script - code taken from
// https://developers.google.com/tag-platform/security/guides/consent?consentmode=basic#set_up_consent_mode
var gtagScript = document.createElement('script');
gtagScript.async = true;
gtagScript.src = 'https://www.googletagmanager.com/gtag/js?id=<Google tag ID>';
var firstScript = document.getElementsByTagName('script')[0];
firstScript.parentNode.insertBefore(gtagScript,firstScript);
}
googlefc.callbackQueue.push({
CONSENT_MODE_DATA_READY: () => {
if (shouldUnblockConsentTags(googlefc.getGoogleConsentModeValues())) {
loadGtagScript();
}
},
});
</script>
การใช้โซลูชันการจัดการความยินยอมของ Google กับเฟรมเวิร์ก GPP ของ IAB สำหรับกฎระเบียบของรัฐในสหรัฐอเมริกา
หากคุณใช้โซลูชันการจัดการความยินยอมของ Google เพื่อแสดงข้อความเลือกไม่รับตามกฎระเบียบของรัฐในสหรัฐอเมริกาต่อผู้ใช้ปลายทางภายใต้เฟรมเวิร์ก IAB GPP คุณควรใช้ IAB GPP API
เนื่องจากลักษณะการเลือกไม่ใช้ของกฎระเบียบระดับรัฐในสหรัฐอเมริกา คุณอาจใช้คีย์คิว Callback CONSENT_API_READY หรือ CONSENT_DATA_READY เพื่อให้แน่ใจว่า GPP API ของ IAB สามารถเรียกใช้ได้และแสดงผลข้อมูลความยินยอมเมื่อมีการเรียกใช้ Callback
<script>
// Make sure that the properties exist on the window.
window.googlefc = window.googlefc || {};
window.googlefc.usstatesoptout = window.googlefc.usstatesoptout || {};
window.googlefc.callbackQueue = window.googlefc.callbackQueue || [];
// Queue the callback on the callbackQueue.
window.googlefc.callbackQueue.push({
'CONSENT_DATA_READY':
() => __gpp('ping', (data, success) => {
// Do something with consent data value.
})
});
</script>
การใช้โซลูชันการจัดการความยินยอมของ Google กับกรอบ GPP ของ IAB สำหรับกฎระเบียบของรัฐในสหรัฐอเมริกาที่มีลิงก์ "ไม่อนุญาตให้ขายหรือแชร์" ที่กำหนดเองของคุณเอง
หากคุณใช้โซลูชันการจัดการความยินยอมของ Google เพื่อแสดงข้อความเลือกไม่ใช้ตามกฎระเบียบของรัฐในสหรัฐอเมริกาต่อผู้ใช้ปลายทางภายใต้เฟรมเวิร์ก IAB GPP คุณสามารถระบุลิงก์ "ห้ามขายหรือแชร์" ที่กำหนดเองได้โดยตั้งค่าแฟล็ก googlefc.usstatesoptout.overrideDnsLink เป็น true
<script>
// Make sure that the properties exist on the window.
window.googlefc = window.googlefc || {};
window.googlefc.usstatesoptout = window.googlefc.usstatesoptout || {};
window.googlefc.callbackQueue = window.googlefc.callbackQueue || [];
// Signals that the default DNS link will be overridden.
window.googlefc.usstatesoptout.overrideDnsLink = true;
// Register the callback for the initial US state regulations data.
window.googlefc.callbackQueue.push({
'INITIAL_US_STATES_OPT_OUT_DATA_READY': () => {
if (googlefc.usstatesoptout.getInitialUsStatesOptOutStatus() ===
googlefc.usstatesoptout.InitialUsStatesOptOutStatusEnum.NOT_OPTED_OUT) {
// TODO: Display custom Do Not Sell or Share link here.
}
}
});
</script>
วิธีนี้ช่วยให้มั่นใจได้ว่าลิงก์ "ห้ามขายหรือแชร์" เริ่มต้นจะไม่แสดง จากนั้น คุณต้องจัดการการโต้ตอบของผู้ใช้กับลิงก์ "ไม่อนุญาตให้ขายหรือแชร์" ที่กำหนดเองโดยเรียกใช้กล่องโต้ตอบการยืนยันการเลือกไม่ใช้ตามกฎระเบียบของรัฐในสหรัฐอเมริกา
โปรดทราบว่าเมื่อใช้ลิงก์ "ไม่อนุญาตให้ขายหรือแชร์" ที่กำหนดเอง คุณมีหน้าที่ตรวจสอบว่าลิงก์เป็นไปตามกฎระเบียบของรัฐในสหรัฐอเมริกา นอกจากนี้ การใช้ลิงก์ "ไม่อนุญาตให้ขายหรือแชร์" ที่กำหนดเองสำหรับฟังก์ชันการรับส่งข้อความ "กฎระเบียบของรัฐในสหรัฐอเมริกา" จะรองรับเฉพาะใน Ad Manager เท่านั้น
<script>
// This callback will be called when the user makes a US state regulations
// decision.
const usStateRegCompletionCallback = (userOptedOut) => {
if (userOptedOut) {
// TODO: Hide custom Do Not Sell or Share link here.
}
}
// Invoke the US state regulations opt-out confirmation dialog when the user
// clicks the link.
document.getElementById("your-custom-do-not-sell-link").addEventListener(
"click", () => googlefc.usstatesoptout.openConfirmationDialog(usStateRegCompletionCallback));
</script>