我正在尝试将Facebook像素集成到我的网站中。我已经按照Pixel文档中给出的步骤进行了操作,并且还将这段代码放在了我的网站中。
<!-- Facebook Pixel Code -->
<script type="text/javascript">
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window, document,'script',
'https://connect.facebook.net/en_US/fbevents.js');
fbq('init', '1299909***520***');
fbq('track', 'PageView');
</script>
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=1299909***520***&ev=PageView&noscript=1"
/></noscript>
<!-- End Facebook Pixel Code -->
当应用程序在localhost中运行时,我能够检测到页面视图,但是在生产环境中不起作用。我已经检查了本地主机和生产版本中的“网络”选项卡,我注意到像素网址仅在本地主机中被调用。这可能是什么原因?
我还使用Facebook Pixel Helper chrome扩展程序来检测触发事件并收到此警告。
We detected event code but the pixel has not activated for this event, so no information was sent to Facebook. This could be due to an error in the code, but could also occur if the pixel fires on a dynamic event such as a button click