A/B टेस्टिंग करने के लिए, Shared Storage वर्कलेट का इस्तेमाल करें.
Shared Storage API, Privacy Sandbox का एक प्रस्ताव है. इसका इस्तेमाल, अलग-अलग कामों के लिए और एक से ज़्यादा साइटों पर डेटा सेव करने के लिए किया जाता है. यह कई तरह के इस्तेमाल के उदाहरणों के साथ काम करता है. इसका एक उदाहरण A/B टेस्टिंग है. यह Chrome 104.0.5086.0 और उसके बाद के वर्शन में टेस्ट करने के लिए उपलब्ध है.
किसी उपयोगकर्ता को एक्सपेरिमेंट ग्रुप में असाइन किया जा सकता है. इसके बाद, उस ग्रुप को SharedStorage में सेव किया जा सकता है, ताकि उसे क्रॉस-साइट एनवायरमेंट में ऐक्सेस किया जा सके.
A/B टेस्टिंग का इस्तेमाल करना
Shared Storage के साथ A/B टेस्टिंग का इस्तेमाल करने के लिए, पक्का करें कि Chrome 104.0.5086.0 या उसके बाद के वर्शन का इस्तेमाल किया जा रहा हो. chrome://settings/adPrivacy में जाकर, विज्ञापन देखने वाले की निजता बनाए रखने से जुड़े सभी एपीआई चालू करें.
कमांड लाइन में --enable-features=PrivacySandboxAdsAPIsOverride,OverridePrivacySandboxSettingsLocalTesting,SharedStorageAPI,FencedFrames फ़्लैग का इस्तेमाल करके भी, शेयर किए गए स्टोरेज की सुविधा चालू की जा सकती है.
कोड सैंपल आज़माएँ
यह देखने के लिए कि किसी एक्सपेरिमेंट का असर आपकी उम्मीद के मुताबिक है या नहीं, कई साइटों पर A/B टेस्टिंग की जा सकती है. विज्ञापन देने वाले व्यक्ति या कंपनी या कॉन्टेंट बनाने वाले व्यक्ति या कंपनी के तौर पर, आपके पास यह चुनने का विकल्प होता है कि उपयोगकर्ता को किस ग्रुप में असाइन किया गया है. इसके आधार पर, अलग-अलग कॉन्टेंट या विज्ञापन दिखाए जा सकते हैं. ग्रुप असाइनमेंट को शेयर किए गए स्टोरेज में सेव किया जाता है. हालांकि, इसे बाहर नहीं निकाला जा सकता.
इस उदाहरण में:
ab-testing.jsको एक फ़्रेम में एम्बेड किया जाना चाहिए. यह फ़्रेम, कंट्रोल और एक्सपेरिमेंट के दो कॉन्टेंट को मैप करता है. यह स्क्रिप्ट, एक्सपेरिमेंट के लिए Shared Storage के वर्कलेट को कॉल करती है.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.
Engage and share feedback
Note that the Select URL API proposal is under active discussion and development and subject to change.
We're eager to hear your thoughts on the Select URL API.
- Proposal: Review the detailed proposal.
- Discussion: Join the ongoing discussion to ask questions and share your insights.