-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Description
What version of Next.js are you using?
11.0.1
What version of Node.js are you using?
v16.5.0
What browser are you using?
Chrome, Firefox
What operating system are you using?
ubuntu
How are you deploying your application?
docker using next start using in my vm
Describe the Bug
Adding the following google analytic using the import Script from 'next/script' create an issue
<Script src={https://www.googletagmanager.com/gtag/js?id=${process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS}`}
dangerouslySetInnerHTML={{
__html: window.dataLayer = window.dataLayer || []; function gtag() { dataLayer.push(arguments); } gtag('js', new Date()); gtag('config', '${process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS}', { page_path: window.location.pathname, }); ,
}}
strategy="lazyOnload"
/>`
I disable next-pwa to make sure its not the service worker , the error persists.
Expected Behavior
It should be simply work and import the js file without any errors.
To Reproduce
Add the the following script to reproduct the issue
<Script
src={`https://www.googletagmanager.com/gtag/js?id=${process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS}`}
dangerouslySetInnerHTML={{
__html: `window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', '${process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS}', {
page_path: window.location.pathname,
});
`,
}}
strategy="lazyOnload"
/>

