「有効フリークエンシー」と呼ばれることもあります。多くの場合、ユーザーが特定のコンテンツを認識または思い出すようになるまでの最小視聴回数が必要です(多くの場合、広告視聴のコンテキストで)。共有ストレージを使用すると、コンテンツを K 回以上表示したユニーク ユーザーのレポートを作成できます。
Shared Storage API は、汎用のクロスサイト ストレージに関するプライバシー サンドボックスの提案であり、多くのユースケースに対応しています。Private Aggregation API は、クロスサイト データを集計できる共有ストレージの出力です。
K+ のフリークエンシー測定を試す
共有ストレージとプライベート アグリゲーションを使用して K+ 頻度の測定を試すには、Chrome M107 以降を使用していることを確認してください。次に、chrome://flags/#privacy-sandbox-ads-apis
でプライバシー サンドボックスの広告 API のテストフラグを有効にします。
コマンドラインで --enable-features=PrivacySandboxAdsAPIsOverride,OverridePrivacySandboxSettingsLocalTesting,SharedStorageAPI,FencedFrames
フラグを使用して共有ストレージを有効にすることもできます。
コードサンプルでテストする
複数のサイトで特定のクライアントに対し、コンテンツを 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 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 をお試しいただき、フィードバックがございましたら、ぜひお寄せください。
- GitHub: 提案を確認し、質問を投稿し、ディスカッションに参加する。
- Shared Storage API に関するお知らせ: メーリング リストに参加したり、過去のお知らせを確認したりできます。
- デベロッパー サポート: プライバシー サンドボックス デベロッパー サポート リポジトリで質問したり、ディスカッションに参加したりできます。