New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scripts not being intercepted on a client-side transition #74
Comments
Hi, I have the same question too: I successfully loaded the GTM script on my custom Next.js Document page and, at start, the pageview event is triggered as expected. I tried, then, to push the pageview event client side, listening on "routeChangeComplete" router event but the command is never forwarded to the service worker: useEffect(() => {
const pageview = (url) => {
dataLayer.push({
event: "pageview",
page: url,
})
}
router.events.on("routeChangeComplete", pageview)
return () => {
router.events.off("routeChangeComplete", pageview)
}
}, [router.events]) |
We're encountering the same with Nuxt. I think implementing with MutationObserver might be a straightforward approach? |
I faced this same issue while implementing this with I've created simple implementation here nuxt2-partytown-demo If this issue is fixed then I'm planning to write a module/plugin for |
I ran gtag integration test locally and it seems button click is not sending event as it suppose to send
Also tried live test https://partytown.builder.io/tests/integrations/gtm/ with same problem. Is this expected behaviour and I am not understanding something or there is problem? |
I am getting the same issue. I cannot find a way to send a page view event to the Partytown GTM script from the main thread in Next.js. |
Check this demo nuxt2-partytown-demo I tried using hidden input on main thread and dispatchEvent('change') on button click and listen the same input change event in doing |
Hi, I finally found how to use GA with Partytown and Next.js.... here my post about it: I'd like to try with GTM too. |
@adamdbradley what's would be the correct approach here to help implement?
One would be the most automated one, where you don't have to think about implementation details as a end-user. The second option would be more on the framework side, where you can do the logic with a Script component. |
This is because the Edit: I've scratched around a bit more and it seems that the worker uses |
Thanks for your help @mrakus-sofomo |
@gioboa Is this issue still present in nextjs worker script? |
I guess so. I didn't solve it yet |
Hi folks! I'm noticing an interesting issue adding Partytown to a Next.js app and I'm not sure if it's intended behavior or if I'm just doing something wrong 馃槄.
Consider a basic Next.js application with two routes that have the
<Partytown/>
React component included in its head along with a 3P script withtype="text/partytown"
:Page 1:
Page 2:
When I reload either of the two pages where the Partytown snippet gets injected server-side, the script seems to be intercepted by the service worker correctly and I see that it gets executed via the debug logs:
However when I navigate from one page to the other via a client-side transition, the script on the second page doesn't seem to be fetched or executed. Here's a video that shows how the script on the second page doesn't load on a client-side navigation but does during an SSR reload:
Screen.Recording.2022-02-12.at.2.49.17.PM.mov
Similarly, if I remove the script in Page 1 and then navigate to Page 2 where the Partytown snippet should get injected and instantiated client-side, it doesn't seem to work as well 馃.
I set up a reproduction here: https://codesandbox.io/s/mystifying-goldberg-o12j7?file=/pages/index.js. Please let me know if you need any more details and/or if I can help debug where the potential issue may be happening.
The text was updated successfully, but these errors were encountered: