Open mattpilott opened 2 years ago
Guessing this component doesn't expect to be rendered server-side where there is no browser.
I decided to add this to my /src/routes/__layout.svelte instead...
onMount(async() => {
const googleAnalytics = document.createElement('script')
googleAnalytics.src = 'https://www.googletagmanager.com/gtag/js?id=YOUR-TRACKER-ID'
document.body.append(googleAnalytics)
window.dataLayer = window.dataLayer || [];
function gtag(){
window.dataLayer.push(arguments)
}
gtag('js', new Date());
gtag('config', 'YOUR-TRACKER-ID');
}
Interesting - it may need updating for SvelteKit.
It doesn't render server-side - it does exactly what you've done above there :)
Seeing this in sveltekit unsure what i need to adjust
<GoogleAnalytics> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules