通过 GTM AMP 变量传递带有空格的键

Passing along keys with whitespace through GTM AMP Variables

我正在尝试将 "content id" 的值作为 GTM 中的 AMP 变量传递。但是,由于键中的空格,我无法[大概]获取值:

<amp-analytics config="http://example.com/config.json">
<script type="application/json">
{
  "requests": {
    "pageview": "https://example.com/...
  },
  "vars": {
    "content id": "ABC123",
    "author": "John Smith"
  ...

其他键(例如作者)成功 return 值。我试过 post%20id 等组合,甚至直接将值称为 CD(绕过 GTM 变量)。有没有人了解 AMP/GTM 对带有空格的 AMP 文章变量的处理?

你不能在变量名中使用space,你可以使用URL这样编码的版本:

<script type="application/json">
{
  "vars": {
    "content%20id": "ABC123",
    "author": "John Smith"
    }
}
</script>

然后在 GTM 中使用相同的 content%20id 变量。

当然,最好的方法就是使用 content_id