首页 > 解决方案 > AMP 页面中的 Facebookpixel ViewContent

问题描述

我想在我的 Amp 页面中添加 Facebook Pixels PagesView 和 ViewContent。

这是我的代码:

<amp-analytics type="facebookpixel" id="facebook-pixel">
  <script type="application/json">
    {
      "vars": {
      "pixelId": "xy"
     },
     "triggers": {
       "trackPageview": {
          "on": "visible",
          "request": "pageview"
        },
        "trackViewContent": {
         "on": "visible",
         "request": "eventViewContent",
         "extraUrlParams": {
           "content_category": "open article"
         }
        }
      }
    }
  </script>
</amp-analytics>

Pageview 有效,但对于 ViewContent,我总是在 Facebook Pixel Helper 中收到警告。从 AMP 到 Facebook 的结果 POST 请求是这样的:https://www.facebook.com/tr?noscript=1&ev=ViewContent&id=xy&cd%5Bvalue%5D=&cd%5Bcurrency%5D=&cd%5Bcontent_name%5D=open%20article&cd %5Bcontent_type%5D=&cd%5Bcontent_ids%5D=&dt=o4haxxaf7ij6ugv6b3p7cy2qybh9e8rd

所以它正在向FB发送各种空参数。Facebook 像素的大多数标准事件参数都是可选的。我不希望他们发送所有参数。我只想发送 content_category ..

标签: facebookgoogle-analyticsamp-htmlamp-analytics

解决方案


使用 img 像素。例子:

<amp-pixel src="https://www.facebook.com/tr?id=&ev=ViewContent&noscript=1"
    layout="nodisplay"></amp-pixel>

推荐阅读