कॉन्टेंट बनाने वाले कई लोगों और विज्ञापन देने वाले लोगों या कंपनियों को यह जानना होता है कि उनके कॉन्टेंट को कितने यूनीक लोगों ने देखा. Shared Storage का इस्तेमाल करके, यह रिकॉर्ड करें कि किसी उपयोगकर्ता ने पहली बार आपका विज्ञापन, एम्बेड किया गया वीडियो या पब्लिकेशन कब देखा. साथ ही, अलग-अलग साइटों पर एक ही उपयोगकर्ता को कई बार गिने जाने से रोकें. इसके बाद, Private Aggregation API का इस्तेमाल करके, पहुंच की खास जानकारी वाली रिपोर्ट जनरेट की जा सकती है.
Shared Storage API, Privacy Sandbox का एक प्रस्ताव है. इसका इस्तेमाल, अलग-अलग कामों के लिए और एक से ज़्यादा साइटों पर डेटा सेव करने के लिए किया जाता है. यह कई तरह के इस्तेमाल के उदाहरणों के साथ काम करता है. Private Aggregation API, Shared Storage में उपलब्ध एक आउटपुट है. इसकी मदद से, अलग-अलग साइटों से मिले डेटा को एग्रीगेट किया जा सकता है. इस डेटा को लागू करने के तरीकों के बारे में ज़्यादा जानने के लिए, पहुंच से जुड़ा व्हाइट पेपर देखें.
यूनीक रीच मेज़रमेंट की सुविधा आज़माना
Shared Storage और Private Aggregation की मदद से यूनीक रीच मेज़रमेंट को आज़माने के लिए, पक्का करें कि Chrome M107 या उसके बाद के वर्शन का इस्तेमाल किया जा रहा हो. chrome://settings/adPrivacy में जाकर, विज्ञापन देखने वाले की निजता बनाए रखने से जुड़े सभी एपीआई चालू करें.
कमांड लाइन में --enable-features=PrivacySandboxAdsAPIsOverride,OverridePrivacySandboxSettingsLocalTesting,SharedStorageAPI,FencedFrames फ़्लैग का इस्तेमाल करके भी, शेयर किए गए स्टोरेज की सुविधा चालू की जा सकती है.
कोड सैंपल आज़माएँ
ऐसा हो सकता है कि आपको यह ट्रैक करना हो कि अलग-अलग साइटों पर, कितने यूनीक उपयोगकर्ताओं ने आपका कॉन्टेंट देखा है. इस उदाहरण में, कॉन्टेंट आईडी डाइमेंशन को एग्रीगेशन की (बकेट) में कोड किया गया है. साथ ही, गिनती का इस्तेमाल एग्रीगेट की जा सकने वाली वैल्यू के तौर पर किया गया है. खास जानकारी वाली रिपोर्ट में, इस तरह की जानकारी शामिल होगी: "लगभग 391 उपयोगकर्ताओं ने कॉन्टेंट आईडी 123 देखा है."
इस उदाहरण में:
unique-reach-measurement.jsको फ़्रेम का इस्तेमाल करके लोड किया जाता है. साथ ही, यह शेयर किए गए स्टोरेज वर्कलेट को लोड करने के लिए ज़िम्मेदार होता है.unique-reach-measurement-worklet.js, Shared Storage के लिए वर्कलेट है. यह Shared Storage में फ़्लैग की जांच करता है और 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);
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.