บางครั้งเรียกว่า "ความถี่ที่มีประสิทธิภาพ" ซึ่งมักจะมีจำนวนการดูขั้นต่ำก่อนที่ผู้ใช้จะจดจำหรือจำเนื้อหาบางอย่างได้ (มักอยู่ในบริบทของการดูโฆษณา) คุณสามารถใช้พื้นที่เก็บข้อมูลที่ใช้ร่วมกันเพื่อสร้างรายงานผู้ใช้ที่ไม่ซ้ำที่เห็นเนื้อหาอย่างน้อย K ครั้ง
Shared Storage API เป็นข้อเสนอ Privacy Sandbox สำหรับพื้นที่เก็บข้อมูลข้ามเว็บไซต์สำหรับวัตถุประสงค์ทั่วไป ซึ่งรองรับ Use Case ที่เป็นไปได้หลายกรณี Private Aggregation API เป็นเอาต์พุตที่พร้อมใช้งานในพื้นที่เก็บข้อมูลที่ใช้ร่วมกันซึ่งช่วยให้คุณรวบรวมข้อมูลข้ามเว็บไซต์ได้
ลองวัดความถี่ K+
หากต้องการทดสอบการวัดความถี่ K+ กับพื้นที่เก็บข้อมูลที่ใช้ร่วมกันและการรวมส่วนตัว ให้ตรวจสอบว่าคุณใช้ Chrome M107 ขึ้นไป จากนั้นเปิดใช้แฟล็กการทดสอบ Privacy Sandbox API ที่ chrome://flags/#privacy-sandbox-ads-apis
คุณยังเปิดใช้พื้นที่เก็บข้อมูลที่ใช้ร่วมกันด้วยแฟล็ก --enable-features=PrivacySandboxAdsAPIsOverride,OverridePrivacySandboxSettingsLocalTesting,SharedStorageAPI,FencedFrames
ในบรรทัดคำสั่งได้ด้วย
การทดสอบกับตัวอย่างโค้ด
คุณอาจต้องการวัดจำนวนผู้ใช้ที่ดูเนื้อหาของคุณ K หรือมากกว่าสำหรับลูกค้าที่ระบุในเว็บไซต์ต่างๆ ในตัวอย่างนี้ จำนวนการแสดงผลจะเพิ่มไปยังพื้นที่เก็บข้อมูลที่ใช้ร่วมกัน โดยจะเพิ่มขึ้น 1 เมื่อมีการโหลดเนื้อหา เมื่อมีจำนวนการแสดงผลถึง 3 ระบบจะเรียกใช้ Private Aggregation API มิติข้อมูล Content ID จะเข้ารหัสเป็นคีย์การรวม และใช้จำนวนเป็นค่าแบบรวมได้ รายงานสรุปจะให้ข้อมูล เช่น "ผู้ใช้ประมาณ 391 คนเห็นรหัสแคมเปญโฆษณา 123 อย่างน้อย 3 ครั้ง"
ในตัวอย่างนี้
k-frequency-measurement.js
จะโหลดผ่านเฟรม และมีหน้าที่โหลดเวิร์กเล็ตของพื้นที่เก็บข้อมูลที่ใช้ร่วมกันk-frequency-measurement-worklet.js
เป็น Worklet พื้นที่เก็บข้อมูลที่ใช้ร่วมกัน ซึ่งจะอ่านจำนวนการแสดงผลในพื้นที่เก็บข้อมูลที่ใช้ร่วมกันและส่งรายงานผ่าน Private Aggregation API
k-frequency-measurement.js
async function injectContent() {
// Load the Shared Storage worklet
await window.sharedStorage.worklet.addModule('k-freq-measurement-worklet.js');
// Run the K-frequency measurement operation
await window.sharedStorage.run('k-freq-measurement', { data: { kFreq: 3, contentId: 123 });
}
injectContent();
k-frequency-measurement-worklet.js
// Learn more about noise and scaling from the Private Aggregation fundamentals
// documentation on Chrome blog
const SCALE_FACTOR = 65536;
/**
* The bucket key must be a number, and in this case, it is simply the content
* ID itself. For more complex bucket key construction, see other use cases in
* this demo.
*/
function convertContentIdToBucket(contentId) {
return BigInt(contentId);
}
class KFreqMeasurementOperation {
async run(data) {
const { kFreq, contentId } = data;
// Read from Shared Storage
const hasReportedContentKey = 'has-reported-content';
const impressionCountKey = 'impression-count';
const hasReportedContent = (await this.sharedStorage.get(hasReportedContentKey)) === 'true';
const impressionCount = parseInt((await this.sharedStorage.get(impressionCountKey)) || 0);
// Do not report if a report has been sent already
if (hasReportedContent) {
return;
}
// Check impression count against frequency limit
if (impressionCount < kFreq) {
await this.sharedStorage.set(impressionCountKey, impressionCount + 1);
return;
}
// Generate the aggregation key and the aggregatable value
const bucket = convertContentIdToBucket(contentId);
const value = 1 * SCALE_FACTOR;
// Send an aggregatable report via the Private Aggregation API
privateAggregation.sendHistogramReport({ bucket, value });
// Set the report submission status flag
await this.sharedStorage.set(hasReportedContentKey, 'true');
}
}
// Register the operation
register('k-freq-measurement', KFreqMeasurementOperation); \
มีส่วนร่วมและแชร์ความคิดเห็น
ข้อเสนอพื้นที่เก็บข้อมูลที่ใช้ร่วมกันอยู่ระหว่างการหารือและอาจมีการเปลี่ยนแปลงในอนาคต หากคุณลองใช้ API นี้แล้วมีความคิดเห็น เรายินดีรับฟัง
- GitHub: อ่านข้อเสนอ ตั้งคำถามและร่วมอภิปราย
- ประกาศเกี่ยวกับพื้นที่เก็บข้อมูลที่ใช้ร่วมกันของ API: เข้าร่วมหรือดูประกาศที่ผ่านมาในรายชื่ออีเมล
- การสนับสนุนนักพัฒนาแอป: ถามคำถามและเข้าร่วมการสนทนาในที่เก็บการสนับสนุนนักพัฒนาแอป Privacy Sandbox