Closed cezarcarvalhaes closed 4 years ago
Can you please share the error you got that will make it easier to move forward on this. It is really an interesting scenario.
Sorry for the delay in getting back to you. Yeah, it's definitely an odd scenario. Here's the error we get if we try to fire a ReactPixel event without initializing ReactPixel itself: "fb-pixel.js:1 Pixel not initialized before using call ReactPixel.init with required params"
It's because of the extra precaution we have taken in our code. I wish if you can provide a small code-base where we can test the fix.
Can you please try from this branch. I have altered code to check if PIXEL is already available in the window object.
Is this branch already merged? I would like to initialize the pixel on my index once and use it all over my app just importing react-facebook-pixel
We haven't merged it yet, have you tested it with your system?
I'd like to do something similar now, is this merged in?
You can install from given branch
It would be great to be able to .init() multiple times without worrying about if this was already done, so we can just ensure we init correctly once, but don't have to safeguard another init later on. useEffect
and useReducer
can sometimes fire more than we really want and safeguarding that can be somewhat of a job.
Merged #38
Is there anyway to call ReactPixel methods without initializing first?
The reason I ask is because we have a React app that we're using within other larger sites that have their own fb tracking. We'd like to keep the app modular, and with its own tracking but also not mess up our tracking data by initializing twice on the same page (larger site, plus smaller react component). I tried calling ReactPixel.track() without initializing and got an error. Hoping maybe I can call it and pass in our app ID without initializing and therefore sending in duplicate data to FB.