1,000 से ज़्यादा फ़्रीक्वेंसी वाली रीच मेज़र करना

इसे कभी-कभी "इफ़ेक्टिव फ़्रीक्वेंसी" भी कहा जाता है. किसी उपयोगकर्ता को कुछ कॉन्टेंट (अक्सर विज्ञापन व्यू के संदर्भ में) पहचानने या याद रखने से पहले, उसे कम से कम कुछ बार देखना होता है. Shared Storage का इस्तेमाल करके, उन यूनीक उपयोगकर्ताओं की रिपोर्ट बनाई जा सकती हैं जिन्होंने किसी कॉन्टेंट को कम से कम K बार देखा है.

Shared Storage API, Privacy Sandbox का एक प्रस्ताव है. इसका इस्तेमाल, अलग-अलग कामों के लिए और एक से ज़्यादा साइटों पर डेटा सेव करने के लिए किया जाता है. यह कई तरह के इस्तेमाल के उदाहरणों के साथ काम करता है. Private Aggregation API, Shared Storage में उपलब्ध एक आउटपुट है. इसकी मदद से, अलग-अलग साइटों से मिले डेटा को एग्रीगेट किया जा सकता है.

K से ज़्यादा बार विज्ञापन देखे जाने का पता लगाने की सुविधा आज़माएं

Shared Storage और Private Aggregation की मदद से, K+ फ़्रीक्वेंसी मेज़रमेंट को आज़माने के लिए, पक्का करें कि Chrome M107 या इसके बाद के वर्शन का इस्तेमाल किया जा रहा हो. chrome://settings/adPrivacy में जाकर, विज्ञापन देखने वाले की निजता बनाए रखने से जुड़े सभी एपीआई चालू करें.

कमांड लाइन में --enable-features=PrivacySandboxAdsAPIsOverride,OverridePrivacySandboxSettingsLocalTesting,SharedStorageAPI,FencedFrames फ़्लैग का इस्तेमाल करके भी, शेयर किए गए स्टोरेज की सुविधा चालू की जा सकती है.

कोड सैंपल आज़माएँ

आपको यह पता लगाना हो सकता है कि किसी क्लाइंट के लिए, अलग-अलग साइटों पर आपके कॉन्टेंट को K या उससे ज़्यादा बार देखने वाले उपयोगकर्ताओं की संख्या कितनी है. इस उदाहरण में, इंप्रेशन की संख्या को शेयर किए गए स्टोरेज में जोड़ा जाता है. जब भी कॉन्टेंट लोड होता है, तब यह संख्या 1 से बढ़ जाती है. जब इंप्रेशन की संख्या तीन तक पहुंच जाती है, तब Private Aggregation API को कॉल किया जाता है. कॉन्टेंट आईडी डाइमेंशन को एग्रीगेशन कुंजी के तौर पर कोड में बदला जाता है. साथ ही, गिनती का इस्तेमाल एग्रीगेट की जा सकने वाली वैल्यू के तौर पर किया जाता है. खास जानकारी वाली रिपोर्ट में, इस तरह की जानकारी मिलेगी: "लगभग 391 उपयोगकर्ताओं ने विज्ञापन कैंपेन आईडी 123 को कम से कम तीन बार देखा है."

इस उदाहरण में:

  • k-frequency-measurement.js को फ़्रेम का इस्तेमाल करके लोड किया जाता है. साथ ही, यह शेयर किए गए स्टोरेज वर्कलेट को लोड करने के लिए ज़िम्मेदार होता है.
  • k-frequency-measurement-worklet.js, Shared Storage वर्कलेट है. यह Shared Storage में मौजूद इंप्रेशन की संख्या को पढ़ता है और Private Aggregation API का इस्तेमाल करके रिपोर्ट भेजता है.

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); \

सुझाव/राय देना या शिकायत करना

ध्यान दें कि Shared Storage API के प्रस्ताव पर अभी चर्चा चल रही है और इसे डेवलप किया जा रहा है. इसलिए, इसमें बदलाव हो सकता है.

हमें Shared Storage API के बारे में आपके सुझावों का इंतज़ार रहेगा.