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

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

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

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

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

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

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

คุณอาจต้องวัดจํานวนผู้ใช้ที่เห็นเนื้อหาของคุณอย่างน้อย K ครั้งในเว็บไซต์ต่างๆ ของลูกค้ารายหนึ่ง ในตัวอย่างนี้ ระบบจะเพิ่มจํานวนการแสดงผลลงในพื้นที่เก็บข้อมูลที่ใช้ร่วมกัน ซึ่งจะเพิ่มขึ้น 1 ครั้งทุกครั้งที่โหลดเนื้อหา เมื่อจำนวนการแสดงผลถึง 3 ระบบจะเรียกใช้ Private Aggregation API ระบบจะเข้ารหัสมิติข้อมูลรหัสเนื้อหาเป็นคีย์การรวม และจะใช้จํานวนเป็นค่าที่รวมได้ รายงานสรุปจะแสดงข้อมูล เช่น "ผู้ใช้ประมาณ 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();

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); \

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

โปรดทราบว่าข้อเสนอ Shared Storage API อยู่ระหว่างการพูดคุยและการพัฒนาอย่างต่อเนื่อง จึงอาจมีการเปลี่ยนแปลง

เรายินดีรับฟังความคิดเห็นของคุณเกี่ยวกับ Shared Storage API

ติดตามข้อมูลอยู่เสมอ

  • รายชื่ออีเมล: สมัครรับอีเมลจากรายชื่ออีเมลของเราเพื่อรับข้อมูลอัปเดตและประกาศล่าสุดเกี่ยวกับ Shared Storage API

หากต้องการความช่วยเหลือ