多くのコンテンツ作成者や広告主は、コンテンツを視聴したユニーク ユーザーの数を把握したいと考えています。共有ストレージを使用して、ユーザーが広告、埋め込み動画、パブリケーションを初めて見た日時を記録し、異なるサイトで同じユーザーが重複してカウントされるのを防ぎます。次に、Private Aggregation API を使用して、リーチの概要レポートを出力できます。
Shared Storage API は、汎用のクロスサイト ストレージに関するプライバシー サンドボックスの提案で、多くのユースケースに対応できます。Private Aggregation API は、クロスサイト データを集計できる Shared Storage で利用可能な出力です。これらの測定を実装する方法について詳しくは、リーチに関するホワイトペーパーをご覧ください。
ユニークリーチ測定を試す
共有ストレージと Private Aggregation を使用してユニーク リーチの測定を試すには、Chrome M107 以降を使用していることを確認してください。chrome://settings/adPrivacy で広告プライバシー API をすべて有効にします。
コマンドラインで --enable-features=PrivacySandboxAdsAPIsOverride,OverridePrivacySandboxSettingsLocalTesting,SharedStorageAPI,FencedFrames フラグを使用して共有ストレージを有効にすることもできます。
コードサンプルを試す
さまざまなサイトでコンテンツを閲覧したユニーク ユーザーの数を把握したい場合があります。この例では、コンテンツ ID ディメンションが集計キー(バケット)にエンコードされ、カウントが集計可能な値として使用されます。概要レポートには、「約 391 人のユーザーがコンテンツ ID 123 を視聴しました」などの情報が表示されます。
この例では、次のようになります。
unique-reach-measurement.jsはフレームを使用して読み込まれ、共有ストレージ ワークレットの読み込みを担当します。unique-reach-measurement-worklet.jsは、共有ストレージ内のフラグをチェックし、Private Aggregation API を使用してレポートを送信する共有ストレージ ワークレットです。
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();
// 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);
意見交換とフィードバックの提供
Shared Storage API の提案は現在、活発な議論と開発の途上にあるため、変更される可能性があります。
Shared Storage API についてのご意見をお待ちしております。
- 提案: 詳細な提案を確認します。
- ディスカッション: 進行中のディスカッションに参加して、質問したり、分析情報を共有したりできます。