Skip to content

Commit 949bb28

Browse files
committed
docs: add gtm
1 parent b6fbb98 commit 949bb28

File tree

3 files changed

+46
-15
lines changed

3 files changed

+46
-15
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
export const WidgetGoogleTagManagerHead = () => {
2+
if (typeof window !== 'undefined' && window.env.ENABLE_PLAUSIBLE !== 'true') {
3+
return null
4+
}
5+
6+
return (
7+
<script
8+
id="google-tag-manager--head"
9+
dangerouslySetInnerHTML={{
10+
__html: `
11+
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
12+
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
13+
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
14+
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
15+
})(window,document,'script','dataLayer','GTM-W793TTP7');
16+
`,
17+
}}
18+
/>
19+
)
20+
}
21+
22+
export const WidgetGoogleTagManagerBody = () => {
23+
if (typeof window !== 'undefined' && window.env.ENABLE_PLAUSIBLE !== 'true') {
24+
return null
25+
}
26+
27+
return (
28+
<div
29+
id="google-tag-manager--body"
30+
dangerouslySetInnerHTML={{
31+
__html: `
32+
<!-- Google Tag Manager (noscript) -->
33+
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-W793TTP7"
34+
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
35+
<!-- End Google Tag Manager (noscript) -->
36+
`,
37+
}}
38+
/>
39+
)
40+
}

docs/app/components/Widgets/WidgetPlausible.tsx

Lines changed: 0 additions & 13 deletions
This file was deleted.

docs/app/root.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ import {
1414
useLoaderData,
1515
} from '@remix-run/react'
1616
import { Analytics } from '@vercel/analytics/react'
17-
import { WidgetPlausible } from './components/Widgets/WidgetPlausible'
17+
import {
18+
WidgetGoogleTagManagerHead,
19+
WidgetGoogleTagManagerBody,
20+
} from './components/Widgets/WidgetGoogleTagManager'
1821
import { lightThemeClass } from './styles/light-theme.css'
1922
import global from './styles/global.css?url'
2023
import docusearch from '@docsearch/css/dist/style.css?url'
@@ -111,9 +114,10 @@ export function Layout({ children }: { children: React.ReactNode }) {
111114
<meta name="viewport" content="width=device-width, initial-scale=1" />
112115
<Meta />
113116
<Links />
114-
<WidgetPlausible />
117+
<WidgetGoogleTagManagerHead />
115118
</head>
116119
<body className={theme === 'light' ? lightThemeClass : darkThemeClass}>
120+
<WidgetGoogleTagManagerBody />
117121
{children}
118122
<SiteFooter />
119123
<script

0 commit comments

Comments
 (0)