Itegrate facebook pixel very easy with react-facebook-pixel
Open and modify _app.tsx and add code like below
useEffect(() => {
import('react-facebook-pixel')
.then((x) => x.default)
.then((ReactPixel) => {
ReactPixel.init('FACEBOOK_PIXEL_ID')
ReactPixel.pageView()
router.events.on('routeChangeComplete', () => {
ReactPixel.pageView()
})
})
}, [router.events])
Top comments (1)
Hello, Agik
As you know, router.events is not supported in NextJs 13 with the app router.
Would it be possible to know the equivalent code to integrate Facebook pixel in a site built on app router?
Thank you very much and greetings