keystone-design-bootstrap 1.0.77 → 1.0.79

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keystone-design-bootstrap",
3
- "version": "1.0.77",
3
+ "version": "1.0.79",
4
4
  "description": "Keystone Design Bootstrap - Sections, Elements, and Theme System for customer websites",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -8,7 +8,6 @@ import {
8
8
  MetaPixelTracker,
9
9
  PostHogProvider,
10
10
  KeystoneAnalyticsTracker,
11
- GoogleTagManager,
12
11
  } from '../../tracking';
13
12
  import { ChatWidget } from '../../design_system/components/ChatWidget';
14
13
  import { FormDefinitionsProvider } from '../contexts/form-definitions';
@@ -159,6 +158,13 @@ export async function KeystoneRootLayout(props: {
159
158
  const posthogApiKey = getPostHogApiKey(analyticsConfig);
160
159
  const gtmContainerId = getGtmContainerPublicId(analyticsConfig);
161
160
  const keystoneEnvironment = getKeystoneEnvironment(analyticsConfig);
161
+ const gtmBootstrapScript = gtmContainerId
162
+ ? `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
163
+ new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
164
+ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
165
+ 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
166
+ })(window,document,'script','dataLayer','${gtmContainerId.replace(/'/g, "\\'")}');`
167
+ : null;
162
168
 
163
169
  const services = Array.isArray(servicesData) ? servicesData : [];
164
170
  const locations = Array.isArray(locationsData) ? locationsData : [];
@@ -195,7 +201,6 @@ export async function KeystoneRootLayout(props: {
195
201
  <>
196
202
  {metaPixelId ? <MetaPixel pixelId={metaPixelId} /> : null}
197
203
  {metaPixelId ? <MetaPixelTracker bookingUrl={externalManagementUrl} /> : null}
198
- {gtmContainerId ? <GoogleTagManager containerId={gtmContainerId} /> : null}
199
204
  <ThemeProvider theme={theme}>
200
205
  <KeystoneSSRProvider>
201
206
  <FormDefinitionsProvider
@@ -234,7 +239,23 @@ export async function KeystoneRootLayout(props: {
234
239
 
235
240
  return (
236
241
  <html lang="en" data-theme={theme}>
242
+ <head>
243
+ {gtmBootstrapScript ? (
244
+ <script id="google-tag-manager" dangerouslySetInnerHTML={{ __html: gtmBootstrapScript }} />
245
+ ) : null}
246
+ </head>
237
247
  <body>
248
+ {gtmContainerId ? (
249
+ <noscript>
250
+ <iframe
251
+ src={`https://www.googletagmanager.com/ns.html?id=${gtmContainerId}`}
252
+ height="0"
253
+ width="0"
254
+ style={{ display: 'none', visibility: 'hidden' }}
255
+ title="google-tag-manager"
256
+ />
257
+ </noscript>
258
+ ) : null}
238
259
  {posthogApiKey ? (
239
260
  <PostHogProvider
240
261
  apiKey={posthogApiKey}
@@ -1,7 +1,3 @@
1
- 'use client';
2
-
3
- import Script from 'next/script';
4
-
5
1
  const GTM_SCRIPT = (containerId: string) => `
6
2
  (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
7
3
  new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
@@ -29,11 +25,7 @@ export function GoogleTagManager({ containerId }: GoogleTagManagerProps) {
29
25
 
30
26
  return (
31
27
  <>
32
- <Script
33
- id="google-tag-manager"
34
- strategy="afterInteractive"
35
- dangerouslySetInnerHTML={{ __html: GTM_SCRIPT(id) }}
36
- />
28
+ <script id="google-tag-manager" dangerouslySetInnerHTML={{ __html: GTM_SCRIPT(id) }} />
37
29
  <noscript>
38
30
  <iframe
39
31
  src={`https://www.googletagmanager.com/ns.html?id=${id}`}