#Google Adsense with Remix
1 messages · Page 1 of 1 (latest)
Somewhere there is an example of splitting the document head and body when doing the initial render on the client. Found these after searching "separate hydration":
https://github.com/Xiphe/remix-island
https://github.com/kiliman/remix-hydration-fix
utils to render remix into a dom-node instead of the whole document - GitHub - Xiphe/remix-island: utils to render remix into a dom-node instead of the whole document
The root of the issue is that google tag manager and similar actually inject additional scripts into the document head at runtime
You can take a look at our gtag implementation here
https://github.com/manawiki/core/blob/main/app/routes/%24siteId%2B/_layout.tsx#L1122
https://github.com/manawiki/core/blob/main/app/routes/%24siteId%2B/utils/gtags.client.ts
For me it works if I load the Adsense script in root.tsx only for the client (useEffect) and activate the ad units also in the client with window.adsbygoogle = window.adsbygoogle || []).push({})
This helped me: https://humanicus.medium.com/fix-google-adsense-loading-issues-with-react-f338cbd61ac4
On one of my recent client projects, I encountered a problem with loading Google AdSense ads.