首页 > 解决方案 > 修复 React-facebook-pixel

问题描述

我对 Facebook 像素包有一点问题。我只需要它来查看页面。我在这里查阅了官方文档,它似乎很容易使用。但是,它仍然不起作用。我写了以下代码:

import ReactPixel from 'react-facebook-pixel'

const advancedMatching = { em: 'some@email.com' }
const options = {
  autoConfig: true,
  debug: false,
}

function MyPage(){
  // other delarations
    useEffect(() => {
      ReactPixel.init('123456', advancedMatching, options)
      if (hasMarketingPreference) {
        console.log("I've just viewed the page!")
        ReactPixel.pageView()
      } else {
        ReactPixel.revokeConsent()
      }
    }, [])

  return (<>{/*the page code*/}</>)
}

看起来它达到了console.log()声明,但它仍然不起作用。我做错什么了吗?非常感谢!

标签: javascriptnode.jsreactjsfacebook-pixel

解决方案


推荐阅读