공유 저장소 워크렛을 사용하여 A/B 테스트를 실행합니다.
Shared Storage API는 개인 정보 보호 다양한 용도를 지원하는 크로스 사이트 스토리지를 위한 범용 샌드박스 제안 사용 사례일 수 있습니다. 예를 들어 A/B 테스트는 Chrome 104.0.5086.0 이상에서 지원됩니다.
사용자 1명을 실험 그룹에 할당한 후 '공유됨' 섹션에 저장할 수 있습니다. 크로스 사이트 환경에서 액세스할 스토리지
A/B 테스트 사용해 보기
공유 저장소로 A/B 테스트를 실험하려면 Chrome 104.0.5086.0 이상을 사용 중인지 확인하세요. chrome://settings/adPrivacy
에서 모든 광고 개인 정보 보호 API를 사용 설정합니다.
명령줄에서 --enable-features=PrivacySandboxAdsAPIsOverride,OverridePrivacySandboxSettingsLocalTesting,SharedStorageAPI,FencedFrames
플래그를 사용하여 공유 저장소를 사용 설정할 수도 있습니다.
코드 샘플 실험
실험에서 원하는 결과를 얻을 수 있는지 확인하기 위해 여러 사이트에서 A/B 테스트를 실행할 수 있습니다. 광고주 또는 콘텐츠 제작자는 사용자가 할당된 그룹에 따라 다양한 콘텐츠나 광고를 렌더링할 수 있습니다. 그룹 할당은 공유 저장공간에 저장되지만 유출될 수 없습니다.
이 예에서는 다음과 같이 정의됩니다.
ab-testing.js
는 대조군과 두 개의 실험 콘텐츠를 매핑하는 프레임에 삽입되어야 합니다. 스크립트는 실험에 사용할 공유 스토리지 Worklet을 호출합니다.ab-testing-worklet.js
는 사용자가 할당된 그룹을 반환하는 공유 저장소 Worklet으로, 표시할 광고를 결정합니다.
// Randomly assigns a user to a group 0 or 1
function getExperimentGroup() {
return Math.round(Math.random());
}
async function injectContent() {
// Register the Shared Storage worklet
await window.sharedStorage.worklet.addModule('ab-testing-worklet.js');
// Assign user to a random group (0 or 1) and store it in Shared Storage
window.sharedStorage.set('ab-testing-group', getExperimentGroup(), {
ignoreIfPresent: true,
});
// Run the URL selection operation
const fencedFrameConfig = await window.sharedStorage.selectURL(
'ab-testing',
[
{ url: `https://your-server.example/content/default-content.html` },
{ url: `https://your-server.example/content/experiment-content-a.html` }
],
{
resolveToConfig: true
}
);
// Render the chosen URL into a fenced frame
document.getElementById('content-slot').config = fencedFrameConfig;
}
injectContent();
class SelectURLOperation {
async run(urls, data) {
// Read the user's experiment group from Shared Storage
const experimentGroup = await sharedStorage.get('ab-testing-group');
// Return the corresponding URL (first or second item in the array)
return urls.indexOf(experimentGroup);
}
}
register('ab-testing', SelectURLOperation);
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와 관련된 최신 업데이트 및 공지사항을 확인하세요.
도움이 필요하신가요?
- 개발자 지원: 개인 정보 보호 샌드박스 개발자 지원 저장소에서 다른 개발자와 소통하고 질문에 대한 답변을 얻을 수 있습니다.