Hello :wave: Did anyone managed to integrate grow...
# ask-questions
Hello 👋 Did anyone managed to integrate growthbook with nextjs middleware + Segment? Trying to utilise the trackingCallback but it seems like
and middleware might not be so compatible.. Been patiently waiting for the follow up on this article: https://dev.to/jdorn/ab-testing-with-the-new-nextjs-12-middleware-54j6 😄 thanks!
I'm not sure any of the usual analytics SDKs work with middleware right now since neither NodeJS nor browser APIs are fully supported. For Segment, you should be able to track events using their HTTP endpoint instead of the
package - https://segment.com/docs/connections/sources/catalog/libraries/server/http-api/
The other option is to pass the assigned variation down to the client in a cookie and call Segment from the front-end. That approach is pretty messy though, not sure I would recommend that.
Thanks, I will give http endpoint a shot! 👍
Another tip is to track the event inside the
method to avoid a timeout if the analytics endpoint responds slowly. See more here: https://vercel.com/docs/concepts/functions/edge-functions#nextfetchevent
👍 1