Chrome 92 將變更 Conversion Measurement API。
異動內容
2021 年前幾個月的 API 提案變更後,Chrome 中的 API 實作方式也隨之演進。異動內容如下:
- API 名稱和權限政策名稱。
- HTML 屬性名稱和
.well-known網址。 - 報表格式。現在報表會以 JSON 格式傳送至要求主體。
- 已移除
credit的內容,以及積分為 0 的檢舉。
Chrome 92 仍支援事件層級報表 (僅限點擊)。敬請期待相關更新。這項變更生效後,其他更新和功能將在日後的 Chrome 版本中發布。
這些異動何時生效?
這些異動將於 2021 年 7 月 20 日在 Chrome 92 穩定版中生效。Chrome 92 Beta 版已於 2021 年 6 月 3 日發布。
此時該如何處理這種狀況?
如果您正在執行原始伺服器試用,或已實作這項 API 的試用版,則有兩種做法:
- 方案 1 (建議):立即或在接下來幾週內遷移程式碼,最好在 2021 年 7 月中之前完成。這樣一來,您的程式碼集就能因應日後變更,並繼續在較新的 Chrome 用戶端上運作。
- 選項 2:等待日後發布的 Chrome 版本推出更多更新和功能,然後一次完成所有必要的程式碼變更。
遷移
遷移範例
您可以在這份提取要求 (草稿) 中,查看小型示範應用程式的遷移範例。
更新權限政策程式碼
| 舊版程式碼 | 新驗證碼 |
|---|---|
allow='conversion-measurement' |
allow='attribution-reporting' |
更新功能偵測程式碼
| 舊版程式碼 | 新驗證碼 |
|---|---|
document.featurePolicy.features() |
document.featurePolicy.features() |
更新 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」已移除。
|
歸因報表:所有資源
請參閱「歸因報表」。