eddev 0.2.52 → 0.2.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -5,9 +5,11 @@ import { getCssText } from "@theme"
|
|
|
5
5
|
import Script from "next/script"
|
|
6
6
|
import settings from "_utils/ed-config"
|
|
7
7
|
|
|
8
|
+
const gtmID =
|
|
9
|
+
settings?.tracking?.tagManagerID === "env" ? process.env.NEXT_PUBLIC_GTM_ID : settings?.tracking?.tagManagerID
|
|
10
|
+
|
|
8
11
|
export default class Document extends NextDocument {
|
|
9
12
|
render() {
|
|
10
|
-
console.log("GTM", settings.tracking?.tagManagerID)
|
|
11
13
|
return (
|
|
12
14
|
<Html lang="en">
|
|
13
15
|
<Head>
|
|
@@ -19,7 +21,7 @@ export default class Document extends NextDocument {
|
|
|
19
21
|
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
|
|
20
22
|
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
|
21
23
|
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
|
|
22
|
-
})(window,document,'script','dataLayer',${JSON.stringify(
|
|
24
|
+
})(window,document,'script','dataLayer',${JSON.stringify(gtmID)});`,
|
|
23
25
|
}}
|
|
24
26
|
></script>
|
|
25
27
|
) : null}
|
|
@@ -44,10 +46,10 @@ export default class Document extends NextDocument {
|
|
|
44
46
|
) : null}
|
|
45
47
|
</Head>
|
|
46
48
|
<body>
|
|
47
|
-
{
|
|
49
|
+
{gtmID ? (
|
|
48
50
|
<noscript
|
|
49
51
|
dangerouslySetInnerHTML={{
|
|
50
|
-
__html: `<iframe src="https://www.googletagmanager.com/ns.html?id=${
|
|
52
|
+
__html: `<iframe src="https://www.googletagmanager.com/ns.html?id=${gtmID}"
|
|
51
53
|
height="0" width="0" style="display:none;visibility:hidden"></iframe>`,
|
|
52
54
|
}}
|
|
53
55
|
></noscript>
|