无法为 Google 跟踪代码管理器添加 AMP 变量
Can't add AMP Variable for Google Tag Manager
我正在为网站使用 Google Analytics 和 Google 标签管理器,我正在尝试为我的 AMP 页面添加自定义维度,我找到了解决方案
https://support.google.com/tagmanager/answer/6164990?hl=en (Step 2) and for AMP pages I am using AMP variables as described here https://support.google.com/tagmanager/answer/9205783?hl=en。
<amp-analytics config="https://www.googletagmanager.com/amp.json?id=Tag Manager-XXXXXX;Tag Manager.url=SOURCE_URL" data-credentials="include">
<script type="application/json ">
{
"vars" : {
"type": "shoes",
"color": "red"
}
}
</script>
</amp-analytics>
但是在我的页面上添加 AMP 变量后我收到 AMP 错误 "Custom JavaScript is not allowed" 并且标签管理器没有捕获我的变量。
我花了很多时间来寻找错误原因,所以我想与其他开发者分享。我只是删除了我从他们的官方页面 https://support.google.com/tagmanager/answer/9205783?hl=en 复制的额外 space,它开始工作了。
我只是将 <script type="application/json ">
替换为 <script type="application/json">
我正在为网站使用 Google Analytics 和 Google 标签管理器,我正在尝试为我的 AMP 页面添加自定义维度,我找到了解决方案 https://support.google.com/tagmanager/answer/6164990?hl=en (Step 2) and for AMP pages I am using AMP variables as described here https://support.google.com/tagmanager/answer/9205783?hl=en。
<amp-analytics config="https://www.googletagmanager.com/amp.json?id=Tag Manager-XXXXXX;Tag Manager.url=SOURCE_URL" data-credentials="include">
<script type="application/json ">
{
"vars" : {
"type": "shoes",
"color": "red"
}
}
</script>
</amp-analytics>
但是在我的页面上添加 AMP 变量后我收到 AMP 错误 "Custom JavaScript is not allowed" 并且标签管理器没有捕获我的变量。
我花了很多时间来寻找错误原因,所以我想与其他开发者分享。我只是删除了我从他们的官方页面 https://support.google.com/tagmanager/answer/9205783?hl=en 复制的额外 space,它开始工作了。
我只是将 <script type="application/json ">
替换为 <script type="application/json">