user3001286
user3001286

Reputation:

Fix React-facebook-pixel

I have a little problem with the Facebook pixel package. I need it only for page view. I consulted the official documentation here and it seems to be pretty easy to use. However, it still doesn't work. I wrote the following code:

import ReactPixel from 'react-facebook-pixel'

const advancedMatching = { em: '[email protected]' }
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*/}</>)
}

It looks like it reaches the console.log() statement, but it still doesn't work. Did I do something wrong? Thank you very much!

Upvotes: 4

Views: 4572

Answers (1)

Udit
Udit

Reputation: 307

Worked for me !!!

We get the error ERR_BLOCKED_BY_CLIENT on chrome if ad blocker is active. Just disable the ad blocker and it will do the work.

Upvotes: 3

Related Questions