我想在我的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请求如下:{{3}}
因此它将各种空参数发送到FB。 Facebook像素的大多数标准事件参数都是可选的。我不希望他们发送所有参数。我只想发送content_category ..
答案 0 :(得分:1)
使用img像素。示例:
<amp-pixel src="https://www.facebook.com/tr?id=&ev=ViewContent&noscript=1"
layout="nodisplay"></amp-pixel>
答案 1 :(得分:0)
使用以下配置:
<amp-analytics type="facebookpixel" id="facebook-pixel">
<script type="application/json">
{
"vars": {
"pixelId": "PIXEL_ID"
},
"triggers": {
"trackPageview": {
"on": "visible",
"request": "pageview"
},
"trackViewContent": {
"on": "visible",
"request": "eventViewContent",
"vars": {
"product_catalog_id": "category_id",
"currency": "EUR",
"content_name": "content_name",
"content_category": "content_category",
"content_type": "product",
"content_ids": "[1,2,3]",
"value": "10"
}
}
}
}
</script>
</amp-analytics>