K+ フリークエンシー リーチを測定する

「有効フリークエンシー」とも呼ばれる一定の回数以上視聴しないと、ユーザーが特定のコンテンツを認識または想起できないことがよくあります(多くの場合、広告視聴の場合)。共有ストレージを使用して、コンテンツを K 回以上見たユニーク ユーザーのレポートを作成できます。

Shared Storage API はプライバシー さまざまな用途をサポートする汎用のクロスサイト ストレージ向けのサンドボックス案 見ていきましょう。Private Aggregation API は、共有ストレージで使用できる出力で、クロスサイト データを集約できます。

K+ 頻度測定を試す

共有ストレージとプライベート アグリゲーションで K+ の周波数測定をテストするには、Chrome M107 以降を使用していることを確認してください。chrome://settings/adPrivacy で、すべての広告プライバシー API を有効にします。

コマンドラインで --enable-features=PrivacySandboxAdsAPIsOverride,OverridePrivacySandboxSettingsLocalTesting,SharedStorageAPI,FencedFrames フラグを使用して共有ストレージを有効にすることもできます。

コードサンプルでテストする

複数のサイトにわたって 1 人のクライアントで K 回以上お客様のコンテンツを見たユーザーの数を測定したい場合もあるでしょう。この例では、インプレッション数は共有ストレージに追加され、コンテンツが読み込まれるたびに 1 ずつ増えます。インプレッション数が 3 に達すると、Private Aggregation API が呼び出されます。Content ID ディメンションが集計キーとしてエンコードされ、そのカウントが集計可能な値として使用されます。概要レポートには、「約 391 人のユーザーが広告キャンペーン ID 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 sharedStorage.get(hasReportedContentKey)) === 'true';
    const impressionCount = parseInt((await 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 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 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.

Stay Informed

  • Mailing List: Subscribe to our mailing list for the latest updates and announcements related to the Shared Storage API.

Need Help?