A veces, se describe como "frecuencia efectiva". A menudo, hay una cantidad mínima de vistas antes de que un usuario reconozca o recuerde cierto contenido (a menudo, en el contexto de las vistas de anuncios). Puedes usar el almacenamiento compartido para crear informes de usuarios únicos que hayan visto un contenido al menos K veces.
La API de Shared Storage es una propuesta de Privacy Sandbox para el almacenamiento multisitio de uso general, que admite muchos casos de uso posibles. La API de Private Aggregation es un resultado disponible en Shared Storage que te permite agregar datos de varios sitios.
Prueba la medición de frecuencia superior a K
Para experimentar con la medición de frecuencia de K+ con almacenamiento compartido y agregación privada, confirma que estás usando Chrome M107 o una versión posterior. Habilita todas las APIs de privacidad en los anuncios en chrome://settings/adPrivacy
.
También puedes habilitar el almacenamiento compartido con la marca --enable-features=PrivacySandboxAdsAPIsOverride,OverridePrivacySandboxSettingsLocalTesting,SharedStorageAPI,FencedFrames
en la línea de comandos.
Experimenta con muestras de código
Te recomendamos que midas la cantidad de usuarios que vieron tu contenido K o más veces en un cliente determinado en diferentes sitios. En este ejemplo, el recuento de impresiones se agrega al almacenamiento compartido, donde aumenta en 1 cada vez que se carga el contenido. Cuando el recuento de impresiones alcanza el valor 3, se llama a la API de Private Aggregation. La dimensión de ID de contenido se codifica como la clave de agregación, y el recuento se usa como el valor agregable. El informe de resumen proporcionará información como "Aproximadamente 391 usuarios vieron el ID de la campaña publicitaria 123 al menos 3 veces".
En este ejemplo:
k-frequency-measurement.js
se carga con un marco y es responsable de cargar la worklet de almacenamiento compartido.k-frequency-measurement-worklet.js
es la tarea de trabajo de almacenamiento compartido que lee el recuento de impresiones en el almacenamiento compartido y envía un informe con la API de Private Aggregation.
k-frequency-measurement.js
async function injectContent() {
// Load the Shared Storage worklet
await window.sharedStorage.worklet.addModule('k-freq-measurement-worklet.js');
// Run the K-frequency measurement operation
await window.sharedStorage.run('k-freq-measurement', { data: { kFreq: 3, contentId: 123 });
}
injectContent();
kuency-measurement-worklet.js
// Learn more about noise and scaling from the Private Aggregation fundamentals
// documentation on Chrome blog
const SCALE_FACTOR = 65536;
/**
* The bucket key must be a number, and in this case, it is just the content
* ID itself. For more complex bucket key construction, see other use cases in
* this demo.
*/
function convertContentIdToBucket(contentId) {
return BigInt(contentId);
}
class KFreqMeasurementOperation {
async run(data) {
const { kFreq, contentId } = data;
// Read from Shared Storage
const hasReportedContentKey = 'has-reported-content';
const impressionCountKey = 'impression-count';
const hasReportedContent = (await sharedStorage.get(hasReportedContentKey)) === 'true';
const impressionCount = parseInt((await sharedStorage.get(impressionCountKey)) || 0);
// Don't report if a report has been sent already
if (hasReportedContent) {
return;
}
// Check impression count against frequency limit
if (impressionCount < kFreq) {
await sharedStorage.set(impressionCountKey, impressionCount + 1);
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(hasReportedContentKey, 'true');
}
}
// Register the operation
register('k-freq-measurement', KFreqMeasurementOperation); \
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.