ユニークリーチの測定

多くのコンテンツ制作者と広告主は、コンテンツを視聴したユニーク ユーザー数を把握したいと考えています。共有ストレージを使用すると、ユーザーが広告、埋め込み動画、パブリケーションを初めて見た日時を記録し、同じユーザーが異なるサイトで重複してカウントされるのを防ぐことができます。その後、Private Aggregation API を使用して、リーチの概要レポートを出力できます。

Shared Storage API は、さまざまなユースケースをサポートする、汎用のクロスサイト ストレージのためのプライバシー サンドボックスの提案です。Private Aggregation API は、共有ストレージで利用できる出力で、クロスサイト データを集計できます。これらの測定を実装する方法について詳しくは、リーチに関するホワイトペーパーをご覧ください。

ユニークリーチ測定を試す

共有ストレージと Private Aggregation によるユニークリーチ測定をテストするには、Chrome M107 以降を使用していることを確認してください。chrome://settings/adPrivacy で、すべての広告プライバシー API を有効にします。

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

コードサンプルを試す

さまざまなサイトにわたってコンテンツを視聴したユニーク ユーザー数を把握したい場合など、この例では、コンテンツ ID ディメンションは集計キー(バケット)にエンコードされ、カウントが集計可能な値として使用されます。概要レポートには、「コンテンツ ID 123 を視聴したユーザーは約 391 人」などの情報が含まれます。

この例では、次のようになります。

  • unique-reach-measurement.js はフレームを使用して読み込まれ、共有ストレージ ワークレットの読み込みを担当します。
  • unique-reach-measurement-worklet.js は、共有ストレージ内のフラグをチェックし、Private Aggregation API を使用してレポートを送信する共有ストレージ ワークレットです。

reach-measurement.js

async function measureUniqueReach() {
  // Load the Shared Storage worklet
  await window.sharedStorage.worklet.addModule('reach-measurement-worklet.js');

  // Run the reach measurement operation
  await window.sharedStorage.run('reach-measurement', { data: { contentId: '1234' } });
}

measureUniqueReach();

reach-measurement-worklet.js

// Learn more about noise and scaling from the Private Aggregation fundamentals
// documentation on Chrome blog
const SCALE_FACTOR = 65536;

function convertContentIdToBucket(contentId) {
  return BigInt(contentId);
}

class ReachMeasurementOperation {
  async run(data) {
    const { contentId } = data;

    // Read from Shared Storage
    const key = 'has-reported-content';
    const hasReportedContent = (await sharedStorage.get(key)) === 'true';

    // Don't report if a report has been sent already
    if (hasReportedContent) {
      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(key, true);
  }
}

// Register the operation
register('reach-measurement', ReachMeasurementOperation);

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.