วัดการเข้าถึงความถี่ตั้งแต่ K ขึ้นไป

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

Shared Storage API เป็นข้อเสนอของ Privacy Sandbox สำหรับพื้นที่เก็บข้อมูลแบบข้ามเว็บไซต์อเนกประสงค์ ซึ่งรองรับ Use Case ที่เป็นไปได้มากมาย Private Aggregation API คือเอาต์พุตที่มีอยู่ใน Shared Storage ซึ่งช่วยให้คุณรวมข้อมูลข้ามเว็บไซต์ได้

ลองใช้การวัดความถี่ K+

หากต้องการทดสอบการวัดความถี่ K+ ด้วยพื้นที่เก็บข้อมูลที่ใช้ร่วมกันและการรวบรวมข้อมูลแบบส่วนตัว โปรดตรวจสอบว่าคุณใช้ Chrome M107 ขึ้นไป เปิดใช้ API ความเป็นส่วนตัวเกี่ยวกับโฆษณาทั้งหมดในส่วน chrome://settings/adPrivacy

นอกจากนี้ คุณยังเปิดใช้พื้นที่เก็บข้อมูลที่ใช้ร่วมกันได้ด้วย--enable-features=PrivacySandboxAdsAPIsOverride,OverridePrivacySandboxSettingsLocalTesting,SharedStorageAPI,FencedFrames แฟล็กในบรรทัดคำสั่ง

ทดลองใช้ตัวอย่างโค้ด

คุณอาจต้องการวัดจำนวนผู้ใช้ที่เห็นเนื้อหาของคุณอย่างน้อย K ครั้งในไคลเอ็นต์ที่กำหนดในเว็บไซต์ต่างๆ ในตัวอย่างนี้ ระบบจะเพิ่มจำนวนการแสดงผลลงในพื้นที่เก็บข้อมูลที่ใช้ร่วมกัน โดยจะเพิ่มขึ้น 1 ทุกครั้งที่โหลดเนื้อหา เมื่อจำนวนการแสดงผลถึง 3 ระบบจะเรียกใช้ Private Aggregation API ระบบจะเข้ารหัสมิติข้อมูลรหัสเนื้อหาเป็นคีย์การรวบรวม และใช้จำนวนเป็นค่าที่รวบรวมได้ รายงานสรุปจะให้ข้อมูล เช่น "ผู้ใช้ประมาณ 391 รายเห็นรหัสแคมเปญโฆษณา 123 อย่างน้อย 3 ครั้ง"

ในตัวอย่างนี้

  • k-frequency-measurement.js จะโหลดโดยใช้เฟรม และมีหน้าที่โหลด Worklet ของพื้นที่เก็บข้อมูลที่ใช้ร่วมกัน
  • k-frequency-measurement-worklet.js คือ Worklet ของ Shared Storage ที่อ่านจํานวนการแสดงผลใน Shared Storage และส่งรายงานโดยใช้ 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();

kuency-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 just 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 sharedStorage.get(hasReportedContentKey)) === 'true';
    const impressionCount = parseInt((await sharedStorage.get(impressionCountKey)) || 0);

    // Don't report if a report has been sent already
    if (hasReportedContent) {
      return;
    }

    // Check impression count against frequency limit
    if (impressionCount < kFreq) {
      await 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 using the Private Aggregation API
    privateAggregation.contributeToHistogram({ bucket, value });

    // Set the report submission status flag
    await sharedStorage.set(hasReportedContentKey, 'true');
  }
}

// Register the operation

register('k-freq-measurement', KFreqMeasurementOperation); \

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.