[已過時] 遷移指南 (Chrome 92 版):從 Conversion Measurement API 遷移至 Attribution Reporting API

Conversion Measurement API 在 Chrome 第 92 版中將有所異動。

異動內容

為了因應 API 提案在 2021 年前幾個月的異動,Chrome 的 API 實作方式也有所改變。異動內容如下:

  • API 名稱和權限政策名稱。
  • HTML 屬性名稱和 .well-known 網址。
  • 報表的格式,現在,報表在要求主體中會以 JSON 格式傳送。
  • 報表內容「credit」已遭移除,報表中的功勞為 0。

Chrome 第 92 版並未變更,包括事件層級報表及僅針對點擊產生的一系列功能。 相關最新消息。這次異動生效後,我們會在日後的 Chrome 版本中推出其他更新和功能。

這些變更何時生效?

這些變更自 Chrome 92 起生效,並於 2021 年 7 月 20 日推出穩定版。Chrome 92 Beta 版已於 2021 年 6 月 3 日發布。

此時該如何處理這種狀況?

如果您正在執行來源試用,或已實作這個 API 的示範,有以下兩種做法:

  • 選項 1 (建議):立即或接下來幾週遷移程式碼,最好在 2021 年 7 月中旬前遷移。如此一來,您的程式碼集即可準備好因應日後的變更,也能繼續支援較新的 Chrome 用戶端。
  • 選項 2:等待日後的 Chrome 版本推出更多更新和功能,並一次進行所有必要程式碼變更。

遷移

遷移範例

如要查看小型試用版應用程式的遷移範例,請參閱這份提取要求 (草稿)

更新權限政策代碼

舊版程式碼 新驗證碼
allow='conversion-measurement' allow='attribution-reporting'

更新功能偵測程式碼

舊版程式碼 新驗證碼
document.featurePolicy.features()
.includes('conversion-measurement')
document.featurePolicy.features()
.includes('attribution-reporting')

更新 HTML 屬性

舊版程式碼 新驗證碼
conversiondestination attributiondestination
impressiondata attributionsourceeventid
impressionexpiry attributionexpiry
reportingorigin attributionreportto

更新 window.open() 引數

您可為由 window.open() 啟動的導覽登錄歸因來源。如果您使用 window.open() 登錄歸因來源,請更新這些呼叫。

您的新程式碼應該會如下所示 (此名稱為「HTML 屬性重新命名」):

window.open(
  'https://dest.example',
  '_blank',
  'attributionsourceeventid=1234,attributiondestination=https://dest.example,attributionreportto=https://reporter.example,attributionexpiry=604800000'
);

更新註冊呼叫網址和參數

舊版程式碼 新驗證碼
.well-known/register-conversion?conversion-data={DATA} .well-known/attribution-reporting/trigger-attribution?trigger-data={DATA}

更新回報端點程式碼

舊版程式碼 新驗證碼
瀏覽器發出的要求 .well-known/register-conversion?impression-data=&conversion-data={DATA}&attribution-credit=100 .well-known/attribution-reporting/trigger-attribution
收到的報告 以網址參數的形式傳送。 在要求主體中以 JSON 格式傳送。

報表資料會以 JSON 物件形式顯示在要求主體中,且包含下列索引鍵:
source_event_id:先前為 impression-data,也就是在歸因來源上設定的 64 位元事件 ID。
trigger_data:先前為 conversion-data,這是歸因觸發條件重新導向中的 3 位元資料集。

⚠️ credit 已移除。

歸因報表:所有資源

請參閱「歸因報表」一文。