Closed neilbradley closed 1 year ago
Hi @neilbradley!
You should probably wrap the fbEvent in an useEffect so it's rendered client side.
Something like this:
function MyApp({ Component, pageProps }: AppProps) {
useEffect(() => {
fbEvent({
eventName: "ViewContent",
products: [],
});
}, []);
return (
<>
...
</>
);
}
Thanks, @ovdahlberg.
That seems to have gotten rid of that error.
When I view my site, developer tools is showing this error for fb-events:
{error: "The request body is missing required parameters"} error: "The request body is missing required parameters"
When I also view the Serverless function logs in Vercel for the /api/fb-events, the POST requests have the following, which is probably due to the error above but I think all of the other parameters were optional? I had to add an empty array of products before because it errored if I didn't include products;
Function Status: 400 Edge Status: 400
I'm assuming this is a Vercel issue rather than
Hi @neilbradley!
I think the problem is related to the empty products array.
Does it work if you add some test product in the array?
In that case, I should make the products array optional.
Hi @ovdahlberg. I’ll give that a try. The website I’m using this on is not an e-commerce site, so we don’t need products to be tracked. We are using this for ViewContent and Lead mainly.
@ovdahlberg Adding the fake SKU in the products array seems to have fixed it for now and I can see ViewContent events appearing in FB.
Hi, Thank you for providing this package. I have a Next.JS project using Typescript, where I have added this code to /pages/api/fb-events.ts;
I have then added the fbEvent into /pages/_app.tsx as follows, but i'm not seeing any test events come through to Facebook when I have deployed to Vercel. I also have the variable set:
NEXT_PUBLIC_FB_DEBUG=true
.I wondered if you could tell me if I have missed something?
When I check the Realtime Logs in Vercel Functions, I also see this error;
Thank you.