วัดการเข้าถึงความถี่ K+

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

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

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

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

นอกจากนี้คุณยังเปิดใช้พื้นที่เก็บข้อมูลที่ใช้ร่วมกันได้ด้วยแฟล็ก --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 เป็นเวิร์กเล็ตพื้นที่เก็บข้อมูลที่ใช้ร่วมกันซึ่งจะอ่านจำนวนการแสดงผลในพื้นที่เก็บข้อมูลที่ใช้ร่วมกันและส่งรายงานผ่าน 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.contributeToHistogram({ bucket, value });

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

// Register the operation

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

มีส่วนร่วมและแชร์ความคิดเห็น

ข้อเสนอพื้นที่เก็บข้อมูลที่ใช้ร่วมกันอยู่ระหว่างการหารือและอาจมีการเปลี่ยนแปลงในอนาคต หากคุณลองใช้ API นี้แล้วมีความคิดเห็น เรายินดีรับฟัง