Skip to content

Commit

Permalink
Add gtm script
Browse files Browse the repository at this point in the history
  • Loading branch information
magdalenaxm authored and thomasdax98 committed Aug 6, 2024
1 parent b3e55d1 commit 2007f7f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions site-configs/secondary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default ((env) => {
domain: "secondary",
languages: ["en", "de"],
},
gtmId: "GTM-YYYY",
},
};
}) satisfies GetSiteConfig;
13 changes: 13 additions & 0 deletions site/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { SitePreviewProvider } from "@comet/cms-site";
import { GlobalStyle } from "@src/layout/GlobalStyle";
import { getSiteConfig } from "@src/middleware";
import { ResponsiveSpacingStyle } from "@src/util/ResponsiveSpacingStyle";
import StyledComponentsRegistry from "@src/util/StyledComponentsRegistry";
import type { Metadata } from "next";
Expand All @@ -15,12 +16,24 @@ export default async function RootLayout({
}: Readonly<{
children: React.ReactNode;
}>) {
const { gtmId } = await getSiteConfig();

return (
<html>
<head>
<PublicEnvScript />
</head>
<body>
{gtmId && (
<noscript>
<iframe
src={`https://www.googletagmanager.com/ns.html?id=${gtmId}`}
height="0"
width="0"
style={{ display: "none", visibility: "hidden" }}
/>
</noscript>
)}
<StyledComponentsRegistry>
<GlobalStyle />
<ResponsiveSpacingStyle />
Expand Down

0 comments on commit 2007f7f

Please sign in to comment.