Attribution Reporting API की डेवलपर की गाइड

Android पर प्राइवसी सैंडबॉक्स से जुड़े दस्तावेज़ को पढ़ते समय, डेवलपर झलक या बीटा बटन का इस्तेमाल करके, प्रोग्राम का वह वर्शन चुनें जिस पर आपको काम करना है. हालांकि, निर्देश अलग-अलग हो सकते हैं.


सुझाव, शिकायत या राय दें

Attribution Reporting API को, उपयोगकर्ता की निजता को बेहतर बनाने के लिए डिज़ाइन किया गया है. ऐसा करने से, क्रॉस-पार्टी यूज़र आइडेंटिफ़ायर पर निर्भरता को कम किया जाता है. साथ ही, सभी ऐप्लिकेशन में एट्रिब्यूशन और कन्वर्ज़न मेज़रमेंट के मुख्य इस्तेमाल के उदाहरणों में सहायता मिलती है. इस डेवलपर गाइड में कॉल करने के ऐसे तरीकों की मदद से विज्ञापन क्लिक, व्यू, और कन्वर्ज़न को रजिस्टर करने के लिए Attribution Reporting API को कॉन्फ़िगर और टेस्ट करने का तरीका बताया गया है जो इस तरह के इवेंट के लिए काम के ट्रिगर और सोर्स को रजिस्टर करता है.

इस गाइड में, सर्वर एंडपॉइंट को सेट अप करने और इन सेवाओं को कॉल करने वाला क्लाइंट ऐप्लिकेशन बनाने का तरीका बताया गया है. डिज़ाइन प्रस्ताव में, Attribution Reporting API के पूरे डिज़ाइन के बारे में ज़्यादा जानें.

प्रमुख शर्तें

  • एट्रिब्यूशन स्रोत क्लिक या व्यू से संबंधित हैं.
  • ट्रिगर ऐसे इवेंट होते हैं जिन्हें कन्वर्ज़न के लिए एट्रिब्यूट किया जा सकता है.
  • रिपोर्ट में ट्रिगर और उससे जुड़े एट्रिब्यूशन सोर्स के बारे में डेटा होता है. ये रिपोर्ट, ट्रिगर किए गए इवेंट के जवाब में भेजी जाती हैं. Attribution Reporting API, इवेंट-लेवल की रिपोर्ट और एग्रीगेट की जा सकने वाली रिपोर्ट के साथ काम करता है.

शुरू करने से पहले

Attribution Reporting API का इस्तेमाल करने के लिए, नीचे दिए गए सर्वर-साइड और क्लाइंट-साइड टास्क को पूरा करें.

Attribution Reporting API के एंडपॉइंट सेट अप करें

Attribution Reporting API को, एंडपॉइंट के एक सेट की ज़रूरत होती है जिसे किसी टेस्ट डिवाइस या एम्युलेटर से ऐक्सेस किया जा सकता है. नीचे दिए गए हर सर्वर साइड टास्क के लिए एक एंडपॉइंट बनाएं:

ज़रूरी एंडपॉइंट सेट अप करने के कई तरीके हैं:

  • तैयार करने और इस्तेमाल करने का सबसे तेज़ तरीका, OpenAPI v3 सेवा की परिभाषाओं को हमारे सैंपल कोड डेटा स्टोर करने की जगह से मॉक या माइक्रोसर्विस प्लैटफ़ॉर्म पर डिप्लॉय करें. पोस्टमैन, Prism या इस फ़ॉर्मैट को स्वीकार करने वाले किसी भी दूसरे मॉक सर्वर प्लैटफ़ॉर्म का इस्तेमाल किया जा सकता है. हर एंडपॉइंट को डिप्लॉय करें और अपने ऐप्लिकेशन में इस्तेमाल के लिए यूआरआई का ट्रैक रखें. रिपोर्ट की डिलीवरी की पुष्टि करने के लिए, मॉक या सर्वर के बिना किए गए प्लैटफ़ॉर्म पर पहले किए गए कॉल देखें.
  • Spring बूट पर आधारित Kotlin सैंपल का इस्तेमाल करके, अपना स्टैंडअलोन सर्वर चलाएं. इस सर्वर को अपने क्लाउड प्रोवाइडर या इंटरनल इन्फ़्रास्ट्रक्चर पर डिप्लॉय करें.
  • अपने मौजूदा सिस्टम में एंडपॉइंट को इंटिग्रेट करने के लिए, सेवा की परिभाषाओं को उदाहरणों के तौर पर इस्तेमाल करें.

सोर्स का रजिस्ट्रेशन स्वीकार करें

इस एंडपॉइंट पर नीचे दिए गए यूआरएल से मिलते-जुलते यूआरएल का इस्तेमाल किया जाना चाहिए:

https://adtech.example/attribution_source

जब कोई क्लाइंट ऐप्लिकेशन किसी एट्रिब्यूशन सोर्स को रजिस्टर करता है, तो यह इस सर्वर एंडपॉइंट के लिए यूआरआई देता है. इसके बाद, Attribution Reporting API एक अनुरोध करता है और उसमें नीचे दिए गए हेडर में से किसी एक को शामिल करता है:

  • क्लिक इवेंट के लिए:

    Attribution-Reporting-Source-Info: navigation
    
  • इवेंट देखने के लिए:

    Attribution-Reporting-Source-Info: event
    

अपने सर्वर एंडपॉइंट को कॉन्फ़िगर करें, ताकि यह आपको इनके साथ जवाब दे सके:

// Metadata associated with attribution source.
Attribution-Reporting-Register-Source: {
  "destination": "[app package name]",
  "web_destination": "[eTLD+1]",
  "source_event_id": "[64 bit unsigned integer]",
  "expiry": "[64 bit signed integer]",
  "event_report_window": "[64-bit signed integer]",
  "aggregatable_report_window": "[64-bit signed integer]",
  "priority": "[64 bit signed integer]",
  "filter_data": {
    "[key name 1]": ["key1 value 1", "key1 value 2"],
    "[key name 2]": ["key2 value 1", "key2 value 2"],
    // Note: "source_type" key will be automatically generated as
    // one of {"navigation", "event"}.
  },
  // Attribution source metadata specifying histogram contributions in aggregate
  // report.
  "aggregation_keys": {
    "[key1 name]": "[key1 value]",
    "[key2 name]": "[key2 value]",
  },

    "debug_key": "[64-bit unsigned integer]",
    "debug_reporting": [boolean]
}
// Specify additional ad tech URLs to register this source with.
Attribution-Reporting-Redirect: <Ad Tech Partner URI 1>
Attribution-Reporting-Redirect: <Ad Tech Partner URI 2>

यहां एक उदाहरण दिया गया है, जिसमें सैंपल वैल्यू जोड़ी गई हैं:

Attribution-Reporting-Register-Source: {
  "destination": "android-app://com.example.advertiser",
  "source_event_id": "234",
  "expiry": "259200",
  "event_report_window": "172800",
  "aggregatable_report_window": "172800",
  "priority": "5",
  "filter_data": {
    "product_id": ["1234"]
  },
  "aggregation_keys": {
  // Generates a "0x159" key piece named (low order bits of the key) for the key
  // named "campaignCounts".
  // User saw an ad from campaign 345 (out of 511).
    "campaignCounts": "0x159",

  // Generates a "0x5" key piece (low order bits of the key) for the key named
  // "geoValue".
  // Source-side geo region = 5 (US), out of a possible ~100 regions.
    "geoValue": "0x5",
  },
  // Opts in to receiving verbose debug reports
  "debug_reporting": true
}

Attribution-Reporting-Redirect:
https://adtechpartner1.example?their_ad_click_id=567
Attribution-Reporting-Redirect:
https://adtechpartner2.example?their_ad_click_id=890

अगर Attribution-Reporting-Redirects में विज्ञापन टेक्नोलॉजी पार्टनर के यूआरआई शामिल हैं, तो Attribution Reporting API हर यूआरआई के लिए एक जैसा अनुरोध करता है. विज्ञापन टेक्नोलॉजी से जुड़े हर पार्टनर को एक ऐसा सर्वर कॉन्फ़िगर करना होगा जो इन हेडर का इस्तेमाल करता हो:

Attribution-Reporting-Register-Source: {
  "destination": "[app package name]",
  "web_destination": "[eTLD+1]",
  "source_event_id": "[64 bit unsigned integer]",
  "expiry": "[64 bit signed integer]",
  "event_report_window": "[64-bit signed integer]",
  "aggregatable_report_window": "[64-bit signed integer]",
  "priority": "[64 bit signed integer]",
  "filter_data": {
    "[key name 1]": ["key1 value 1", "key1 value 2"],
    "[key name 2]": ["key2 value 1", "key2 value 2"],
    // Note: "source_type" key will be automatically generated as
    // one of {"navigation", "event"}.
  },
  "aggregation_keys": {
    "[key1 name]": "[key1 value]",
    "[key2 name]": "[key2 value]",
  }
}
// The Attribution-Reporting-Redirect header is ignored for ad tech partners.

कन्वर्ज़न ट्रिगर का रजिस्ट्रेशन स्वीकार करें

इस एंडपॉइंट पर नीचे दिए गए यूआरएल से मिलते-जुलते यूआरएल का इस्तेमाल किया जाना चाहिए:

https://adtech.example/attribution_trigger

जब कोई क्लाइंट ऐप्लिकेशन किसी ट्रिगर इवेंट को रजिस्टर करता है, तो यह इस सर्वर एंडपॉइंट के लिए यूआरआई देता है. इसके बाद, Attribution Reporting API एक अनुरोध करता है और उसमें नीचे दिए गए किसी एक हेडर को शामिल करता है:

अपने सर्वर एंडपॉइंट को कॉन्फ़िगर करें, ताकि यह आपको इनके साथ जवाब दे सके:

