Skip to content

Instantly share code, notes, and snippets.

@marcorivm
Created July 20, 2021 13:46
Show Gist options
  • Select an option

  • Save marcorivm/e73a7321907e15e957250551b0051e57 to your computer and use it in GitHub Desktop.

Select an option

Save marcorivm/e73a7321907e15e957250551b0051e57 to your computer and use it in GitHub Desktop.
Add Facebook Pixel to Sharetribe Flex project
REACT_APP_FB_PIXEL_ID=
export class FacebookPixelHandler {
constructor(pixelId) {
import('react-facebook-pixel')
.then(module => module.default)
.then(ReactPixel => {
ReactPixel.init(pixelId)
this.ReactPixel = ReactPixel
})
}
//PageView de facebook pixel
trackPageView() {
if (this.ReactPixel) {
return this.ReactPixel.pageView();
}
}
}
// ... Starting aprox on line 60
const setupAnalyticsHandlers = () => {
let handlers = [];
// ... Add logging and Google Analytics
// Add Facebook Pixel handler if FB_PIXEL_ID is found
if (process.env.REACT_APP_FB_PIXEL_ID) {
handlers.push(new FacebookPixelHandler(process.env.REACT_APP_FB_PIXEL_ID));
}
return handlers;
};
//...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment