-
-
Save marcorivm/e73a7321907e15e957250551b0051e57 to your computer and use it in GitHub Desktop.
Add Facebook Pixel to Sharetribe Flex project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| REACT_APP_FB_PIXEL_ID= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ... 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