// Metadata associated with trigger.
Attribution-Reporting-Register-Trigger: {
  "event_trigger_data": [{
    // "trigger_data returned" in event reports is truncated to
    // the last 1 or 3 bits, based on conversion type.
    "trigger_data": "[unsigned 64-bit integer]",
    "priority": "[signed 64-bit integer]",
    "deduplication_key": "[signed 64-bit integer]",
    // "filter" and "not_filters" are optional fields which allow configuring
    // event trigger data based on source's filter_data. They consist of a
    // filter set, which is a list of filter maps. An event_trigger_data object
    // is ignored if none of the filter maps in the set match the source's
    // filter data.
    // Note: "source_type" can be used as a key in a filter map to filter based
    // on the source's "navigation" or "event" type. The first
    // Event-Trigger that matches (based on the filters/not_filters) will be
    // used for report generation. If none of the event-triggers match, no
    // event report will be generated.
    "filters": [{
      "[key name 1]": ["key1 value 1", "key1 value 2"],
      // If a key is missing from filters or source's filter_data, it won't be
      // used during matching.
      "[key name 2]": ["key2 value 1", "key2 value 2"],
    }],
    "not_filters":  [{
      "[key name 1]": ["key1 value 1", "key1 value 2"],
      // If a key is missing from not_filters or source's filter_data, it won't
      // be used during matching.
      "[key name 2]": ["key2 value 1", "key2 value 2"],
    }]
  }],
  // Specify a list of dictionaries that generates aggregation keys.
  "aggregatable_trigger_data": [
    // Each dictionary entry independently adds pieces to multiple source keys.
    {
      "key_piece": "[key piece value]",
      "source_keys": ["[key name the key piece value applies to]",
      ["list of IDs in source to match. Non-matching IDs are ignored"]]
      // filters/not_filters are optional fields similar to event trigger data
      // filter fields.
      "filters": [{
        "[key name 1]": ["key1 value 1", "key1 value 2"]
      }],
      "not_filters":  [{
          "[key name 1]": ["key1 value 1", "key1 value 2"],
          "[key name 2]": ["key2 value 1", "key2 value 2"],
      }]
    },
    ..
  ],
  // Specify an amount of an abstract value which can be integers in [1, 2^16]
  // to contribute to each key that is attached to aggregation keys in the
  // order they are generated.
  "aggregatable_values": [
     // Each source event can contribute a maximum of L1 = 2^16 to the
     // aggregate histogram.
    {
     "[key_name]": [value]
    },
    ..
  ],
  aggregatable_deduplication_keys: [{
  deduplication_key": [unsigned 64-bit integer],
    "filters": {
        "category": [filter_1, …, filter_H]
      },
    "not_filters": {
        "category": [filter_1, …, filter_J]
      }
  },
  ...
  {
  "deduplication_key": [unsigned 64-bit integer],
    "filters": {
        "category": [filter_1, …, filter_D]
      },
    "not_filters": {
        "category": [filter_1, …, filter_J]
      }
    }
  ]

  "debug_key": "[64-bit unsigned integer]",
  "debug_reporting": [boolean]

}
// Specify additional ad tech URLs to register this trigger with.
// Repeated Header field "Attribution-Reporting-Redirect"
Attribution-Reporting-Redirect: <Ad Tech Partner URI 1>
Attribution-Reporting-Redirect: <Ad Tech Partner URI 2>

यहां एक उदाहरण दिया गया है, जिसमें सैंपल वैल्यू जोड़ी गई हैं:

Attribution-Reporting-Register-Trigger: {
  "event_trigger_data": [{
    "trigger_data": "1122", // Returns 010 for CTCs and 0 for VTCs in reports.
    "priority": "3",
    "deduplication_key": "3344"
    "filters": [{ // Filter strings can not exceed 25 characters
      "product_id": ["1234"],
      "source_type": ["event"]
    }]
  },
  {
    "trigger_data": "4", // Returns 100 for CTCs and 0 for VTCs in reports.
    "priority": "3",
    "deduplication_key": "3344"
    "filters": [{ // Filter strings can not exceed 25 characters
      "product_id": ["1234"],
      "source_type": ["navigation"]
    }]
  }],
  "aggregatable_trigger_data": [
    // Each dictionary independently adds pieces to multiple source keys.
    {
      // Conversion type purchase = 2 at a 9-bit offset, i.e. 2 << 9.
      // A 9-bit offset is needed because there are 511 possible campaigns,
      // which takes up 9 bits in the resulting key.
      "key_piece": "0x400",// Conversion type purchase = 2
      // Apply this key piece to:
      "source_keys": ["campaignCounts"]
       // Filter strings can not exceed 25 characters
    },
    {
      // Purchase category shirts = 21 at a 7-bit offset, i.e. 21 << 7.
      // A 7-bit offset is needed because there are ~100 regions for the geo
      // key, which takes up 7 bits of space in the resulting key.
      "key_piece": "0xA80",
      // Apply this key piece to:
      "source_keys": ["geoValue", "nonMatchingIdsAreIgnored"]
      // source_key values must not exceed the limit of 25 characters
    }
  ],
  "aggregatable_values":
    {
      // Privacy budget for each key is L1 / 2 = 2^15 (32768).
      // Conversion count was 1.
      // Scale the count to use the full budget allocated: 1 * 32768 = 32768.
      "campaignCounts": 32768,

      // Purchase price was $52.
      // Purchase values for the app range from $1 to $1,024 (integers only).
      // Scaling factor applied is 32768 / 1024 = 32.
      // For $52 purchase, scale the value by 32 ($52 * 32 = $1,664).
      "geoValue": 1664
    }
  ,
  // aggregatable_deduplication_keys is an optional field. Up to 50 "keys"
  // can be included in the aggregatable_deduplication_keys list. Filters, not
  // filters, and deduplication_key are optional fields. If deduplication_key
  // is omitted, it will be treated as a null value. See
  // https://wicg.github.io/attribution-reporting-api/#triggering-aggregatable-attribution
  aggregatable_deduplication_keys:
  [
    {
    deduplication_key": 3,
        "filters": {
          "category": [A]
        }
    },
    {
    "deduplication_key": 4,
        "filters": {
          "category": [C, D]
        },
        "not_filters": {
          "category": [F]
        }
    }
  ]
  // Opts into receiving verbose debug reports
  "debug_reporting": true
}
Attribution-Reporting-Redirect:https://adtechpartner.example?app_install=567

हर एग्रीगेशन कुंजी आईडी और फ़िल्टर स्ट्रिंग के लिए, ज़्यादा से ज़्यादा 25 बाइट का डेटा इस्तेमाल किया जा सकता है. इसका मतलब है कि आपके एग्रीगेशन कुंजी आईडी और फ़िल्टर स्ट्रिंग में 25 से ज़्यादा वर्ण नहीं होने चाहिए. इस उदाहरण में, campaignCounts में 14 वर्ण हैं, इसलिए यह एग्रीगेशन की एक मान्य आईडी और 1234 में चार वर्ण हैं. इसलिए, यह एक मान्य फ़िल्टर स्ट्रिंग है. अगर एग्रीगेशन की कुंजी के आईडी या फ़िल्टर स्ट्रिंग में 25 से ज़्यादा वर्ण होते हैं, तो ट्रिगर को अनदेखा कर दिया जाता है.

अगर Attribution-Reporting-Redirect में विज्ञापन टेक्नोलॉजी पार्टनर के यूआरआई शामिल हैं, तो Attribution Reporting API हर यूआरआई के लिए एक जैसा अनुरोध करता है. विज्ञापन टेक्नोलॉजी से जुड़े हर पार्टनर को एक ऐसा सर्वर कॉन्फ़िगर करना होगा जो इन हेडर का इस्तेमाल करता हो:

// Metadata associated with trigger.
Attribution-Reporting-Register-Trigger: {
  "event_trigger_data": [{
    // "trigger_data" returned in event reports is truncated to
    // the last 1 or 3 bits, based on conversion type.
    "trigger_data": "[unsigned 64-bit integer]",
    "priority": "[signed 64-bit integer]",
    "deduplication_key": "[signed 64-bit integer]",
    // filter and not_filters are optional fields which allow configuring
    // different event trigger data based on source's filter_data. They
    // consist of a filter set, which is a list of filter maps. An
    // event_trigger_data object is ignored if none of the filter maps in the
    // set match the source's filter data. Note: "source_type" can be used as
    // a key in a filter map to filter based on the source's "navigation" or
    // "event" type. The first Event-Trigger that matches (based on the
    // filters/not_filters) will be used for report generation. If none of the
    // event-triggers match, no report will be generated.
    "filters": [{
      "[key name 1]": ["key1 value 1", "key1 value 2"],
      // If a key is missing from filters or source's filter_data, it will not be
      // used during matching.
      "[key name 2]": ["key2 value 1", "key2 value 2"],
    }],
    "not_filters":  [{
      "[key name 1]": ["key1 value 1", "key1 value 2"],
      // If a key is missing from not_filters or source's filter_data, it will not
      // be used during matching.
      "[key name 2]": ["key2 value 1", "key2 value 2"],
    }]
  }],
  "aggregatable_trigger_data": [
    // Each dictionary entry independently adds pieces to multiple source keys.
    {
      "key_piece": "[key piece value]",
      "source_keys": ["[key name the key piece value applies to]",
      ["list of IDs in source to match. Non-matching IDs are ignored"]],
      // filters/not_filters are optional fields similar to event trigger data
      // filter fields.
      "filters": [{
        "[key name 1]": ["key1 value 1", "key1 value 2"]
      }],
      "not_filters":  [{
          "[key name 1]": ["key1 value 1", "key1 value 2"],
          "[key name 2]": ["key2 value 1", "key2 value 2"],
      }]
    },
    ..
  ],
  // Specify an amount of an abstract value which can be integers in [1, 2^16] to
  // contribute to each key that is attached to aggregation keys in the order they
  // are generated.
  "aggregatable_values": [
    // Each source event can contribute a maximum of L1 = 2^16 to the aggregate
    // histogram.
    {
     "[key_name]": [value]
    }
  ]
}
// The Attribution-Reporting-Redirect header is ignored for ad tech partners.

इवेंट-लेवल की रिपोर्ट स्वीकार करें

इस एंडपॉइंट पर यूआरआई का इस्तेमाल किया जाना चाहिए. यूआरआई को रजिस्टर करने के बारे में ज़्यादा जानकारी के लिए, Privacy Sandbox खाते के लिए रजिस्टर करना देखें. (यूआरआई, सोर्स रजिस्ट्रेशन और ट्रिगर रजिस्ट्रेशन स्वीकार करने के लिए इस्तेमाल किए जाने वाले सर्वर के ऑरिजिन से लिया जाता है.) सोर्स रजिस्ट्रेशन स्वीकार करने और ट्रिगर रजिस्ट्रेशन स्वीकार करने वाले एंडपॉइंट के लिए, उदाहरण वाले यूआरआई का इस्तेमाल करके, इस एंडपॉइंट का यूआरआई है:

https://adtech.example/.well-known/attribution-reporting/report-event-attribution

इस सर्वर को इस फ़ॉर्मैट का इस्तेमाल करने वाले JSON अनुरोधों को स्वीकार करने के लिए कॉन्फ़िगर करें:

{
  "attribution_destination": "android-app://com.advertiser.example",
  "source_event_id": "12345678",
  "trigger_data": "2",
  "report_id": "12324323",
  "source_type": "navigation",
  "randomized_trigger_rate": "0.02"
   [Optional] "source_debug_key": "[64-bit unsigned integer]",
   [Optional] "trigger_debug_key": "[64-bit unsigned integer]",
}

डीबग कुंजियों की मदद से, अपनी एट्रिब्यूशन रिपोर्ट में ज़्यादा अहम जानकारी पाई जा सकती है. इन्हें कॉन्फ़िगर करने के बारे में ज़्यादा जानें.

एग्रीगेट की जा सकने वाली रिपोर्ट स्वीकार करना

इस एंडपॉइंट पर यूआरआई का इस्तेमाल किया जाना चाहिए. यूआरआई को रजिस्टर करने के बारे में ज़्यादा जानकारी के लिए, Privacy Sandbox खाते के लिए रजिस्टर करना देखें. (यूआरआई, सोर्स रजिस्ट्रेशन और ट्रिगर रजिस्ट्रेशन स्वीकार करने के लिए इस्तेमाल किए जाने वाले सर्वर के ऑरिजिन से लिया जाता है.) सोर्स रजिस्ट्रेशन स्वीकार करने और ट्रिगर रजिस्ट्रेशन स्वीकार करने वाले एंडपॉइंट के लिए, उदाहरण वाले यूआरआई का इस्तेमाल करके, इस एंडपॉइंट का यूआरआई है:

https://adtech.example/.well-known/attribution-reporting/report-aggregate-attribution

एन्क्रिप्ट (सुरक्षित) किए गए और एन्क्रिप्ट (सुरक्षित) नहीं किए गए, दोनों फ़ील्ड में इकट्ठा की जा सकने वाली रिपोर्ट में जानकारी अपने-आप भर जाती है. एन्क्रिप्ट (सुरक्षित) की गई रिपोर्ट की मदद से, एग्रीगेशन सेवा की मदद से टेस्टिंग शुरू की जा सकती है. वहीं, एन्क्रिप्ट (सुरक्षित) नहीं किए गए फ़ील्ड से उस तरीके के बारे में अहम जानकारी मिलती है जिससे सेट की-वैल्यू पेयर, डेटा को तैयार करते हैं.

इस सर्वर को इस फ़ॉर्मैट का इस्तेमाल करने वाले JSON अनुरोधों को स्वीकार करने के लिए कॉन्फ़िगर करें:

{
  // Info that the aggregation services also need encoded in JSON
  // for use with AEAD. Line breaks added for readability.
  "shared_info": "{
     \"api\":\"attribution-reporting\",
     \"attribution_destination\": \"android-app://com.advertiser.example.advertiser\",
     \"scheduled_report_time\":\"[timestamp in seconds]\",
     \"source_registration_time\": \"[timestamp in seconds]\",
     \"version\":\"[api version]\",
     \"report_id\":\"[UUID]\",
     \"reporting_origin\":\"https://reporter.example\" }",

  // In the current Developer Preview release, The "payload" and "key_id" fields
  // are not used because the platform does not yet encrypt aggregate reports.
  // Currently, the "debug_cleartext_payload" field holds unencrypted reports.
  "aggregation_service_payloads": [
    {
      "payload": "[base64 HPKE encrypted data readable only by the aggregation service]",
      "key_id": "[string identifying public key used to encrypt payload]",

      "debug_cleartext_payload": "[unencrypted payload]"
    },
  ],

  "source_debug_key": "[64 bit unsigned integer]",
  "trigger_debug_key": "[64 bit unsigned integer]"
}

डीबग कुंजियों की मदद से, अपनी एट्रिब्यूशन रिपोर्ट में ज़्यादा अहम जानकारी पाई जा सकती है. इन्हें कॉन्फ़िगर करने के बारे में ज़्यादा जानें.

Android क्लाइंट सेट अप करें

क्लाइंट ऐप्लिकेशन, एट्रिब्यूशन सोर्स और ट्रिगर को रजिस्टर करता है. साथ ही, इवेंट-लेवल और एग्रीगेट की जा सकने वाली रिपोर्ट जनरेट करने की सुविधा चालू करता है. Attribution Reporting API का इस्तेमाल करने के लिए, Android क्लाइंट डिवाइस या एम्युलेटर तैयार करने के लिए, ये काम करें:

  1. Android पर प्राइवसी सैंडबॉक्स के लिए, डेवलपमेंट एनवायरमेंट सेट अप करें.
  2. ऐसे डिवाइस पर सिस्टम इमेज इंस्टॉल करें जिस पर प्राइवसी सैंडबॉक्स की सुविधा काम करती हो या एक एम्युलेटर सेट अप करें, जिसमें Android पर प्राइवसी सैंडबॉक्स की सुविधा मौजूद हो.
  3. नीचे दिए गए ADB कमांड को चलाकर, Attribution Reporting API का ऐक्सेस चालू करें. एपीआई डिफ़ॉल्ट रूप से बंद रहता है.

    adb shell device_config put adservices ppapi_app_allow_list \"\*\"
    
  4. अगर स्थानीय तौर पर Attribution Reporting API को टेस्ट किया जा रहा है (जैसे कि उस डिवाइस पर टेस्ट करना जिसका ऐक्सेस आपके पास है), तो रजिस्ट्रेशन को बंद करने के लिए यह कमांड चलाएं:

    adb shell device_config put adservices disable_measurement_enrollment_check "true"
    
  5. अपनी Android मेनिफ़ेस्ट फ़ाइल में ACCESS_ADSERVICES_ATTRIBUTION की अनुमति शामिल करें. साथ ही, एट्रिब्यूशन रिपोर्टिंग एपीआई का इस्तेमाल करने के लिए, अपने ऐप्लिकेशन के लिए विज्ञापन सेवाओं का एक कॉन्फ़िगरेशन बनाएं:

    <uses-permission android:name="android.permission.ACCESS_ADSERVICES_ATTRIBUTION" />
    
  6. (ज़रूरी नहीं) अगर आपको डीबग रिपोर्ट चाहिए, तो अपनी Android मेनिफ़ेस्ट फ़ाइल में ACCESS_ADSERVICES_AD_ID की अनुमति शामिल करें:

    <uses-permission android:name="android.permission.ACCESS_ADSERVICES_AD_ID" />
    
  7. अपने मेनिफ़ेस्ट के <application> एलिमेंट में विज्ञापन सेवाओं से जुड़े कॉन्फ़िगरेशन का रेफ़रंस दें:

    <property android:name="android.adservices.AD_SERVICES_CONFIG"
              android:resource="@xml/ad_services_config" />
    
  8. मेनिफ़ेस्ट में बताए गए विज्ञापन सेवाओं के एक्सएमएल रिसॉर्स के बारे में बताएं, जैसे कि res/xml/ad_services_config.xml. विज्ञापन सेवाओं की अनुमतियों और SDK टूल के ऐक्सेस कंट्रोल के बारे में ज़्यादा जानें.

    <ad-services-config>
        <attribution allowAllToAccess="true" />
    </ad-services-config>
    

विज्ञापन इवेंट रजिस्टर करें

आपके ऐप्लिकेशन में सोर्स और कन्वर्ज़न होने पर, उन्हें रजिस्टर करना चाहिए, ताकि यह पक्का किया जा सके कि उन्हें सही तरीके से रिपोर्ट किया जा रहा हो. MeasurementManager क्लास में ऐसे तरीके मौजूद हैं जो एट्रिब्यूशन सोर्स इवेंट और कन्वर्ज़न ट्रिगर को रजिस्टर करने में आपकी मदद करते हैं.

एट्रिब्यूशन सोर्स इवेंट रजिस्टर करना

जब किसी विज्ञापन को देखा या क्लिक किया जाता है, तो पब्लिशर ऐप्लिकेशन registerSource() को कॉल करके, एट्रिब्यूशन सोर्स को रजिस्टर करता है. इसका तरीका कोड स्निपेट में दिखाया गया है.

Attribution Reporting API, इस तरह के एट्रिब्यूशन सोर्स इवेंट के साथ काम करता है:

  • क्लिक, जिन्हें आम तौर पर onClick() से मिलते-जुलते कॉलबैक वाले तरीके में रजिस्टर किया जाता है. आम तौर पर, ट्रिगर इवेंट, क्लिक इवेंट के तुरंत बाद होता है. इस प्रकार का इवेंट उपयोगकर्ता इंटरैक्शन के बारे में ज़्यादा जानकारी देता है और इसलिए उच्च प्राथमिकता देने के लिए यह एक अच्छा एट्रिब्यूशन स्रोत है.
  • व्यू, जिन्हें आम तौर पर onAdShown() से मिलते-जुलते कॉलबैक तरीके में रजिस्टर किया जाता है. संबंधित ट्रिगर इवेंट, व्यू इवेंट के घंटों या कई दिनों बाद हो सकता है.

Kotlin

companion object {
    private val CALLBACK_EXECUTOR = Executors.newCachedThreadPool()
}

val measurementManager = context.getSystemService(MeasurementManager::class.java)
var exampleClickEvent: InputEvent? = null

// Use the URI of the server-side endpoint that accepts attribution source
// registration.
val attributionSourceUri: Uri =
  Uri.parse("https://adtech.example/attribution_source?AD_TECH_PROVIDED_METADATA")

val future = CompletableFuture<Void>()

adView.setOnTouchListener(_: View?, event: MotionEvent?)) ->
    exampleClickEvent = event
    true
}

// Register Click Event
measurementManager.registerSource(
        attributionSourceUri,
        exampleClickEvent,
        CALLBACK_EXECUTOR,
        future::complete)

// Register View Event
measurementManager.registerSource(
        attributionSourceUri,
        null,
        CALLBACK_EXECUTOR,
        future::complete)

Java

private static final Executor CALLBACK_EXECUTOR = Executors.newCachedThreadPool();
private InputEvent exampleClickEvent;

MeasurementManager measurementManager =
        context.getSystemService(MeasurementManager.class);

// Use the URI of the server-side endpoint that accepts attribution source
// registration.
Uri attributionSourceUri =
Uri.parse("https://adtech.example/attribution_source?AD_TECH_PROVIDED_METADATA");

CompletableFuture<Void> future = new CompletableFuture<>();

adView.setOnTouchListener(v, event)) -> {
    exampleClickEvent = event;
    return true;
}

// Register Click Event
measurementManager.registerSource(attributionSourceUri, exampleClickEvent,
        CALLBACK_EXECUTOR, future::complete);

// Register View Event
measurementManager.registerSource(attributionSourceUri, null,
        CALLBACK_EXECUTOR, future::complete);

रजिस्ट्रेशन के बाद, एपीआई attributionSourceUri के बताए गए पते पर सेवा एंडपॉइंट पर एक एचटीटीपी पोस्ट अनुरोध जारी करता है. एंडपॉइंट के जवाब में destination, source_event_id, expiry और source_priority के लिए वैल्यू शामिल होती हैं.

अगर मूल विज्ञापन टेक्नोलॉजी को सोर्स रजिस्ट्रेशन शेयर करना है, तो ओरिजनल एट्रिब्यूशन सोर्स यूआरआई में दूसरे विज्ञापन टेक्नोलॉजी एंडपॉइंट पर रीडायरेक्ट शामिल किए जा सकते हैं. रीडायरेक्ट पर लागू होने वाली सीमाओं और नियमों के बारे में तकनीकी प्रस्ताव में बताया गया है.

registerSource और registerTrigger के लिए, डेज़ी-चेन रीडायरेक्ट के लिए सहायता जोड़ी गई है. रजिस्ट्रेशन हेडर के अलावा, एपीआई उपभोक्ता अब सर्वर रिस्पॉन्स के तौर पर, एचटीटीपी रीडायरेक्ट उपलब्ध करा सकता है. इसमें 302 स्टेटस कोड और "जगह की जानकारी" हेडर, अगले यूआरएल के साथ शामिल होता है, ताकि आप अलग से रजिस्ट्रेशन कर सकें.

डेज़ी चेन में सिर्फ़ पहली विज़िट में दिए गए "डेस्टिनेशन" फ़ील्ड का इस्तेमाल किया जाता है. विज़िट की संख्या वही है जो "एट्रिब्यूशन-रिपोर्टिंग-रीडायरेक्ट" हेडर को असाइन की जाती है. यह रीडायरेक्ट सहायता, मौजूदा "एट्रिब्यूशन-रिपोर्टिंग-रीडायरेक्ट" सहायता से अलग है. अगर दोनों सहायता मौजूद है, तो "एट्रिब्यूशन-रिपोर्टिंग-रीडायरेक्ट" सुविधा को प्राथमिकता दी जाएगी.

कन्वर्ज़न ट्रिगर इवेंट को रजिस्टर करना

कोई कन्वर्ज़न ट्रिगर इवेंट रजिस्टर करने के लिए, अपने ऐप्लिकेशन में registerTrigger() को कॉल करें:

Kotlin

companion object {
    private val CALLBACK_EXECUTOR = Executors.newCachedThreadPool()
}

val measurementManager = context.getSystemService(MeasurementManager::class.java)

// Use the URI of the server-side endpoint that accepts trigger registration.
val attributionTriggerUri: Uri =
    Uri.parse("https://adtech.example/trigger?AD_TECH_PROVIDED_METADATA")

val future = CompletableFuture<Void>()

// Register trigger (conversion)
measurementManager.registerTrigger(
        attributionTriggerUri,
        CALLBACK_EXECUTOR,
        future::complete)

Java

private static final Executor CALLBACK_EXECUTOR = Executors.newCachedThreadPool();

MeasurementManager measurementManager =
        context.getSystemService(MeasurementManager.class);

// Use the URI of the server-side endpoint that accepts trigger registration.
Uri attributionTriggerUri =
        Uri.parse("https://adtech.example/trigger?AD_TECH_PROVIDED_METADATA");

CompletableFuture<Void> future = new CompletableFuture<>();

// Register trigger (conversion)
measurementManager.registerTrigger(
        attributionTriggerUri,
        CALLBACK_EXECUTOR,
        future::complete)

रजिस्ट्रेशन के बाद, एपीआई attributionTriggerUri के बताए गए पते पर सेवा एंडपॉइंट पर एक एचटीटीपी पोस्ट अनुरोध जारी करता है. endpoint के रिस्पॉन्स में इवेंट और एग्रीगेट रिपोर्ट की वैल्यू शामिल होती हैं.

अगर मूल विज्ञापन टेक्नोलॉजी प्लैटफ़ॉर्म, ट्रिगर के रजिस्ट्रेशन को शेयर करने की अनुमति देता है, तो यूआरआई में दूसरे विज्ञापन टेक्नोलॉजी प्लैटफ़ॉर्म से जुड़े यूआरआई के रीडायरेक्ट शामिल किए जा सकते हैं. रीडायरेक्ट पर लागू होने वाली सीमाओं और नियमों के बारे में तकनीकी प्रस्ताव में बताया गया है.

क्रॉस ऐप्लिकेशन और वेब मेज़रमेंट को रजिस्टर करें

ऐसे मामले में, जहां उपयोगकर्ता के सोर्स से ट्रिगर होने तक की प्रोसेस में ऐप्लिकेशन और ब्राउज़र, दोनों की कोई भूमिका होती है, वहां विज्ञापन इवेंट को रजिस्टर करने के तरीके में मामूली अंतर होता है. अगर कोई उपयोगकर्ता किसी ऐप्लिकेशन पर कोई विज्ञापन देखता है और उसे कन्वर्ज़न के लिए ब्राउज़र पर रीडायरेक्ट किया जाता है, तो सोर्स को ऐप्लिकेशन और वेब ब्राउज़र से कन्वर्ज़न के तौर पर रजिस्टर किया जाता है. इसी तरह, अगर कोई उपयोगकर्ता वेब ब्राउज़र पर काम शुरू करता है और उसे कन्वर्ज़न के लिए किसी ऐप्लिकेशन पर भेजा जाता है, तो ब्राउज़र सोर्स को रजिस्टर करता है और ऐप्लिकेशन कन्वर्ज़न रजिस्टर करता है.

वेब और Android, दोनों पर विज्ञापन टेक्नोलॉजी को व्यवस्थित करने के तरीके में कई अंतर हैं. इसलिए, हमने सोर्स और ट्रिगर को रजिस्टर करने के लिए नए एपीआई जोड़े हैं. ये एपीआई, ब्राउज़र पर इस्तेमाल होने पर ही लागू होते हैं. इन एपीआई और इनसे जुड़े ऐप्लिकेशन पर आधारित एपीआई के बीच मुख्य अंतर यह है कि हम उम्मीद करते हैं कि ब्राउज़र रीडायरेक्ट का पालन करे, ब्राउज़र के हिसाब से फ़िल्टर लागू करे, और registerWebSource() या registerWebTrigger() को कॉल करके प्लैटफ़ॉर्म पर मान्य रजिस्ट्रेशन भेजे.

नीचे दिया गया कोड स्निपेट, एपीआई कॉल का एक उदाहरण दिखाता है. ब्राउज़र, उपयोगकर्ता को किसी ऐप्लिकेशन पर भेजने से पहले, एट्रिब्यूशन सोर्स को रजिस्टर करता है:

Kotlin

companion object {
    private val CALLBACK_EXECUTOR = Executors.newCachedThreadPool()
}

val measurementManager =
        context.getSystemService(MeasurementManager::class.java)
var exampleClickEvent: InputEvent? = null

// Use the URIs of the server-side endpoints that accept attribution source
// registration.
val sourceParam1 = WebSourceParams.Builder(Uri.parse(
        "https://adtech1.example/attribution_source?AD_TECH_PROVIDED_METADATA"))
// True, if debugging is allowed for the ad tech.
    .setDebugKeyAllowed(true)
    .build()

val sourceParam2 = WebSourceParams.Builder(Uri.parse(
        "https://adtech2.example/attribution_source?AD_TECH_PROVIDED_METADATA"))
    .setDebugKeyAllowed(false)
    .build()

val sourceParam3 = WebSourceParams.Builder(Uri.parse(
        "https://adtech3.example/attribution_source?AD_TECH_PROVIDED_METADATA"))
    .build()

val sourceParams = Arrays.asList(sourceParam1, sourceParam2, sourceParam3)
val publisherOrigin = Uri.parse("https://publisher.example")
val appDestination = Uri.parse("android-app://com.example.store")
val webDestination = Uri.parse("https://example.com")

val future = CompletableFuture<Void>()

adView.setOnTouchListener {_: View?, event: MotionEvent? ->
    exampleClickEvent = event
    true
}
val clickRegistrationRequest = WebSourceRegistrationRequest.Builder(
          sourceParams,
          publisherOrigin)
      .setAppDestination(appDestination)
      .setWebDestination(webDestination)
      .setInputEvent(event)
      .build()
val viewRegistrationRequest = WebSourceRegistrationRequest.Builder(
          sourceParams,
          publisherOrigin)
      .setAppDestination(appDestination)
      .setWebDestination(webDestination)
      .setInputEvent(null)
      .build()

// Register a web source for a click event.
measurementManager.registerWebSource(
        clickRegistrationRequest,
        CALLBACK_EXECUTOR,
        future::complete)

// Register a web source for a view event.
measurementManager.registerWebSource(
        viewRegistrationRequest,
        CALLBACK_EXECUTOR,
        future::complete)

Java

private static final Executor CALLBACK_EXECUTOR =
        Executors.newCachedThreadPool();
private InputEvent exampleClickEvent;

MeasurementManager measurementManager =
        context.getSystemService(MeasurementManager.class);

// Use the URIs of the server-side endpoints that accept attribution source
// registration.
WebSourceParams sourceParam1 = WebSourceParams.Builder(Uri.parse(
        "https://adtech1.example/attribution_source?AD_TECH_PROVIDED_METADATA"))
    // True, if debugging is allowed for the ad tech.
    .setDebugKeyAllowed(true)
    .build();

WebSourceParams sourceParam2 = WebSourceParams.Builder(Uri.parse(
        "https://adtech2.example/attribution_source?AD_TECH_PROVIDED_METADATA"))
    .setDebugKeyAllowed(false)
    .build();

WebSourceParams sourceParam3 = WebSourceParams.Builder(Uri.parse(
        "https://adtech3.example/attribution_source?AD_TECH_PROVIDED_METADATA"))
    .build();

List<WebSourceParams> sourceParams =
        Arrays.asList(sourceParam1, sourceParam2, sourceParam3);
Uri publisherOrigin = Uri.parse("https://publisher.example");
Uri appDestination = Uri.parse("android-app://com.example.store");
Uri webDestination = Uri.parse("https://example.com");

CompletableFuture<Void> future = new CompletableFuture<>();

adView.setOnTouchListener(v, event) -> {
    exampleClickEvent = event;
    return true;
}

WebSourceRegistrationRequest clickRegistrationRequest =
        new WebSourceRegistrationRequest.Builder(sourceParams, publisherOrigin)
    .setAppDestination(appDestination)
    .setWebDestination(webDestination)
    .setInputEvent(event)
    .build();
WebSourceRegistrationRequest viewRegistrationRequest =
        new WebSourceRegistrationRequest.Builder(sourceParams, publisherOrigin)
    .setAppDestination(appDestination)
    .setWebDestination(webDestination)
    .setInputEvent(null)
    .build();

// Register a web source for a click event.
measurementManager.registerWebSource(clickRegistrationRequest,
        CALLBACK_EXECUTOR, future::complete);

// Register a web source for a view event.
measurementManager.registerWebSource(viewRegistrationRequest,
        CALLBACK_EXECUTOR, future::complete);

नीचे दिया गया कोड स्निपेट, एपीआई कॉल का एक उदाहरण दिखाता है. इसे ब्राउज़र, उपयोगकर्ता को ऐप्लिकेशन से भेजे जाने के बाद कन्वर्ज़न रजिस्टर करने के लिए बनाता है:

Kotlin

companion object {
    private val CALLBACK_EXECUTOR = Executors.newCachedThreadPool()
}

val measurementManager = context.getSystemService(MeasurementManager::class.java)

// Use the URIs of the server-side endpoints that accept trigger registration.
val triggerParam1 = WebTriggerParams.Builder(Uri.parse(
        "https://adtech1.example/trigger?AD_TECH_PROVIDED_METADATA"))
    // True, if debugging is allowed for the ad tech.
    .setDebugKeyAllowed(true)
    .build()

val triggerParam2 = WebTriggerParams.Builder(Uri.parse(
        "https://adtech2.example/trigger?AD_TECH_PROVIDED_METADATA"))
    .setDebugKeyAllowed(false)
    .build()

val triggerParams = Arrays.asList(triggerParam1, triggerParam2)
val advertiserOrigin = Uri.parse("https://advertiser.example")

val future = CompletableFuture<Void>()

val triggerRegistrationRequest = WebTriggerRegistrationRequest.Builder(
        triggerParams,
        advertiserOrigin)
    .build()

// Register the web trigger (conversion).
measurementManager.registerWebTrigger(
    triggerRegistrationRequest,
    CALLBACK_EXECUTOR,
    future::complete)

Java

private static final Executor CALLBACK_EXECUTOR =
        Executors.newCachedThreadPool();

MeasurementManager measurementManager =
        context.getSystemService(MeasurementManager.class);

// Use the URIs of the server-side endpoints that accept trigger registration.
WebTriggerParams triggerParam1 = WebTriggerParams.Builder(Uri.parse(
        "https://adtech1.example/trigger?AD_TECH_PROVIDED_METADATA"))
    // True, if debugging is allowed for the ad tech.
    .setDebugKeyAllowed(true)
    .build();

WebTriggerParams triggerParam2 = WebTriggerParams.Builder(Uri.parse(
        "https://adtech2.example/trigger?AD_TECH_PROVIDED_METADATA"))
    .setDebugKeyAllowed(false)
    .build();

List<WebTriggerParams> triggerParams =
        Arrays.asList(triggerParam1, triggerParam2);
Uri advertiserOrigin = Uri.parse("https://advertiser.example");

CompletableFuture<Void> future = new CompletableFuture<>();

WebTriggerRegistrationRequest triggerRegistrationRequest =
        new WebTriggerRegistrationRequest.Builder(
            triggerParams, advertiserOrigin)
    .build();

// Register the web trigger (conversion).
measurementManager.registerWebTrigger( triggerRegistrationRequest,
        CALLBACK_EXECUTOR, future::complete);

निजता की सुरक्षा के लिए ग़ैर-ज़रूरी आवाज़ें जोड़ना

इवेंट-लेवल की रिपोर्ट में डेस्टिनेशन, एट्रिब्यूशन सोर्स आईडी, और ट्रिगर का डेटा शामिल होता है. इन्हें रिपोर्टिंग ऑरिजिन पर, ओरिजनल (एन्क्रिप्ट नहीं किया गया) फ़ॉर्मैट में भेजा जाता है. उपयोगकर्ता की निजता की सुरक्षा के लिए, ग़ैर-ज़रूरी आवाज़ों को शामिल किया गया है, ताकि किसी उपयोगकर्ता को पहचानना मुश्किल हो. ग़ैर-ज़रूरी इवेंट-लेवल की रिपोर्ट, डिफ़रेंशियल-प्राइवसी फ़्रेमवर्क के मुताबिक जनरेट और भेजी जाती हैं. अलग-अलग स्थितियों में, गै़र-ज़रूरी डेटा के प्रतिशत की डिफ़ॉल्ट वैल्यू यहां दी गई हैं:

सोर्स टाइप

सोर्स डेस्टिनेशन की वैल्यू

हर सोर्स रजिस्ट्रेशन के हिसाब से, ग़ैर-ज़रूरी रिपोर्ट की संभावना

देखें

ऐप्लिकेशन या वेब

0.0000025

देखें

ऐप्लिकेशन और वेब

0.0000042

क्लिक करें

ऐप्लिकेशन या वेब

0.0024263

क्लिक करें

ऐप्लिकेशन और वेब

0.0170218

ऐप्लिकेशन-टू-वेब एट्रिब्यूशन मेज़रमेंट में, सोर्स, ऐप्लिकेशन और वेब, दोनों डेस्टिनेशन पर कन्वर्ज़न बढ़ा सकते हैं. वहीं, इवेंट-लेवल की रिपोर्ट से यह पता चल सकता है कि ट्रिगर, ऐप्लिकेशन पर हुआ या वेब पर. इस अतिरिक्त जानकारी की भरपाई करने के लिए, जनरेट की गई नॉइज़ रिपोर्ट, क्लिक के लिए ~7 गुना और व्यू के लिए ~1.7 गुना होती है.

कुछ विज्ञापन तकनीकों को यह बताने के लिए इवेंट-लेवल रिपोर्ट की ज़रूरत नहीं होती कि ट्रिगर ऐप्लिकेशन या वेब डेस्टिनेशन पर हुआ या नहीं. विज्ञापन टेक्नोलॉजी, शोर को कम करने के लिए, Attribution-Reporting-Register-Source हेडर में मौजूद coarse_event_report_destinations फ़ील्ड का इस्तेमाल कर सकती हैं. अगर coarse_event_report_destinations फ़ील्ड के लिए तय किए गए एट्रिब्यूशन वाला सोर्स, एट्रिब्यूशन को जीतता है, तो तैयार होने वाली रिपोर्ट में ऐप्लिकेशन और वेब डेस्टिनेशन, दोनों शामिल होते हैं. हालांकि, उन्हें यह नहीं बताया जाता कि असल ट्रिगर कहां हुआ था.

यहां दिए गए उदाहरणों में, कोई उपयोगकर्ता किसी विज्ञापन पर क्लिक करता है और वह सोर्स, एपीआई के साथ रजिस्टर होता है. इसके बाद, उपयोगकर्ता, विज्ञापन देने वाले के ऐप्लिकेशन और विज्ञापन देने वाले की वेबसाइट, दोनों पर ग्राहक में बदल जाता है. ये दोनों कन्वर्ज़न ट्रिगर के तौर पर रजिस्टर किए जाते हैं और इन्हें शुरुआती क्लिक के लिए एट्रिब्यूट किया जाता है.

क्लिक-आधारित सोर्स रजिस्ट्रेशन एचटीटीपी हेडर:

Attribution-Reporting-Register-Source: {
    "destination": "android-app://com.advertiser.example",
    "web_destination": "https://advertiser.com",
    "source_event_id": "234",
    "expiry": "60000",
    "priority": "5",
    // Ad tech opts out of receiving app-web destination distinction
    // in event report, avoids additional noise
    "coarse_event_report_destinations": "true"
}

ऐप्लिकेशन से पैकेज नाम के साथ एक ट्रिगर रजिस्टर किया जाता है com.advertiser.example:

Attribution-Reporting-Register-Trigger: {
    "event_trigger_data": [{
    "trigger_data": "1",
    "priority": "1"
    }],
}

ट्रिगर को eTLD+1 डोमेन वाली वेबसाइट के ब्राउज़र से रजिस्टर किया जाता है https://advertiser.com:

Attribution-Reporting-Register-Trigger: {
    "event_trigger_data": [{
    "trigger_data": "2",
    "priority": "2"
    }],
}

इसके बाद, इवेंट-लेवल की रिपोर्ट जनरेट होती हैं. अगर दोनों ट्रिगर को सोर्स में एट्रिब्यूट किया जाता है, तो इवेंट-लेवल की ये रिपोर्ट जनरेट होती हैं:

  {
    "attribution_destination": ["android-app://com.advertiser.example,https://advertiser.com"],
    "scheduled_report_time": "800176400",
    "source_event_id": "53234",
    "trigger_data": "1",
    // Can be "event" if source were registered by user viewing the ad
    "source_type": "navigation",
    // Would be 0.0170218 without coarse_event_report_destinations as true in the source
    "randomized_trigger_rate": 0.0024263
  }

रिपोर्ट जनरेट और डिलीवर करना

Attribution Reporting API, आपके सर्वर पर मौजूद उन एंडपॉइंट को रिपोर्ट भेजता है जो इवेंट-लेवल की रिपोर्ट और एग्रीगेट की जा सकने वाली रिपोर्ट स्वीकार करते हैं.

जॉब की रिपोर्टिंग के लिए हर हाल में कार्रवाई करें

एट्रिब्यूशन सोर्स इवेंट को रजिस्टर करने या किसी ट्रिगर इवेंट को रजिस्टर करने के बाद, सिस्टम रिपोर्टिंग के जॉब को शेड्यूल करता है. डिफ़ॉल्ट रूप से, यह काम हर चार घंटे में होता है. जांच करने के लिए, रिपोर्टिंग जॉब को ज़बरदस्ती चलाया जा सकता है या दोनों के बीच के इंटरवल कम किए जा सकते हैं.

