Birçok içerik üretici ve reklamveren, içeriklerini kaç benzersiz kullanıcının gördüğünü bilmek ister. Bir kullanıcının reklamınızı, yerleştirilmiş videonuzu veya yayınınızı ilk kez gördüğünü kaydetmek ve aynı kullanıcının farklı sitelerde tekrar sayılmasını önlemek için Shared Storage'ı kullanın. Ardından, erişiminiz için özet rapor oluşturmak üzere Private Aggregation API'yi kullanabilirsiniz.
Shared Storage API, genel amaçlı, siteler arası depolama için bir Privacy Sandbox teklifidir ve birçok olası kullanım alanını destekler. Private Aggregation API, Ortak Depolama'da bulunan ve siteler arası verileri toplamanıza olanak tanıyan bir çıkıştır. Bu ölçümleri uygulama yöntemleri hakkında daha fazla bilgi edinmek için erişim teknik belgemizi inceleyin.
Tekil erişim ölçümünü deneyin
Shared Storage ve Private Aggregation ile benzersiz erişim ölçümünü denemek için Chrome M107 veya sonraki bir sürümü kullandığınızı onaylayın. chrome://settings/adPrivacy
altındaki tüm reklam gizliliği API'lerini etkinleştirin.
Paylaşılan depolama alanını, komut satırında --enable-features=PrivacySandboxAdsAPIsOverride,OverridePrivacySandboxSettingsLocalTesting,SharedStorageAPI,FencedFrames
işaretini kullanarak da etkinleştirebilirsiniz.
Kod örneklerini deneme
İçeriğinizi farklı sitelerde kaç benzersiz kullanıcının gördüğünü takip etmek isteyebilirsiniz. Bu örnekte, içerik kimliği boyutu toplama anahtarına (bucket) kodlanır ve toplama değeri olarak sayı kullanılır. Özet raporda "123 içerik kimlikli içeriği yaklaşık 391 kullanıcı gördü" gibi bilgiler yer alır.
Bu örnekte:
unique-reach-measurement.js
, bir çerçeve kullanılarak yüklenir ve paylaşılan depolama alanı iş parçacığının yüklenmesinden sorumludur.unique-reach-measurement-worklet.js
, ortak depolama alanındaki işareti kontrol eden ve Private Aggregation API'yi kullanarak rapor gönderen ortak depolama alanı işleyicisidir.
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);
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.
- Proposal: Review the detailed proposal.
- Discussion: Join the ongoing discussion to ask questions and share your insights.
Stay Informed
- Mailing List: Subscribe to our mailing list for the latest updates and announcements related to the Shared Storage API.
Need Help?
- Developer Support: Connect with other developers and get answers to your questions in the Privacy Sandbox Developer Support repository.