ผู้ผลิตเนื้อหาและผู้ลงโฆษณาจํานวนมากต้องการทราบว่ามีคนที่ไม่ซ้ำกันกี่คนที่เห็นเนื้อหาของตน ใช้พื้นที่เก็บข้อมูลส่วนกลางเพื่อบันทึกครั้งแรกที่ผู้ใช้เห็นโฆษณา วิดีโอที่ฝัง หรือสิ่งพิมพ์ของคุณ และป้องกันการนับผู้ใช้รายเดียวกันซ้ำในเว็บไซต์ต่างๆ จากนั้นคุณก็ใช้ Private Aggregation API เพื่อแสดงผลรายงานสรุปสําหรับการเข้าถึงได้
Shared Storage API เป็นข้อเสนอ Privacy Sandbox สำหรับพื้นที่เก็บข้อมูลข้ามเว็บไซต์อเนกประสงค์ที่รองรับ Use Case หลายรายการ Private Aggregation API เป็นเอาต์พุตที่มีอยู่ใน Shared Storage ซึ่งช่วยให้คุณรวบรวมข้อมูลจากหลายเว็บไซต์ได้ ดูข้อมูลเพิ่มเติมเกี่ยวกับวิธีใช้การวัดเหล่านี้ได้ในสมุดปกขาวเกี่ยวกับการเข้าถึง
ลองใช้การวัด Unique Reach
หากต้องการทดสอบการวัดการเข้าถึงที่ไม่ซ้ำกันด้วยพื้นที่เก็บข้อมูลที่ใช้ร่วมกันและการรวมข้อมูลส่วนตัว โปรดตรวจสอบว่าคุณใช้ Chrome M107 ขึ้นไป เปิดใช้ Ad Privacy API ทั้งหมดในส่วน chrome://settings/adPrivacy
นอกจากนี้ คุณยังเปิดใช้พื้นที่เก็บข้อมูลที่ใช้ร่วมกันได้ด้วย Flag --enable-features=PrivacySandboxAdsAPIsOverride,OverridePrivacySandboxSettingsLocalTesting,SharedStorageAPI,FencedFrames
ในบรรทัดคำสั่ง
ทดลองใช้ตัวอย่างโค้ด
คุณอาจต้องติดตามจํานวนผู้ใช้ที่ไม่ซ้ำกันที่ดูเนื้อหาของคุณในเว็บไซต์ต่างๆ ในตัวอย่างนี้ มิติข้อมูลรหัสเนื้อหาได้รับการเข้ารหัสเป็นคีย์การรวม (ที่เก็บข้อมูล) และระบบจะใช้จํานวนเป็นค่าที่รวบรวมได้ รายงานสรุปจะมีข้อมูล เช่น "ผู้ใช้ประมาณ 391 คนดูรหัสเนื้อหา 123"
ในตัวอย่างนี้
unique-reach-measurement.js
จะโหลดโดยใช้เฟรมและมีหน้าที่รับผิดชอบในการโหลดชิ้นงานพื้นที่เก็บข้อมูลที่ใช้ร่วมกันunique-reach-measurement-worklet.js
คือเวิร์กเลตพื้นที่เก็บข้อมูลที่ใช้ร่วมกันซึ่งจะตรวจสอบการตั้งค่าสถานะในพื้นที่เก็บข้อมูลที่ใช้ร่วมกันและส่งรายงานโดยใช้ 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);
Engage and share feedback
Note that the Shared Storage API proposal is under active discussion and development and therefore subject to change.
We're eager to hear your thoughts on the Shared Storage API.
- Proposal: Review the detailed proposal.
- Discussion: Join the ongoing discussion to ask questions and share your insights.
Stay Informed
- Mailing List: Subscribe to our mailing list for the latest updates and announcements related to the Shared Storage API.
Need Help?
- Developer Support: Connect with other developers and get answers to your questions in the Privacy Sandbox Developer Support repository.