מדידת היקף החשיפה של תדירות K+

לעיתים קרובות, המתוארת כ "תדירות אפקטיבית", יש מספר מינימלי של צפיות לפני שמשתמש יזהה או יזכור תוכן מסוים (לרוב בהקשר של צפיות בפרסומת). אתם יכולים להשתמש בנפח אחסון משותף כדי ליצור דוחות על משתמשים ייחודיים שראו קטע תוכן לפחות K פעמים.

Shared Storage API הוא הצעה של ארגז חול לפרטיות לשימוש כללי, אחסון באתרים שונים, שתומך בהרבה תרחישים אפשריים של שימוש. Private Aggregation API הוא פלט שזמין באחסון משותף שמאפשר לכם לצבור נתונים מאתרים שונים.

כדאי לנסות את מדידת התדירות של K+

כדי להתנסות במדידת תדירות של K+ עם 'אחסון משותף' ו'צבירה פרטית', צריך לוודא שאתם משתמשים ב-Chrome מגרסה M107 ואילך. לאחר מכן מפעילים את הסימון של ניסוי בממשקי ה-API של ארגז החול לפרטיות בכתובת chrome://flags/#privacy-sandbox-ads-apis.

הפעלת הניסוי של ממשקי ה-API של מודעות ארגז החול לפרטיות כך שאפשר יהיה להשתמש בהם

ניתן להפעיל אחסון משותף גם באמצעות הדגל --enable-features=PrivacySandboxAdsAPIsOverride,OverridePrivacySandboxSettingsLocalTesting,SharedStorageAPI,FencedFrames בשורת הפקודה.

ניסוי עם דוגמאות קוד

אתם יכולים למדוד את מספר המשתמשים שראו את התוכן שלכם K או יותר פעמים באתר של לקוח נתון, באתרים שונים. בדוגמה הזו, ספירת החשיפות מתווספת לנפח האחסון המשותף, שבה היא נספרת ב-1 בכל פעם שהתוכן נטען. כשמספר החשיפות מגיע ל-3, מתבצעת קריאה ל-Private Aggregation API. המאפיין Content ID מקודד כמפתח צבירה, והספירה משמשת כערך המצטבר. דוח הסיכום יספק מידע כמו "בערך 391 משתמשים ראו את מזהה הקמפיין 123 לפחות 3 פעמים".

בדוגמה הזו:

  • k-frequency-measurement.js נטען דרך מסגרת, והוא אחראי לטעינת ה-worklet של האחסון המשותף.
  • 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 הזה ויש לך משוב, נשמח לשמוע אותו.