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: '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*/}</>)
}
It looks like it reaches the console.log()
statement, but it still doesn't work. Did I do something wrong?
Thank you very much!