콘텐츠 제작자는 시청자의 인구통계를 파악하고자 하는 경우가 많습니다. 공유 저장소를 사용하여 퍼스트 파티 사이트와 같이 사용자 인구통계 데이터가 있는 맥락에 사용자 인구통계 데이터를 기록한 다음 집계된 보고서를 사용하여 삽입된 콘텐츠와 같은 다른 사이트의 보고서에 해당 데이터를 포함할 수 있습니다.
Shared Storage API는 다양한 사용 사례를 지원하는 범용 크로스 사이트 스토리지를 위한 개인 정보 보호 샌드박스 제안입니다. Private Aggregation API는 크로스 사이트 데이터를 집계할 수 있는 Shared Storage의 출력입니다.
사용자 인구통계 측정 사용해 보기
공유 저장소 및 비공개 집계로 사용자 인구통계 측정을 실험하려면 Chrome Canary 및 Dev M107 이상을 사용하고 있는지 확인하세요. chrome://settings/adPrivacy
아래의 모든 광고 개인 정보 보호 API를 사용 설정합니다.
명령줄에서 --enable-features=PrivacySandboxAdsAPIsOverride,OverridePrivacySandboxSettingsLocalTesting,SharedStorageAPI,FencedFrames
플래그를 사용하여 공유 저장소를 사용 설정할 수도 있습니다.
코드 샘플로 실험하기
여러 사이트에서 콘텐츠를 본 사용자의 특정 인구통계(예: 연령대 또는 지리적 위치)를 측정할 수 있습니다. 이 예시에서 콘텐츠 ID, 연령대 ID, 지역 ID 측정기준은 집계 키 (버킷)로 인코딩되고 개수는 집계 가능한 값으로 사용됩니다. 생성된 요약 보고서에는 '콘텐츠 ID 123을 본 사용자 중 18~39세의 유럽 사용자가 약 391명입니다'와 같은 정보가 제공됩니다.
이 예에서는 다음과 같이 정의됩니다.
demographic-measurement.js
는 프레임을 사용하여 로드되며 공유 저장소 워크렛을 로드하는 역할을 합니다.demographic-measurement-worklet.js
는 공유 저장소의 인구통계 데이터를 읽고 Private Aggregation 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 just 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');
// Don't 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 using 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); \
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.