Conversion Measurement API 在 Chrome 92 中即将发生变化。
有何变化?
继 2021 头几个月内 API 提案变更之后,Chrome 中的 API 实现也在不断改进。具体变化如下:
- API 名称和权限政策名称。
- HTML 属性名称和
.well-known
网址。 - 报告的格式。现在,报告在请求正文中以 JSON 格式发送。
- 以下报告的内容:
credit
以及原本没有功劳的报告。
在 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 已移除。
|
Attribution Reporting:所有资源
请参阅归因报告。