A/B testi yapmak için Paylaşılan Depolama iş akışı kullanın.
Shared Storage API; genel amaçlı, siteler arası depolamaya yönelik bir Özel Korumalı Alan teklifidir. Birçok olası kullanım alanını destekler. Chrome 104.0.5086.0 ve sonraki sürümlerde test etmek için kullanılabilen A/B testi de buna bir örnektir.
Bir deneme grubuna kullanıcı atayabilir ve ardından bu grubu, siteler arası bir ortamda erişilebilmesi için Paylaşılan Depolama'da depolayabilirsiniz.
A/B testini deneyin
Paylaşılan depolama alanıyla A/B testi denemesi yapmak için Chrome 104.0.5086.0 veya sonraki bir sürümü kullandığınızdan emin olun. chrome://settings/adPrivacy
altındaki tüm reklam gizliliği API'lerini etkinleştirin.
Paylaşılan Depolama Alanı'nı, komut satırındaki --enable-features=PrivacySandboxAdsAPIsOverride,OverridePrivacySandboxSettingsLocalTesting,SharedStorageAPI,FencedFrames
işaretini kullanarak da etkinleştirebilirsiniz.
Kod örnekleriyle denemeler yapma
Bir denemenin istenen etkiyi yaratıp yaratmadığını görmek için birden fazla sitede A/B testi çalıştırabilirsiniz. Bir reklamveren veya içerik üreticisi olarak, kullanıcının atandığı gruba bağlı olarak farklı içerik veya reklamlar oluşturmayı seçebilirsiniz. Grup ataması paylaşılan depolama alanına kaydedildi, ancak çalınamaz.
Bu örnekte:
ab-testing.js
, bir kontrol ve iki deneme içeriğini eşleyen bir çerçeveye yerleştirilmelidir. Komut dosyası, deneme için paylaşılan depolama alanı iş akışını çağırır.ab-testing-worklet.js
, hangi reklamın gösterileceğini belirleyerek kullanıcının hangi gruba atandığını döndüren paylaşılan depolama iş uygulamasıdır.
// 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 this.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
These are only some of the possible use cases for Shared Storage. We'll continue to add examples as we receive feedback and discover new use cases.
Content selection
Select and display different content on different websites in fenced frames based on information collected in Shared Storage. The output gate for these use cases is URL selection.
- Creative rotation: Store data, such as creative ID, view counts, and user interaction, to determine which creative users' see across different sites.
- A/B testing: You can assign a user to an experiment group, then store that group in Shared Storage to be accessed cross-site.
- Custom user experiences: Share custom content and calls-to-action based on a user's registration status or other user states
Generate summary reports
Collect information with Shared Storage and generated a noisy, aggregated summary report. The output gate for these use cases is the Private Aggregation API.
- Unique reach measurement: Many content producers and advertisers want to know how many unique people saw their content. Use Shared Storage to record the first time a user saw your ad, embedded video, or publication, and prevent duplicative counting of that same user on different sites. You can then use the Private Aggregation API to output a summary report for your reach.
- Demographics measurement: Content producers often want to understand the demographics of their audience. You can use Shared Storage to record user demographic data in a context where you have it, such as your first-party site, and use aggregated reporting to report on it across many other sites, such as embedded content.
- K+ frequency measurement: Sometimes described as "effective frequency," there is often a minimum number views before a user will recognize or recall certain content (often in the context of advertisement views). You can use Shared Storage to build reports of unique users that have seen a piece of content at least K number of times.
Etkileşimde bulunun ve geri bildirim paylaşın
Paylaşılan Depolama alanı teklifi şu anda etkin bir şekilde tartışılmaktadır ve gelecekte değiştirilebilir. Bu API'yi deneyip geri bildirimde bulunursanız memnuniyet duyarız.
- GitHub: Teklifi okuyun, soruları sorun ve tartışmaya katılın.
- Shared Storage API duyuruları: Posta listemizdeki eski duyurulara katılın veya bu duyuruları görüntüleyin
- Geliştirici desteği: Özel Korumalı Alan Geliştirici Desteği deposunda soru sorun ve tartışmalara katılın.