gtm-support/vue-gtm

SSR support?

Opened this issue · 0 comments

Request / Idea

Inject the needed scripts (in the head and body tag) in SSR, so the server wil render the tags.

Additional Context

Use https://github.com/vueuse/head to inject script to the head tag.

Of course this needs some work in the frontend, because you have to get the injected head and merge with your index.html, see: https://github.com/vueuse/head#ssr-rendering

There seems no plugin available to inject stuff into the body, as Evan You states: You should not teleport an element to the body because SSR don't know how to hydrate it. Maybe exposing a function, returning the code to add to the body, and implement it in the SSR implementation live mentioned in the vueuse link.

Im going to need this, so expect a PR soon!