ผู้ผลิตเนื้อหาและผู้ลงโฆษณาจำนวนมากต้องการทราบจำนวนผู้ที่ไม่ซ้ำกันที่เห็นเนื้อหาของตน ใช้ Shared Storage เพื่อบันทึกครั้งแรกที่ผู้ใช้เห็นโฆษณา วิดีโอที่ฝัง หรือสิ่งพิมพ์ของคุณ และป้องกันการนับผู้ใช้รายเดียวกันซ้ำในเว็บไซต์ต่างๆ จากนั้นคุณจะใช้ Private Aggregation API เพื่อแสดงรายงานสรุปสำหรับการเข้าถึงได้
Shared Storage API เป็นข้อเสนอของ Privacy Sandbox สำหรับพื้นที่เก็บข้อมูลแบบข้ามเว็บไซต์อเนกประสงค์ ซึ่งรองรับ Use Case ที่เป็นไปได้มากมาย Private Aggregation API คือเอาต์พุตที่มีอยู่ใน Shared Storage ซึ่งช่วยให้คุณรวมข้อมูลข้ามเว็บไซต์ได้ ดูข้อมูลเพิ่มเติมเกี่ยวกับวิธีใช้การวัดเหล่านี้ได้ในสมุดปกขาวเกี่ยวกับการเข้าถึง
ลองใช้การวัด Unique Reach
หากต้องการทดลองใช้การวัดการเข้าถึงที่ไม่ซ้ำกับ Shared Storage และ Private Aggregation ให้ตรวจสอบว่าคุณใช้ Chrome M107 ขึ้นไป เปิดใช้ API ความเป็นส่วนตัวเกี่ยวกับโฆษณาทั้งหมดในส่วน chrome://settings/adPrivacy
นอกจากนี้ คุณยังเปิดใช้พื้นที่เก็บข้อมูลที่ใช้ร่วมกันได้ด้วย--enable-features=PrivacySandboxAdsAPIsOverride,OverridePrivacySandboxSettingsLocalTesting,SharedStorageAPI,FencedFrames แฟล็กในบรรทัดคำสั่ง
ทดลองใช้ตัวอย่างโค้ด
คุณอาจต้องการติดตามจำนวนผู้ใช้ที่ไม่ซ้ำที่เห็นเนื้อหาของคุณในเว็บไซต์ต่างๆ ในตัวอย่างนี้ ระบบจะเข้ารหัสมิติข้อมูลรหัสเนื้อหาลงในคีย์การรวบรวม (ที่เก็บข้อมูล) และใช้จำนวนเป็นค่าที่รวบรวมได้ รายงานสรุปจะมีข้อมูล เช่น "ผู้ใช้ประมาณ 391 คนเห็นเนื้อหาที่มีรหัส 123"
ในตัวอย่างนี้
unique-reach-measurement.jsโหลดโดยใช้เฟรม และมีหน้าที่โหลด Worklet ของพื้นที่เก็บข้อมูลที่แชร์unique-reach-measurement-worklet.jsคือ Worklet ของ Shared Storage ที่ตรวจสอบค่าสถานะใน Shared Storage และส่งรายงานโดยใช้ Private Aggregation API
async function measureUniqueReach() {
// Load the Shared Storage worklet
await window.sharedStorage.worklet.addModule('reach-measurement-worklet.js');
// Run the reach measurement operation
await window.sharedStorage.run('reach-measurement', { data: { contentId: '1234' } });
}
measureUniqueReach();
// Learn more about noise and scaling from the Private Aggregation fundamentals
// documentation on Chrome blog
const SCALE_FACTOR = 65536;
function convertContentIdToBucket(contentId) {
return BigInt(contentId);
}
class ReachMeasurementOperation {
async run(data) {
const { contentId } = data;
// Read from Shared Storage
const key = 'has-reported-content';
const hasReportedContent = (await sharedStorage.get(key)) === 'true';
// Don't report if a report has been sent already
if (hasReportedContent) {
return;
}
// Generate the aggregation key and the aggregatable value
const bucket = convertContentIdToBucket(contentId);
const value = 1 * SCALE_FACTOR;
// Send an aggregatable report using the Private Aggregation API
privateAggregation.contributeToHistogram({ bucket, value });
// Set the report submission status flag
await sharedStorage.set(key, true);
}
}
// Register the operation
register('reach-measurement', ReachMeasurementOperation);
มีส่วนร่วมและแชร์ความคิดเห็น
โปรดทราบว่าข้อเสนอ Shared Storage API อยู่ระหว่างการหารือและการพัฒนาอย่างต่อเนื่อง จึงอาจมีการเปลี่ยนแปลงได้
เราอยากรับฟังความคิดเห็นของคุณเกี่ยวกับ Shared Storage API
- ข้อเสนอ: ดูข้อเสนอแบบละเอียด
- การสนทนา: เข้าร่วมการสนทนาที่ดำเนินอยู่เพื่อถามคำถามและแชร์ข้อมูลเชิงลึก