fixed build when NEXT_PUBLIC_GTM_ID is not defined
This commit is contained in:
parent
8f9a31bfd4
commit
73c1bdc813
@ -8,5 +8,5 @@ PUBLIC_KEY=
|
|||||||
# Base64 encoded value of private key `cat key.pem | base64`
|
# Base64 encoded value of private key `cat key.pem | base64`
|
||||||
PRIVATE_KEY=
|
PRIVATE_KEY=
|
||||||
|
|
||||||
# Google Tag Manager ID
|
# Google Tag Manager ID. Leave as blank because removing this causes next.js build to fail.
|
||||||
NEXT_PUBLIC_GTM_ID=
|
NEXT_PUBLIC_GTM_ID=""
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { useEffect } from 'react';
|
|||||||
|
|
||||||
function MyApp({ Component, pageProps }: AppProps) {
|
function MyApp({ Component, pageProps }: AppProps) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (process.env.NEXT_PUBLIC_GTM_ID) {
|
if (process.env.NEXT_PUBLIC_GTM_ID && process.env.NEXT_PUBLIC_GTM_ID.length > 0) {
|
||||||
TagManager.initialize({ gtmId: process.env.NEXT_PUBLIC_GTM_ID });
|
TagManager.initialize({ gtmId: process.env.NEXT_PUBLIC_GTM_ID });
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user