공유 저장소 워크렛을 실행하여 URL을 선택하고 분리 프레임에 렌더링합니다.
Shared Storage API는 개인 정보 보호 다양한 용도를 지원하는 크로스 사이트 스토리지를 위한 범용 샌드박스 제안 사용 사례일 수 있습니다. 한 가지 예로 게재빈도 제어가 있는데, 이는 테스트할 수 있습니다.
Worklet 스크립트를 실행하여 저장된 구분한 다음 해당 URL을 분리 프레임에 렌더링해야 합니다. 이를 사용하여 새 광고나 다른 콘텐츠를 게재할 수 없습니다.
실행 빈도에 따른 광고 소재 선택 테스트
공유 저장소 및 분리 프레임으로 빈도별 광고 소재 선택을 테스트하려면
Chrome 104.0.5086.0 이상 사용 chrome://settings/adPrivacy
에서 모든 광고 개인 정보 보호 API를 사용 설정합니다.
명령줄에서 --enable-features=PrivacySandboxAdsAPIsOverride,OverridePrivacySandboxSettingsLocalTesting,SharedStorageAPI,FencedFrames
플래그를 사용하여 공유 저장소를 사용 설정할 수도 있습니다.
코드 샘플 실험
불투명 URL을 선택하고 만들려면 공유 항목을 읽을 워크렛 모듈을 등록하세요. 사용할 수 있습니다 worklet 클래스는 최대 8개의 URL 목록을 받은 다음 는 선택한 URL의 색인을 반환합니다.
클라이언트가 sharedStorage.selectURL()
를 호출할 때 Worklet은
를 실행하고 분리 프레임으로 렌더링할 불투명 URL을 반환합니다.
사용자가 이전에 광고를 본 횟수의 빈도에 따라 렌더링할 다른 광고나 콘텐츠를 선택한다고 가정해 보겠습니다. 사용자가 콘텐츠를 본 횟수를 계산하고 그 가치를 공유 저장공간에 저장할 수 있습니다. 공유 스토리지의 값을 저장하면 여러 출처에서 사용할 수 있습니다.
그런 다음, 공유 저장소 Worklet은 공유 저장소의 값을 읽고 추가 뷰가 있을 때마다 카운터를 증가시킵니다. 개수가 사전 정의된 한도에 도달하지 않은 경우 렌더링할 콘텐츠 (색인 1
)가 반환됩니다. 그렇지 않은 경우 기본 URL (색인 0
)이 반환됩니다.
이 예에서는 다음과 같이 정의됩니다.
creative-selection-by-frequencyjs
는 콘텐츠 제작자 또는 광고주의 iframe을 통해 로드되며 는 공유 저장소 Worklet을 로드하고 반환된 불투명한 분리 프레임으로 전송합니다.creative-selection-by-frequency-worklet.js
는 게재빈도를 사용하여 콘텐츠 또는 광고 소재에 대해 반환되는 URL을 결정합니다.
creative-selection-by-frequency.js
// The first URL is the default content or ad to be rendered when the frequency limits reached.
const CONTENT_URLS = [
{ url: `https://${contentProducerUrl}/default-content.html` },
{ url: `https://${contentProducerUrl}/example-content.html` },
];
async function injectAd() {
// Load the worklet module.
await window.sharedStorage.worklet.addModule('creative-selection-by-frequency-worklet.js');
// Set the initial frequency count
window.sharedStorage.set('frequency-count', 0, {
ignoreIfPresent: true,
});
// Run the URL selection operation to choose an ad based on the frequency count in shared storage.
const fencedFrameConfig = await window.sharedStorage.selectURL('creative-selection-by-frequency', CONTENT_URLS, {
resolveToConfig: true
});
// Render the opaque URL into a fenced frame
document.getElementById('content-slot').config = fencedFrameConfig;
}
injectAd();
creative-selection-by-frequency-worklet.js
const FREQUENCY_LIMIT = 5;
class CreativeSelectionByFrequencyOperation {
async run(urls, data) {
// Read the current frequency limit in shared storage
const count = parseInt(await sharedStorage.get('frequency-count'));
// Check if the frequency limit has been reached.
if (count === FREQUENCY_LIMIT) {
console.log('Frequency limit has been reached, and the default content will be rendered.');
return 0;
}
// Set the new frequency count in shared storage
await sharedStorage.set('frequency-count', count + 1);
return 1;
}
}
// Register the operation as 'creative-selection-by-frequency'.
register('creative-selection-by-frequency', CreativeSelectionByFrequencyOperation);
Use cases
All available use cases for Select URL API can be found in this section. We'll continue to add examples as we receive feedback and discover new test cases.
- Rotate ad creatives: Store data, such as creative ID and user interaction, to determine which creative users' see across different sites.
- Select ad creatives by frequency: Use view count data to determine which creative users' see across different sites.
- Run A/B testing: You can assign a user to an experiment group, then store that group in Shared Storage to be accessed cross-site.
- Customize experience for known customers: Share custom content and calls-to-action based on a user's registration status or other user states.
참여 및 의견 공유
Select URL API 제안은 현재 논의 및 개발 중이며 변경될 수 있습니다.
Select URL API에 대한 의견을 보내주세요.
최신 정보 확인하기
- 메일링 리스트: 메일링 리스트를 구독하여 Select URL 및 Shared Storage API와 관련된 최신 업데이트 및 공지사항을 확인하세요.
도움이 필요하신가요?
- 개발자 지원: 개인 정보 보호 샌드박스 개발자 지원 저장소에서 다른 개발자와 소통하고 질문에 대한 답변을 얻을 수 있습니다.