एट्रिब्यूशन जॉब को हर हाल में चलाएं:

adb shell cmd jobscheduler run -f com.google.android.adservices.api 5

इवेंट-लेवल रिपोर्टिंग जॉब को हर हाल में चलाएं:

adb shell cmd jobscheduler run -f com.google.android.adservices.api 3

एग्रीगेटेड रिपोर्टिंग जॉब को हर हाल में चलाएं:

adb shell cmd jobscheduler run -f com.google.android.adservices.api 7

जॉब कब चला, यह जानने के लिए Logcat में आउटपुट देखें. यह कुछ ऐसा दिखेगा:

JobScheduler: executeRunCommand(): com.google.android.adservices.api/0 5 s=false f=true

रिपोर्ट की डिलीवरी हर हाल में करें

रिपोर्टिंग जॉब को ज़बरदस्ती चलने के बाद भी, सिस्टम डिलीवरी में लगने वाले समय से जुड़े अपने शेड्यूल के हिसाब से रिपोर्ट भेजता है. इसमें कुछ घंटे से लेकर कई दिन तक लग सकते हैं. टेस्टिंग के लिए, रिपोर्ट की डिलीवरी शुरू करने के लिए, डिवाइस के सिस्टम का समय, शेड्यूल की गई देरी के बाद रखा जा सकता है.

अपने सर्वर पर रिपोर्ट की पुष्टि करना

रिपोर्ट भेजे जाने के बाद, मिलने वाली रिपोर्ट, लागू होने वाले सर्वर लॉग जैसे कि सर्वर का इतिहास या अपने कस्टम सिस्टम की जांच करके, डिलीवरी की पुष्टि करें.

अपनी एग्रीगेट रिपोर्ट को डिकोड करना

एग्रीगेट की गई रिपोर्ट पाते समय, debug_cleartext_payload फ़ील्ड में आपकी कुल रिपोर्ट का एन्क्रिप्ट (सुरक्षित) नहीं किया गया वर्शन होता है. हालांकि, आपकी रिपोर्ट के इस वर्शन को एन्क्रिप्ट नहीं किया गया है, फिर भी इसे डिकोड करने की ज़रूरत है.

यहां debug_cleartext_payload फ़ील्ड के कॉन्टेंट को दो चरणों में डिकोड करने का उदाहरण दिया गया है: पहला बेस 64 डीकोडिंग का इस्तेमाल करके और दूसरे में सीबीओआर डिकोडिंग का इस्तेमाल करके.

String base64DebugPayload  = "omRkYXRhgqJldmFsdWVEAAAGgGZidWNrZXRQAAAAAAAAAAAAAAAAAAAKhaJldmFsdWVEAACAAGZidWNrZXRQAAAAAAAAAAAAAAAAAAAFWWlvcGVyYXRpb25paGlzdG9ncmFt";
byte[] cborEncoded = Base64.getDecoder().decode(base64DebugPayload);

// CbodDecoder comes from this library https://github.com/c-rack/cbor-java
final List<DataItem> dataItems = new CborDecoder(new ByteArrayInputStream(cborEncoded)).decode();

// In here you can see the contents, but the value will be something like:
// Data items: [{ data: [{ value: co.nstant.in.cbor.model.ByteString@a8b5c07a,
//   bucket: co.nstant.in.cbor.model.ByteString@f812097d },
//   { value: co.nstant.in.cbor.model.ByteString@a8b5dfc0,
//   bucket: co.nstant.in.cbor.model.ByteString@f8120934 }], operation: histogram }]
Log.d("Data items : " + dataItems);

// In order to see the value for bucket and value, you can traverse the data
// and get their values, something like this:
final Map payload = (Map) dataItems.get(0);
final Array payloadArray = (Array) payload.get(new UnicodeString("data"));

payloadArray.getDataItems().forEach(i -> {
    BigInteger value = new BigInteger(((ByteString) ((Map)i).get(new UnicodeString("value"))).getBytes());
    BigInteger bucket = new BigInteger(((ByteString) ((Map)i).get(new UnicodeString("bucket"))).getBytes());
    Log.d("value : " + value + " ;bucket : " + bucket);
});

टेस्ट करना

Attribution Reporting API का इस्तेमाल शुरू करने में मदद पाने के लिए, GitHub पर MeasurementSampleApp प्रोजेक्ट का इस्तेमाल किया जा सकता है. इस सैंपल ऐप्लिकेशन में, एट्रिब्यूशन सोर्स के रजिस्ट्रेशन और ट्रिगर के रजिस्ट्रेशन की जानकारी दी गई है.

सर्वर एंडपॉइंट के लिए, इन रेफ़रंस रिसॉर्स या अपने कस्टम सलूशन पर विचार करें:

  • MeasurementAdTechServerSpec में OpenAPI सेवा की परिभाषाएं शामिल होती हैं. इन्हें, इस सुविधा के साथ काम करने वाले मॉक या माइक्रोसर्विस प्लैटफ़ॉर्म पर डिप्लॉय किया जा सकता है.
  • MeasurementAdTechServer में, Google App Engine के लिए Spring बूट ऐप्लिकेशन पर आधारित एक मॉक सर्वर को लागू करने का रेफ़रंस दिया जाता है.

ज़रूरी शर्तें

अपने टेस्ट डिवाइस या एम्युलेटर से ऐक्सेस किए जा सकने वाले रिमोट एंडपॉइंट पर, मॉक एपीआई डिप्लॉय करें. आसानी के लिए, टेस्ट करने के लिए, MeasurementAdTechServerSpec और MeasurementAdTechServer सैंपल प्रोजेक्ट देखें.

जांच करने के लिए सुविधाएं

आने वाली सुविधाएं

इवेंट लेवल पर सुविधाजनक कॉन्फ़िगरेशन

यूटिलिटी टेस्टिंग शुरू करने के लिए, इवेंट लेवल की रिपोर्टिंग के डिफ़ॉल्ट कॉन्फ़िगरेशन का इस्तेमाल करने की सलाह दी जाती है. हालांकि, हो सकता है कि यह हर तरह के इस्तेमाल के लिए सही न हो. Attribution Reporting API के साथ वैकल्पिक और ज़्यादा सुविधाजनक कॉन्फ़िगरेशन का इस्तेमाल किया जा सकेगा. इससे विज्ञापन टेक्नोलॉजी को अपने इवेंट लेवल की रिपोर्ट के स्ट्रक्चर पर ज़्यादा कंट्रोल मिलेगा. साथ ही, वे डेटा का ज़्यादा से ज़्यादा फ़ायदा पा सकेंगे. यह सुविधा, Attribution Reporting API में दो चरणों में उपलब्ध होगी:

  • पहला चरण: लाइट फ़ॉर्मैट में, सुविधाजनक इवेंट लेवल का कॉन्फ़िगरेशन; दूसरे चरण का सबसेट.
  • दूसरा चरण: सुविधाजनक इवेंट लेवल के कॉन्फ़िगरेशन का फ़ुल वर्शन.

पहला चरण: सुविधाजनक इवेंट लेवल

हम Attribution-Reporting-Register-Source में, JSON में ये दो वैकल्पिक पैरामीटर जोड़ेंगे:

  • max_event_level_reports
  • event_report_windows
{
  ...
  // Optional. This is a parameter that acts across all trigger types for the
  // lifetime of this source. It restricts the total number of event-level
  // reports that this source can generate. After this maximum is hit, the
  // source is no longer capable of producing any new data. The use of
  // priority in the trigger attribution algorithm in the case of multiple
  // attributable triggers remains unchanged. Defaults to 3 for navigation
  // sources and 1 for event sources
  "max_event_level_reports": <int>,

  // Optional. Represents a series of time windows, starting at 0. Reports
  // for this source will be delivered an hour after the end of each window.
  // Time is encoded as seconds after source registration. If
  // event_report_windows is omitted, will use the default windows. This
  // field is mutually exclusive with the existing `event_report_window` field.
  // // End time is exclusive.
  "event_report_windows": {
    "start_time": <int>,
    "end_times": [<int>, ...]
  }
}

कस्टम कॉन्फ़िगरेशन का उदाहरण

यह उदाहरण कॉन्फ़िगरेशन उस डेवलपर का इस्तेमाल करता है जो पहले वाली रिपोर्टिंग विंडो में रिपोर्ट पाने के लिए ऑप्टिमाइज़ करना चाहता है.

{
  ...
  "max_event_level_reports": 2,
  "event_report_windows": {
    "end_times": [7200, 43200, 86400] // 2 hours, 12 hours, 1 day in seconds
  }
}

दूसरा चरण: सभी सुविधाजनक इवेंट लेवल

पहले चरण में जोड़े गए पैरामीटर के अलावा, हम Attribution-Reporting-Register-Source के JSON में एक अतिरिक्त वैकल्पिक पैरामीटर trigger_specs जोड़ेंगे.

{
  // A trigger spec is a set of matching criteria, along with a scheme to
  // generate bucketized output based on accumulated values across multiple
  // triggers within the specified event_report_window. There will be a limit on
  // the number of specs possible to define for a source.
  "trigger_specs": [{
    // This spec will only apply to registrations that set one of the given
    // trigger data values (non-negative integers) in the list.
    // trigger_data will still appear in the event-level report.
    "trigger_data": [<int>, ...]

    // Represents a series of time windows, starting at the source registration
    // time. Reports for this spec will be delivered an hour after the end of
    // each window. Time is encoded as seconds after source registration.
    // end_times must consist of strictly increasing positive integers.
    //
    // Note: specs with identical trigger_data cannot have overlapping windows;
    // this ensures that triggers match at most one spec. If
    // event_report_windows is omitted, will use the "event_report_window" or
    // "event_report_windows" field specified at the global level for the source
    // (or the default windows if none are specified). End time is exclusive.
    "event_report_windows": {
      "start_time": <int>,
      "end_times": [<int>, ...],
    }

    // Represents an operator that summarizes the triggers within a window
    // count: number of triggers attributed within a window
    // value_sum: sum of the value of triggers within a window
    // The summary is reported as an index into a bucketization scheme. Defaults
    // to "count"
    "summary_window_operator": <one of "count" or "value_sum">,

    // Represents a bucketization of the integers from [0, MAX_INT], encoded as
    // a list of integers where new buckets begin (excluding 0 which is
    // implicitly included).
    // It must consist of strictly increasing positive integers.
    //
    // e.g. [5, 10, 100] encodes the following ranges:
    // [[0, 4], [5, 9], [10, 99], [100, MAX_INT]]
    //
    // At the end of each reporting window, triggers will be summarized into an
    // integer which slots into one of these ranges. Reports will be sent for
    // every new range boundary that is crossed. Reports will never be sent for
    // the range that includes 0, as every source is initialized in this range.
    //
    // If omitted, then represents a trivial mapping
    // [1, 2, ... , MAX_INT]
    // With MAX_INT being the maximum int value defined by the browser.
    "summary_buckets": [<bucket start>, ...]
  }, {
    // Next trigger_spec
  } ...],

  // See description in phase 1.
  "max_event_level_reports": <int>
  // See description in phase 1.
  "event_report_windows": {
    "start_time": <int>,
    "end_times": [<int>, ...]
  }
}

