ব্যবহারকারীর জনসংখ্যার পরিমাপ করুন

বিষয়বস্তু প্রযোজকরা প্রায়শই তাদের দর্শকদের জনসংখ্যা বুঝতে চান। আপনি শেয়ার্ড স্টোরেজ ব্যবহার করতে পারেন ব্যবহারকারীর জনসংখ্যা সংক্রান্ত ডেটা রেকর্ড করতে যেখানে আপনার কাছে এটি রয়েছে, যেমন আপনার প্রথম-পক্ষের সাইট, এবং তারপরে আপনার এমবেড করা সামগ্রীর মতো অন্যান্য সাইটের প্রতিবেদনে সেই ডেটা অন্তর্ভুক্ত করতে সমষ্টিগত প্রতিবেদন ব্যবহার করতে পারেন।

শেয়ার্ড স্টোরেজ API হল সাধারণ উদ্দেশ্যে, ক্রস-সাইট স্টোরেজের জন্য একটি গোপনীয়তা স্যান্ডবক্স প্রস্তাব, যা অনেক সম্ভাব্য ব্যবহারের ক্ষেত্রে সমর্থন করে। প্রাইভেট অ্যাগ্রিগেশন API হল শেয়ার্ড স্টোরেজে উপলব্ধ একটি আউটপুট যা আপনাকে ক্রস-সাইট ডেটা একত্রিত করতে দেয়।

ব্যবহারকারী জনসংখ্যার পরিমাপ চেষ্টা করুন

শেয়ার্ড স্টোরেজ এবং প্রাইভেট অ্যাগ্রিগেশনের সাথে ব্যবহারকারীর জনসংখ্যার পরিমাপ পরীক্ষা করতে, আপনি Chrome Canary এবং Dev M107 বা তার পরে ব্যবহার করছেন তা নিশ্চিত করুন। তারপরে chrome://flags/#privacy-sandbox-ads-apisগোপনীয়তা স্যান্ডবক্স বিজ্ঞাপন API-এর পরীক্ষার পতাকা সক্ষম করুন।

গোপনীয়তা স্যান্ডবক্স বিজ্ঞাপন API পরীক্ষা সেট করুন এই APIগুলি ব্যবহার করতে সক্ষম করুন৷

আপনি কমান্ড লাইনে --enable-features=PrivacySandboxAdsAPIsOverride,OverridePrivacySandboxSettingsLocalTesting,SharedStorageAPI,FencedFrames পতাকা সহ শেয়ার করা স্টোরেজ সক্ষম করতে পারেন।

কোড নমুনা সঙ্গে পরীক্ষা

আপনি এমন ব্যবহারকারীদের নির্দিষ্ট জনসংখ্যার পরিমাপ করতে চাইতে পারেন যারা বিভিন্ন সাইট জুড়ে আপনার সামগ্রী দেখেছেন, উদাহরণস্বরূপ বয়স পরিসীমা বা ভৌগলিক অবস্থান। এই উদাহরণে, বিষয়বস্তু আইডি, বয়স গোষ্ঠীর আইডি এবং ভূগোল আইডি মাত্রাগুলি একত্রিতকরণ কী (বালতি) এ এনকোড করা হয় এবং গণনাটি সমষ্টিগত মান হিসাবে ব্যবহৃত হয়। উত্পন্ন সারাংশ প্রতিবেদনটি তথ্য প্রদান করবে যেমন "প্রায় 391 জন ব্যবহারকারী যারা কন্টেন্ট আইডি 123 দেখেছেন তারা 18-39 বছরের মধ্যে এবং ইউরোপ থেকে এসেছেন।"

এই উদাহরণে:

  • demographic-measurement.js একটি ফ্রেমের মাধ্যমে লোড করা হয় এবং শেয়ার্ড স্টোরেজ ওয়ার্কলেট লোড করার জন্য দায়ী।
  • demographic-measurement-worklet.js হল শেয়ার্ড স্টোরেজ ওয়ার্কলেট যা শেয়ার্ড স্টোরেজে ডেমোগ্রাফিক ডেটা পড়ে এবং প্রাইভেট অ্যাগ্রিগেশন API-এর মাধ্যমে একটি রিপোর্ট পাঠায়।

store-demographic-data.js

(শেয়ারড স্টোরেজে ডেমোগ্রাফিক ডেটা সেট করার জন্য পরিমাপ করার আগে কিছু সময়ে চলে)

function getDemogrationsData() {
  // Collect age group and continent data
  return {
    ageGroup,
    continent
  }
}

async function storeDemographics() {
  const { ageGroup, continent } = getDemographicsData();
  await window.sharedStorage.set('age-group', ageGroup);
  await window.sharedStorage.set('continent', continent);
}

storeDemographics();

demographic-measurement.js

async function measureDemographics() {
  // Load the Shared Storage worklet
  await window.sharedStorage.worklet.addModule('demographics-measurement-worklet.js');

  // Run the demographics measurement operation
  await window.sharedStorage.run('demographics-measurement', { data: { contentId: '123' } });
}

measureDemographics();

demographic-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 simply the ad campaign
 * ID itself. For more complex bucket key construction, see other use cases in
 * this demo.
 */

const AGGREGATION_KEY_MAP = {
  ageGroupId: {
    '18-39': '1',
    '40-64': '2',
    '65+': '3',
  },

  continentId: {
    africa: '1',
    antarctica: '2',
    asia: '3',
    australia: '4',
    europe: '5',
    'north-america': '6',
    'south-america': '7',
  },

};

/**
 * The aggregation key will be in the format of:
 * contentId | ageGroupId | continentId
 *
 * For example, a user from Australia between the age of 40-64, who has
 * seen the Content ID 321 will be represented by the key:
 * 321 | 2 | 4 or 32124
 */

function generateAggregationKey(contentId, ageGroup, continent) {
  const ageGroupId = AGGREGATION_KEY_MAP.ageGroupId[ageGroup];
  const continentId = AGGREGATION_KEY_MAP.continentId[continent];
  const aggregationKey = BigInt(`${contentId}${ageGroupId}${continentId}`);

  return aggregationKey;
}

class DemographicsMeasurementOperation {
  async run(data) {
    const { contentId } = data;

    // Read from Shared Storage
    const key = 'has-reported-content';
    const hasReportedContent = (await this.sharedStorage.get(key)) === 'true';
    const ageGroup = await this.sharedStorage.get('age-group');
    const continent = await this.sharedStorage.get('continent');

    // Do not report if a report has been sent already
    if (hasReportedContent) {
      return;
    }

    // Generate the aggregation key and the aggregatable value
    const bucket = generateAggregationKey(contentId, ageGroup, continent);
    const value = 1 * SCALE_FACTOR;

    // Send an aggregatable report via the Private Aggregation API
    privateAggregation.sendHistogramReport({ bucket, value });

    // Set the report submission status flag
    await this.sharedStorage.set(key, true);
  }
}

// Register the operation
register('demographics-measurement', DemographicsMeasurementOperation); \

জড়িত এবং মতামত শেয়ার করুন

শেয়ার্ড স্টোরেজ প্রস্তাবটি সক্রিয় আলোচনার অধীনে রয়েছে এবং ভবিষ্যতে পরিবর্তন হতে পারে। আপনি যদি এই APIটি চেষ্টা করেন এবং প্রতিক্রিয়া জানান, আমরা এটি শুনতে চাই।