콘텐츠 제작자는 시청자의 인구통계를 파악하고 싶어하는 경우가 많습니다. 공유 스토리지를 사용하면 퍼스트 파티 사이트와 같이 사용자 인구통계 데이터가 있는 컨텍스트에서 해당 데이터를 기록한 다음 집계 보고를 사용하여 삽입된 콘텐츠와 같은 다른 사이트의 보고서에 해당 데이터를 포함할 수 있습니다.
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을 본 사용자 중 약 391명이 18~39세이며 유럽에 거주합니다.'와 같은 정보가 제공됩니다.
예를 들면 다음과 같습니다.
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); \
참여 및 의견 공유
Shared Storage API 제안은 현재 활발히 논의되고 개발 중이며 변경될 가능성이 있습니다.
Shared Storage API에 관한 의견을 기다리고 있습니다.