यह कॉन्फ़िगरेशन, हर सोर्स रजिस्ट्रेशन के हिसाब से इवेंट-लेवल रिपोर्ट के आउटपुट स्पेस के बारे में पूरी तरह से तय करता है. हर ट्रिगर की खास जानकारी के लिए, हम पूरी तरह से यह तय करते हैं:

  • मैचिंग की शर्तों का एक सेट:
    • यह खास जानकारी किस ट्रिगर डेटा पर लागू होती है. इस सोर्स को सिर्फ़ उन ट्रिगर से मैच किया जा सकता है जिनके लिए trigger_specs में, trigger_data वैल्यू में से कोई एक वैल्यू दी गई हो. दूसरे शब्दों में, अगर ट्रिगर इस सोर्स से मैच करता है, लेकिन उसका trigger_data, सोर्स के कॉन्फ़िगरेशन में मौजूद एक वैल्यू नहीं है, तो ट्रिगर को अनदेखा कर दिया जाता है.
    • जब कोई खास ट्रिगर इस स्पेसिफ़िकेशन (event_report_windows का इस्तेमाल करके) से मैच करता है. ध्यान दें कि पहले बताई गई दो मैच शर्तों में असफल होने के बावजूद ट्रिगर को अब भी एग्रीगेट की जा सकने वाली रिपोर्ट के सोर्स से मैच किया जा सकता है.
  • एट्रिब्यूशन विंडो में मौजूद सभी ट्रिगर की खास जानकारी देने और उन्हें बकेट करने के लिए खास एल्गोरिदम. इसकी मदद से, ट्रिगर एक ऐसा value पैरामीटर तय कर सकते हैं जो किसी खास स्पेसिफ़िकेशन के लिए जोड़ा जाता है, लेकिन इसे बकेट की गई वैल्यू के तौर पर रिपोर्ट किया जाता है.

ट्रिगर की मदद से, event_trigger_data के शब्दकोश में एक वैकल्पिक वैल्यू पैरामीटर भी जोड़ा जा सकता है.

{
  "event_trigger_data": [
    {
      "trigger_data": "2",
      "value": 100,  // Defaults to 1
      "filters": ...
    },
    ...
  ]
}

हर ट्रिगर रजिस्ट्रेशन का ज़्यादा से ज़्यादा एक ट्रिगर स्पेसिफ़िकेशन से मैच होगा और इससे जुड़ी खास जानकारी की वैल्यू अपडेट होगी. बड़े लेवल पर, ट्रिगर समय पर हम:

  • ग्लोबल एट्रिब्यूशन फ़िल्टर लागू करें.
  • हर ट्रिगर की खास जानकारी के लिए, स्पेसिफ़िकेशन के event_reporting_window का इस्तेमाल करके मिलान ढूंढने के लिए, स्पेसिफ़िकेशन के event_trigger_data का आकलन करें. अगर ट्रिगर की किसी खास जानकारी में event_report_windows सब-फ़ील्ड मौजूद नहीं है, तो टॉप लेवल event_reporting_windows डिफ़ॉल्ट वैल्यू के तौर पर काम करता है.
  • मैच होने वाली पहली खास जानकारी को एट्रिब्यूशन के लिए चुना जाता है और खास जानकारी की वैल्यू में value की बढ़ोतरी होती है.

खास जानकारी के लिए event_report_window पूरा होने पर, हम इसकी खास जानकारी वाली वैल्यू को एक बकेट में मैप करेंगे. साथ ही, एट्रिब्यूट की गई ट्रिगर वैल्यू की वजह से होने वाली, खास जानकारी वाली बकेट में हर बढ़ोतरी के लिए, इवेंट-लेवल की रिपोर्ट भेजेंगे. रिपोर्ट में एक और फ़ील्ड, trigger_summary_bucket होगा.

{
  ...
  "trigger_summary_bucket": [<bucket start>, <bucket end>],
}

ऐसे कॉन्फ़िगरेशन जो मौजूदा वर्शन से मिलते-जुलते हैं

एपीआई के मौजूदा इवेंट और नेविगेशन सोर्स के लिए, ये कॉन्फ़िगरेशन एक जैसे होते हैं. खास तौर पर, नेविगेशन के सोर्स के लिए, इससे पता चलता है कि एक जैसे एपिसोड की वैल्यू बनाए रखने के लिए, इवेंट सोर्स की तुलना में नॉइज़ लेवल इतना ज़्यादा क्यों है: नेविगेशन सोर्स में आउटपुट स्पेस ज़्यादा है.

ऐसा हो सकता है कि एक जैसे कई कॉन्फ़िगरेशन हों. ऐसा इसलिए होता है, क्योंकि कुछ पैरामीटर को डिफ़ॉल्ट के तौर पर सेट किया जा सकता है या कम किया जा सकता है.

इवेंट के मिलते-जुलते सोर्स
// Note: most of the fields here are not required to be explicitly listed.
// Here we list them explicitly just for clarity.
{
  "trigger_specs": [
  {
    "trigger_data": [0, 1],
    "event_report_windows": {
      "end_times": [<30 days>]
    },
    "summary_window_operator": "count",
    "summary_buckets": [1],
  }],
  "max_event_level_reports": 1,
  ...
  // expiry must be greater than or equal to the last element of the end_times
  "expiry": <30 days>,
}
नेविगेशन के मिलते-जुलते सोर्स
// Note: most of the fields here are not required to be explicitly listed.
// Here we list them explicitly just for clarity.
{
  "trigger_specs": [
  {
    "trigger_data": [0, 1, 2, 3, 4, 5, 6, 7],
    "event_report_windows": {
      "end_times": [<2 days>, <7 days>, <30 days>]
    },
    "summary_window_operator": "count",
    "summary_buckets": [1, 2, 3],
  }],
  "max_event_level_reports": 3,
  ...
  // expiry must be greater than or equal to the last element of the end_times
  "expiry": <30 days>,
}

कस्टम कॉन्फ़िगरेशन के उदाहरण

