পরিচিত গ্রাহকদের সনাক্ত করতে একটি শেয়ার্ড স্টোরেজ ওয়ার্কলেট ব্যবহার করুন।
শেয়ার্ড স্টোরেজ API হল সাধারণ উদ্দেশ্যে, ক্রস-সাইট স্টোরেজের জন্য একটি গোপনীয়তা স্যান্ডবক্স প্রস্তাব, যা অনেক সম্ভাব্য ব্যবহারের ক্ষেত্রে সমর্থন করে। একটি উদাহরণ হল পরিচিত গ্রাহকদের সনাক্ত করা, যা Chrome 104.0.5086.0 এবং পরবর্তীতে পরীক্ষা করার জন্য উপলব্ধ৷
ব্যবহারকারী আপনার সাইটে শেয়ার্ড স্টোরেজে নিবন্ধিত হয়েছে কিনা তা আপনি সংরক্ষণ করতে পারেন, তারপর ব্যবহারকারীর সঞ্চিত স্থিতি (ব্যবহারকারী একজন "পরিচিত" গ্রাহক) কিনা তার উপর ভিত্তি করে একটি পৃথক উপাদান রেন্ডার করতে পারেন।
পরিচিত গ্রাহকদের সেট করুন
শেয়ার্ড স্টোরেজে পরিচিত গ্রাহকদের শনাক্ত করার জন্য পরীক্ষা করতে, আপনি Chrome 104.0.5086.0 বা তার পরবর্তী সংস্করণ ব্যবহার করছেন তা নিশ্চিত করুন। chrome://settings/adPrivacy
অধীনে সমস্ত বিজ্ঞাপন গোপনীয়তা API সক্রিয় করুন।
আপনি কমান্ড লাইনে --enable-features=PrivacySandboxAdsAPIsOverride,OverridePrivacySandboxSettingsLocalTesting,SharedStorageAPI,FencedFrames
পতাকা সহ শেয়ার করা স্টোরেজ সক্ষম করতে পারেন।
কোড নমুনা সঙ্গে পরীক্ষা
ব্যবহারকারীকে একটি ভিন্ন সাইটে দেখা হয়েছে কিনা তার উপর ভিত্তি করে আপনি একটি ভিন্ন উপাদান রেন্ডার করতে চাইতে পারেন। উদাহরণস্বরূপ, একজন অর্থপ্রদান প্রদানকারী একটি "নিবন্ধন করুন" বা "এখনই কিনুন" বোতাম রেন্ডার করতে চাইতে পারে যে ব্যবহারকারী অর্থ প্রদানকারীর সাইটে নিবন্ধন করেছেন কিনা। শেয়ার্ড স্টোরেজ ব্যবহারকারীর স্থিতি সেট করতে এবং সেই স্থিতির উপর ভিত্তি করে তাদের ব্যবহারকারীর অভিজ্ঞতা কাস্টমাইজ করতে ব্যবহার করা যেতে পারে।
এই উদাহরণে:
-
known-customer.js
একটি ফ্রেমে এম্বেড করা আছে। এই স্ক্রিপ্টটি একটি সাইটে কোন বোতামটি প্রদর্শিত হবে তার বিকল্পগুলি সেট করে, "নিবন্ধন করুন" বা "এখনই কিনুন।" -
known-customer-worklet.js
হল শেয়ার্ড স্টোরেজ ওয়ার্কলেট যা নির্ধারণ করে যে ব্যবহারকারী পরিচিত কিনা। ব্যবহারকারী পরিচিত হলে, তথ্য ফেরত দেওয়া হয়. ব্যবহারকারী অজানা হলে, "নিবন্ধন" বোতামটি প্রদর্শন করতে সেই তথ্য ফেরত দেওয়া হয় এবং ব্যবহারকারীকে ভবিষ্যতের জন্য পরিচিত হিসাবে চিহ্নিত করা হয়।
// The first URL for the "register" button is rendered for unknown users.
const BUTTON_URLS = [
{ url: `https://${advertiserUrl}/ads/register-button.html` },
{ url: `https://${advertiserUrl}/ads/buy-now-button.html` },
];
async function injectButton() {
// Load the worklet module
await window.sharedStorage.worklet.addModule('known-customer-worklet.js');
// Set the initial status to unknown ('0' is unknown and '1' is known)
window.sharedStorage.set('known-customer', 0, {
ignoreIfPresent: true,
});
// Run the URL selection operation to choose the button based on the user status
const fencedFrameConfig = await window.sharedStorage.selectURL('known-customer', BUTTON_URLS, {
resolveToConfig: true
});
// Render the opaque URL into a fenced frame
document.getElementById('button-slot').src = fencedFrameConfig;
}
injectButton();
class SelectURLOperation {
async run(urls) {
const knownCustomer = await sharedStorage.get('known-customer');
// '0' is unknown and '1' is known
return parseInt(knownCustomer);
}
}
register('known-customer', 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.
Stay Informed
- Mailing List: Subscribe to our mailing list for the latest updates and announcements related to the Select URL and Shared Storage APIs.
Need Help?
- Developer Support: Connect with other developers and get answers to your questions in the Privacy Sandbox Developer Support repository.