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!
debug
totrue
for starters and see if that tells you anything, or removing the advanced matching email address (are you using a real address, or just the one you copy & pasted from the example?) If you add a console.log afterReactPixel.pageView()
does that also get reached?true
thedebug
it tells me[react-facebook-pixel] called fbq('track', 'PageView');
. And yeah It reaches the console log after theReactPixel.PageView()
GET https://connect.facebook.net/en_US/fbevents.js net::ERR_BLOCKED_BY_CLIENT
Maybe the facebook pixel is wrong? And btw the email is fake, I don't need it