नीचे डिफ़ॉल्ट के बाहर के कुछ अतिरिक्त कॉन्फ़िगरेशन दिए गए हैं. इन सभी उदाहरणों में, डेवलपर के लिए ट्रेड-ऑफ़ में ये शामिल हैं:

  • शोर के स्तर को बरकरार रखने के लिए, किसी दूसरे डाइमेंशन को बढ़ाने के लिए डिफ़ॉल्ट कॉन्फ़िगरेशन (#ट्रिगर, ट्रिगर डेटा, #Windows) के कुछ डाइमेंशन को कम कर रही हूँ
  • गै़र-ज़रूरी डेटा के लेवल को कम करने के लिए डिफ़ॉल्ट कॉन्फ़िगरेशन के कुछ डाइमेंशन को कम कर रही हूँ (#ट्रिगर, ट्रिगर डेटा कार्डिनैलिटी, #Windows)

रिपोर्ट ट्रिगर वैल्यू बकेट

उदाहरण के तौर पर दिया गया यह कॉन्फ़िगरेशन, एक ऐसे डेवलपर के साथ काम करता है जो कम शोर में कम रिपोर्टिंग विंडो के लिए, सिर्फ़ एक रिपोर्टिंग विंडो (जैसे कि सात दिन) के लिए, वैल्यू डेटा को ऑप्टिमाइज़ करना चाहता है. इस उदाहरण में, अगर trigger_data को 0 के बजाय किसी दूसरी वैल्यू पर सेट किया जाता है, तो उसे एट्रिब्यूशन नहीं दिया जा सकता.

{
  "trigger_specs": [
  {
    "trigger_data": [0],
    "event_report_windows": {
      "end_times": [604800, 1209600] // 7 days, 14 days represented in seconds
    },
    "summary_window_operator": "value_sum",
    "summary_buckets": [5, 10, 100]
  }],
}

ट्रिगर को value फ़ील्ड सेट के साथ रजिस्टर किया जा सकता है. इन फ़ील्ड सेट को जोड़कर, बांटा जाता है. उदाहरण के लिए, अगर सोर्स रजिस्ट्रेशन के सात दिनों के अंदर 1, 3, और 4 वैल्यू वाले तीन ट्रिगर हों.

{ "event_trigger_data": [{"trigger_data": "0", "value": 1}] }
{ "event_trigger_data": [{"trigger_data": "0", "value": 3}] }
{ "event_trigger_data": [{"trigger_data": "0", "value": 4}] }

वैल्यू को जोड़ कर 8 कर दिया जाता है. इन्हें सात दिन और एक घंटे बाद इन रिपोर्ट में रिपोर्ट किया जाता है:

// Report 1
{
  ...
  "trigger_summary_bucket": [5, 9]
}

बाद के 7 दिनों में, ये ट्रिगर रजिस्टर किए जाते हैं:

{ "event_trigger_data": [{"trigger_data": "0", "value": 50}] }
{ "event_trigger_data": [{"trigger_data": "0", "value": 45}] }

वैल्यू का योग 8 + 50 + 45 = 103 है. इससे 14 दिन + 1 घंटे बाद ये रिपोर्ट मिलती हैं:

// Report 2
{
  ...
  "trigger_summary_bucket": [10, 99]
},

// Report 3
{
  ...
  "trigger_summary_bucket": [100, MAX_INT]
}
रिपोर्ट ट्रिगर की संख्या

इस उदाहरण में दिखाया गया है कि डेवलपर 10 तक ट्रिगर की संख्या पाने के लिए सोर्स को कैसे कॉन्फ़िगर कर सकता है.

{
  "trigger_specs": [
  {
    "trigger_data": [0],
    "event_report_windows": {
      "end_times": [604800] // 7 days represented in seconds
    },
    // This field could be omitted to save bandwidth since the default is "count"
    "summary_window_operator": "count",
    "summary_buckets": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
  }],
}

trigger_data वाले एट्रिब्यूट किए गए जिन ट्रिगर की वैल्यू 0 पर सेट होती है उनकी गिनती की जाती है और उन्हें 10 तक सीमित किया जाता है. ट्रिगर वैल्यू को अनदेखा कर दिया जाता है, क्योंकि summary_window_operator को गिनती पर सेट किया गया है. अगर चार ट्रिगर रजिस्टर किए गए हैं और सोर्स को एट्रिब्यूट किए गए हैं, तो रिपोर्ट कुछ ऐसी दिखेगी:

// Report 1
{
  ...
  "trigger_summary_bucket": [1, 1]
}
// Report 2
{
  ...
  "trigger_summary_bucket": [2, 2]
}
// Report 3
{
  ...
  "trigger_summary_bucket": [3, 3]
}
// Report 4
{
  ...
  "trigger_summary_bucket": [4, 4]
}
ज़्यादा रिपोर्टिंग वाली बाइनरी

उदाहरण के तौर पर, यह कॉन्फ़िगरेशन एक ऐसे डेवलपर के साथ काम करता है जो यह जानना चाहता है कि शुरुआती 10 दिनों में कम से कम एक कन्वर्ज़न हुआ है या नहीं (भले ही कोई भी कन्वर्ज़न हुआ हो), लेकिन वह डिफ़ॉल्ट की तुलना में ज़्यादा बार-बार रिपोर्ट पाना चाहता है. ध्यान दें, इस उदाहरण में जब trigger_data को 0 के बजाय किसी दूसरी वैल्यू पर सेट किया जाता है, तो उसे एट्रिब्यूशन नहीं मिलेगा. इसलिए, इस्तेमाल के इस उदाहरण को बाइनरी कहा जाता है.

{
  "trigger_specs": [
  {
    "trigger_data": [0],
    "event_report_windows": {
      // 1 day, 2 days, 3 days, 5 days, 7 days, 10 days represented in seconds
      "end_times": [86400, 172800, 259200, 432000, 604800, 864000]
    },
    // This field could be omitted to save bandwidth since the default is "count"
    "summary_window_operator": "count",
    "summary_buckets": [1]
  }],
}
स्रोत से स्रोत तक अलग-अलग ट्रिगर की जानकारी
{
  "trigger_specs": [
  {
    "trigger_data": [0, 1, 2, 3],
    "event_report_windows": {
      "end_times": [172800, 604800, 2592000] // 2 days, 7 days, 30 days represented in seconds
    }
  }],
  "max_event_level_reports": 3
}
{
  "trigger_specs": [
  {
    "trigger_data": [4, 5, 6, 7],
    "event_report_windows": {
      "end_times": [172800, 604800, 2592000] // 2 days, 7 days, 30 days represented in seconds
    }
  }],
  "max_event_level_reports": 3
}

हम डेवलपर को सुझाव देते हैं कि वे इस एपीआई एक्सटेंशन के लिए, इस्तेमाल के अलग-अलग उदाहरण दें. साथ ही, हम इस जानकारी को अपडेट करके, इस एपीआई एक्सटेंशन के सैंपल कॉन्फ़िगरेशन अपडेट करेंगे.

रीडायरेक्ट के बिना क्रॉस नेटवर्क एट्रिब्यूशन

विज्ञापन टेक्नोलॉजी को कई एट्रिब्यूशन सोर्स ट्रिगर रजिस्टर करने और क्रॉस-नेटवर्क एट्रिब्यूशन करने के लिए, रीडायरेक्ट का इस्तेमाल करना चाहिए. यह सुविधा क्रॉस-नेटवर्क एट्रिब्यूशन के साथ काम करती है, जहां रीडायरेक्ट करने की सुविधा सभी नेटवर्क पर काम नहीं करती. ज़्यादा जानें.

विज्ञापन टेक्नोलॉजी, ट्रिगर रजिस्ट्रेशन रिस्पॉन्स में कॉन्फ़िगरेशन भेज सकती हैं. यह इस आधार पर तय किया जाता है कि दूसरी विज्ञापन टेक्नोलॉजी ने किन सोर्स को रजिस्टर किया है, ताकि उनसे मिले सोर्स जनरेट किए जा सकें. इसके बाद, एट्रिब्यूशन के लिए इन सोर्स का इस्तेमाल किया जाता है. एग्रीगेट रिपोर्ट तब जनरेट होती हैं, जब ट्रिगर को किसी डिराइव्ड सोर्स से एट्रिब्यूट किया जाता है. हासिल किए गए सोर्स के लिए, इवेंट रिपोर्ट जनरेट करने की सुविधा काम नहीं करती.

विज्ञापन टेक्नोलॉजी कंपनियां अपने रजिस्टर किए गए सोर्स में से, aggregation_keys में से चुन सकती हैं और इन्हें पार्टनर विज्ञापन टेक्नोलॉजी के साथ शेयर करना चाहती हैं. इन कुंजियों का एलान, सोर्स रजिस्ट्रेशन हेडर Attribution-Reporting-Register-Source के नीचे मौजूद विकल्प के तौर पर दिए गए shared_aggregation_keys फ़ील्ड में किया जा सकता है:

"shared_aggregation_keys": ["[key name1]", "[key name2]"]

हासिल किए गए सोर्स, ट्रिगर रजिस्ट्रेशन के हेडर Attribution-Reporting-Register-Trigger में मौजूद कॉन्फ़िगरेशन के आधार पर जनरेट होते हैं:

  // Specifies the configuration based on which derived sources should be
  // generated. Those derived sources will be included for source matching at the
  // time of attribution. For example, if adtech2 is registering a trigger with an
  // attribution_config with source_network as adtech1, available sources
  // registered by adtech1 will be considered with additional filtering criteria
  // applied to that set as mentioned in the attribution_config. Derived
  // sources can have different values to priority, post_install_exclusivity_window
  // etc.

  "attribution_config": [
    {
      // Derived sources are created from this adtech's registered sources
      "source_network": "[original source's adtech enrollment ID]",
      //(optional) Filter sources whose priority falls in this range
      "source_priority_range": {
        "start": [priority filter lower bound],
        "end": [priority filter upper bound]
      },
      // (optional) Filter sources whose at least one of filter maps matches these
      // filters
      "source_filters": {
        "key name 1": ["key1 value 1"]
      },
      // (optional) Filter sources whose none of filter map matches these
      // filters
        "source_not_filters": {
          "key name 1": ["key1 value 1"]
        },
      // (optional) Apply this priority to the generated derived sources
      "priority": "[64 bit signed integer]",
      // (optional) The derived source will have expiry set as this or parent
      // source's, whichever is earlier
      "expiry": "[64 bit signed integer]",
      // (optional) set on the derived source
      "filter_data": {
        "key name 1": ["key1 value 1"]
      },
      // (optional) set on the derived source
      "post_install_exclusivity_window": "[64-bit unsigned integer]"
    }
  ]

यहां उदाहरण के तौर पर जोड़ी गई वैल्यू का एक वर्शन दिया गया है:

  "attribution_config": [
    {
      "source_network": "adtech1-enrollment-id",
      "source_priority_range": {
        "start": 50,
        "end": 100
      },
      "source_filters": {
        "source_type": ["NAVIGATION"]
      },
      "source_not_filters": {
        "product_id": ["789"]
      },
      "priority": "30",
      "expiry": "78901",
      // (optional) set on the derived source
      "filter_data": {
        "product_id": ["1234"]
        },
      // (optional) set on the derived source
      "post_install_exclusivity_window": "7890"
    }
  ]

ट्रिगर रजिस्ट्रेशन हेडर के लिए, दो नए वैकल्पिक फ़ील्ड जोड़े गए हैं. ये फ़ील्ड एग्रीगेट करने लायक रिपोर्ट कुंजियों में विजेता विज्ञापन तकनीक के आइडेंटिफ़ायर को चालू करते हैं:

  • x_network_bit_mapping: विज्ञापन तकनीक पहचानकर्ता बिट मैपिंग के लिए रजिस्ट्रेशन आईडी
  • x_network_data: विजेता विज्ञापन तकनीक के लिए ऑफ़सेट (बायां शिफ़्ट) x_network_bit_mapping या ट्रिगर कुंजी के हिस्से के साथ कार्रवाई
उदाहरण:
"Attribution-Reporting-Register-Trigger": {
  "attribution_config": [...],
  "aggregatable_trigger_data": [
    {
     "key_piece": "0x400",
     "source_keys": ["campaignCounts"]
      "x_network_data" : {
        "key_offset" : 12 // [64 bit unsigned integer]
      }
    }
    …
  ]
  …
  "x_network_bit_mapping": {
   // This mapping is used to generate trigger key pieces with AdTech identifier
   // bits. eg. If AdTechA's sources wins the attribution then 0x1 here will be
   // OR'd with the trigger key pieces to generate the final key piece.
    "AdTechA-enrollment_id": "0x1", // Identifier bits in hex for A
    "AdTechB-enrollment_id": "0x2"  // Identifier bits in hex for B
  }
  …
}

AdTechB के सोर्स के लिए रिपोर्ट जनरेट करते समय, ट्रिगर की इस कैलकुलेशन से मिलने वाले नतीजे यहां दिए गए हैं:

  • key_piece: 0x400 (010000000000)
  • key_offset: 12
  • AdtechB की enrollment_id वैल्यू: 2 (010) (x_network_bit_mapping से)
  • नतीजे के तौर पर इस्तेमाल होने वाले ट्रिगर की कुंजी: 0x400 | 0x2 << 12 = 0x2400

सीमाएं

SDK टूल के रनटाइम में इस्तेमाल की जा रही सुविधाओं की सूची देखने के लिए, प्रॉडक्ट की जानकारी देखें.

बग और समस्याओं की रिपोर्ट करें

आपके सुझाव, शिकायत या राय, Android पर प्राइवसी सैंडबॉक्स का अहम हिस्सा होते हैं! अगर आपको समस्याओं का पता चलता है या Android पर प्राइवसी सैंडबॉक्स को बेहतर बनाने के लिए आइडिया आते हैं, तो हमें बताएं.