Shared Storage worklet을 사용하여 A/B 테스트를 실행합니다.
Shared Storage API는 다양한 사용 사례를 지원하는 범용 크로스 사이트 스토리지를 위한 개인 정보 보호 샌드박스 제안입니다. 한 가지 예로 Chrome 104.0.5086.0 이상에서 테스트할 수 있는 A/B 테스트가 있습니다.
사용자를 실험 그룹에 할당한 다음 교차 사이트 환경에서 액세스할 수 있도록 공유 스토리지에 해당 그룹을 저장할 수 있습니다.
A/B 테스트 사용해 보기
Shared Storage로 A/B 테스트를 실험하려면 Chrome 104.0.5086.0 이상을 사용하고 있는지 확인하세요. chrome://settings/adPrivacy에서 모든 광고 개인 정보 보호 API를 사용 설정합니다.
명령줄에서 --enable-features=PrivacySandboxAdsAPIsOverride,OverridePrivacySandboxSettingsLocalTesting,SharedStorageAPI,FencedFrames 플래그를 사용하여 공유 스토리지를 사용 설정할 수도 있습니다.
코드 샘플 실험
실험이 원하는 효과를 내는지 확인하려면 여러 사이트에서 A/B 테스트를 실행하면 됩니다. 광고주 또는 콘텐츠 제작자는 사용자가 할당된 그룹에 따라 다른 콘텐츠 또는 광고를 렌더링하도록 선택할 수 있습니다. 그룹 할당은 공유 스토리지에 저장되지만 유출될 수는 없습니다.
예를 들면 다음과 같습니다.
ab-testing.js는 컨트롤과 두 실험 콘텐츠를 매핑하는 프레임에 삽입해야 합니다. 스크립트가 실험의 공유 저장소 워크릿을 호출합니다.ab-testing-worklet.js는 사용자가 할당된 그룹을 반환하여 표시되는 광고를 결정하는 공유 저장소 워클릿입니다.
// 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에 대한 의견을 기다리고 있습니다.