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

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

ה-Shared Storage API הוא הצעה לארגז החול לפרטיות שמיועד לשימוש כללי לאחסון באתרים שונים, והוא תומך בתרחישים שונים לדוגמה של שימוש במגוון אתרים. 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 נטען באמצעות מסגרת, והוא אחראי לטעון את 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.contributeToHistogram({ bucket, value });

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

// Register the operation

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

מעורבות ושיתוף משוב

ההצעה לנפח אחסון משותף נמצאת בדיון פעיל וכפופה לשינויים הוא בעתיד. אם ניסיתם את ה-API הזה ויש לכם משוב, נשמח לשמוע אותו.