कॉन्टेंट प्रोड्यूसर अक्सर अपने दर्शकों की डेमोग्राफ़िक्स (उम्र, लिंग, आय, शिक्षा वगैरह) को समझना चाहते हैं. शेयर किए गए स्टोरेज का इस्तेमाल करके, उपयोगकर्ता की डेमोग्राफ़िक (उम्र, लिंग, आय, शिक्षा वगैरह) डेटा को उस जगह के हिसाब से रिकॉर्ड किया जा सकता है जहां आपके पास उपलब्ध है. जैसे, आपके पहले पक्ष की साइट. इसके बाद, उस डेटा को अन्य साइटों की रिपोर्ट में शामिल करने के लिए, एग्रीगेट की गई रिपोर्टिंग का इस्तेमाल किया जा सकता है. जैसे, एम्बेड किया गया कॉन्टेंट.
Shared Storage API को निजता के तौर पर इस्तेमाल किया जाता है सामान्य उद्देश्य के लिए सैंडबॉक्स प्रस्ताव, क्रॉस-साइट स्टोरेज, जो कई इस्तेमाल के कुछ उदाहरण हो सकते हैं. निजी एग्रीगेशन एपीआई, शेयर किए गए स्टोरेज में उपलब्ध एक आउटपुट है. इसकी मदद से, क्रॉस-साइट डेटा को इकट्ठा किया जा सकता है.
उपयोगकर्ता के डेमोग्राफ़िक (उम्र, लिंग, आय, शिक्षा वगैरह) मेज़रमेंट को आज़माएं
शेयर किए गए स्टोरेज और प्राइवेट एग्रीगेशन की मदद से, उपयोगकर्ता के डेमोग्राफ़िक (उम्र, लिंग, आय, शिक्षा वगैरह) मेज़रमेंट के साथ एक्सपेरिमेंट करने के लिए, पुष्टि करें कि Chrome कैनरी और Dev M107 या इसके बाद के वर्शन का इस्तेमाल किया जा रहा है. chrome://settings/adPrivacy
में शामिल, विज्ञापन देखने वाले की निजता बनाए रखने से जुड़े सभी एपीआई चालू करें.
कमांड लाइन में मौजूद --enable-features=PrivacySandboxAdsAPIsOverride,OverridePrivacySandboxSettingsLocalTesting,SharedStorageAPI,FencedFrames
फ़्लैग के साथ, शेयर किए गए स्टोरेज की सुविधा भी चालू की जा सकती है.
कोड सैंपल के साथ प्रयोग करें
शायद आप उन उपयोगकर्ताओं की कुछ जनसांख्यिकी (उम्र, लिंग, आय, शिक्षा वगैरह) का आकलन करना चाहें जिन्होंने अलग-अलग साइटों पर आपका कॉन्टेंट देखा है, जैसे कि उम्र सीमा या भौगोलिक जगह. इस उदाहरण में, Content ID, उम्र समूह आईडी, और भूगोल आईडी के डाइमेंशन को एग्रीगेशन कुंजी (बकेट) में एन्कोड किया गया है. साथ ही, इस संख्या का इस्तेमाल, एग्रीगेशन की जा सकने वाली वैल्यू के तौर पर किया गया है. जनरेट की गई खास जानकारी वाली रिपोर्ट में कुछ जानकारी दी जाएगी. जैसे, "Content ID 123 देखने वाले करीब 391 उपयोगकर्ता, 18 से 39 साल के बीच के हैं और यूरोप के हैं."
इस उदाहरण में:
demographic-measurement.js
को एक फ़्रेम से लोड किया जाता है. इसकी ज़िम्मेदारी, शेयर किए गए स्टोरेज के वर्कलेट को भी लोड करनी होती है.demographic-measurement-worklet.js
, शेयर किया गया स्टोरेज वर्कलेट है, जो शेयर किए गए स्टोरेज में मौजूद डेमोग्राफ़िक्स (उम्र, लिंग, आय, शिक्षा वगैरह) के डेटा को पढ़ता है और Private एग्रीगेशन API के ज़रिए रिपोर्ट भेजता है.
(यह रिपोर्ट, मेज़रमेंट किए जाने से पहले, कुछ समय के लिए काम करती है. इससे डेमोग्राफ़िक डेटा को Shared Storage में सेट किया जाता है)
function getDemogrationsData() {
// Collect age group and continent data
return {
ageGroup,
continent
}
}
async function storeDemographics() {
const { ageGroup, continent } = getDemographicsData();
await window.sharedStorage.set('age-group', ageGroup);
await window.sharedStorage.set('continent', continent);
}
storeDemographics();
async function measureDemographics() {
// Load the Shared Storage worklet
await window.sharedStorage.worklet.addModule('demographics-measurement-worklet.js');
// Run the demographics measurement operation
await window.sharedStorage.run('demographics-measurement', { data: { contentId: '123' } });
}
measureDemographics();
demographic-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 ad campaign
* ID itself. For more complex bucket key construction, see other use cases in
* this demo.
*/
const AGGREGATION_KEY_MAP = {
ageGroupId: {
'18-39': '1',
'40-64': '2',
'65+': '3',
},
continentId: {
africa: '1',
antarctica: '2',
asia: '3',
australia: '4',
europe: '5',
'north-america': '6',
'south-america': '7',
},
};
/**
* The aggregation key will be in the format of:
* contentId | ageGroupId | continentId
*
* For example, a user from Australia between the age of 40-64, who has
* seen the Content ID 321 will be represented by the key:
* 321 | 2 | 4 or 32124
*/
function generateAggregationKey(contentId, ageGroup, continent) {
const ageGroupId = AGGREGATION_KEY_MAP.ageGroupId[ageGroup];
const continentId = AGGREGATION_KEY_MAP.continentId[continent];
const aggregationKey = BigInt(`${contentId}${ageGroupId}${continentId}`);
return aggregationKey;
}
class DemographicsMeasurementOperation {
async run(data) {
const { contentId } = data;
// Read from Shared Storage
const key = 'has-reported-content';
const hasReportedContent = (await sharedStorage.get(key)) === 'true';
const ageGroup = await sharedStorage.get('age-group');
const continent = await sharedStorage.get('continent');
// Do not report if a report has been sent already
if (hasReportedContent) {
return;
}
// Generate the aggregation key and the aggregatable value
const bucket = generateAggregationKey(contentId, ageGroup, continent);
const value = 1 * SCALE_FACTOR;
// Send an aggregatable report via the Private Aggregation API
privateAggregation.contributeToHistogram({ bucket, value });
// Set the report submission status flag
await sharedStorage.set(key, true);
}
}
// Register the operation
register('demographics-measurement', DemographicsMeasurementOperation); \
互动和分享反馈
共享存储空间提案正在积极讨论,可能会发生变化 。如果您试用此 API 并有反馈意见,我们非常期待收到您的反馈意见。
- GitHub:阅读 提案、覆盖面白皮书、提出问题并参与讨论。
- Shared Storage API 通告:加入我们的邮寄名单,或查看以往的通告
- 开发者支持:提出问题并加入 Privacy Sandbox 开发者支持代码库。