بسیاری از تولیدکنندگان محتوا و تبلیغکنندگان میخواهند بدانند چه تعداد از افراد منحصربهفرد محتوای آنها را دیدهاند. از فضای ذخیرهسازی مشترک برای ضبط اولین باری که کاربر تبلیغ، ویدیوی جاسازی شده یا انتشارات شما را مشاهده کرد و از شمارش تکراری همان کاربر در سایتهای مختلف جلوگیری کنید. سپس می توانید از Private Aggregation API برای خروجی یک گزارش خلاصه برای دسترسی خود استفاده کنید.
Shared Storage API یک پیشنهاد Privacy Sandbox برای اهداف عمومی، فضای ذخیرهسازی بین سایتی است که از بسیاری از موارد استفاده ممکن پشتیبانی میکند. Private Aggregation API خروجی موجود در ذخیره سازی مشترک است که به شما امکان می دهد داده های بین سایتی را جمع آوری کنید. برای کسب اطلاعات بیشتر در مورد روشهای اجرای این اندازهگیریها، کاغذ سفید دسترسی ما را بررسی کنید.
اندازه گیری دسترسی منحصر به فرد را امتحان کنید
برای آزمایش اندازهگیری دسترسی منحصربهفرد با فضای ذخیرهسازی مشترک و تجمیع خصوصی، تأیید کنید که از Chrome M107 یا جدیدتر استفاده میکنید. همه APIهای حریم خصوصی تبلیغات را در chrome://settings/adPrivacy
فعال کنید.
همچنین میتوانید ذخیرهسازی مشترک را با پرچم --enable-features=PrivacySandboxAdsAPIsOverride,OverridePrivacySandboxSettingsLocalTesting,SharedStorageAPI,FencedFrames
در خط فرمان فعال کنید.
با نمونه کد آزمایش کنید
ممکن است بخواهید تعداد کاربران منحصربهفرد محتوای شما را در سایتهای مختلف مشاهده کنید. در این مثال، بعد Content ID در کلید جمعآوری (سطل) کدگذاری میشود و تعداد بهعنوان مقدار قابل جمعآوری استفاده میشود. گزارش خلاصه حاوی اطلاعاتی مانند "تقریباً 391 کاربر شناسه محتوای 123 را دیده اند."
در این مثال:
-
unique-reach-measurement.js
با استفاده از یک قاب بارگیری می شود و مسئول بارگیری Worklet ذخیره سازی مشترک است. -
unique-reach-measurement-worklet.js
یک Worklet ذخیره سازی مشترک است که پرچم را در حافظه مشترک بررسی می کند و گزارشی را با استفاده از Private Aggregation API ارسال می کند.
async function measureUniqueReach() {
// Load the Shared Storage worklet
await window.sharedStorage.worklet.addModule('reach-measurement-worklet.js');
// Run the reach measurement operation
await window.sharedStorage.run('reach-measurement', { data: { contentId: '1234' } });
}
measureUniqueReach();
// Learn more about noise and scaling from the Private Aggregation fundamentals
// documentation on Chrome blog
const SCALE_FACTOR = 65536;
function convertContentIdToBucket(contentId) {
return BigInt(contentId);
}
class ReachMeasurementOperation {
async run(data) {
const { contentId } = data;
// Read from Shared Storage
const key = 'has-reported-content';
const hasReportedContent = (await sharedStorage.get(key)) === 'true';
// Don't report if a report has been sent already
if (hasReportedContent) {
return;
}
// Generate the aggregation key and the aggregatable value
const bucket = convertContentIdToBucket(contentId);
const value = 1 * SCALE_FACTOR;
// Send an aggregatable report using the Private Aggregation API
privateAggregation.contributeToHistogram({ bucket, value });
// Set the report submission status flag
await sharedStorage.set(key, true);
}
}
// Register the operation
register('reach-measurement', ReachMeasurementOperation);
Engage and share feedback
Note that the Shared Storage API proposal is under active discussion and development and therefore subject to change.
We're eager to hear your thoughts on the Shared Storage 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 Shared Storage API.
Need Help?
- Developer Support: Connect with other developers and get answers to your questions in the Privacy Sandbox Developer Support repository.