Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

Add Google Tag Manager integration for demo environment in layout component

Bill Yang5cdc485eed0d
diff --git a/client/src/app/layout.tsx b/client/src/app/layout.tsx
index ba254a2ee..751c2434a 100644
--- a/client/src/app/layout.tsx
+++ b/client/src/app/layout.tsx
@@ -20,9 +20,30 @@ export default function RootLayout({ children }: { children: React.ReactNode })
return (
<html lang="en" className="dark">
+ {globalThis?.location?.hostname === "demo.rybbit.io" && (
+ <head>
+ <Script id="gtm-script" strategy="afterInteractive">
+ {`(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
+ new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
+ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
+ 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
+ })(window,document,'script','dataLayer','GTM-KWZ8K6K9');`}
+ </Script>
+ </head>
+ )}
<ReactScan />
<TooltipProvider>
<body className={cn("bg-background text-foreground h-full", inter.className)}>
+ {globalThis?.location?.hostname === "demo.rybbit.io" && (
+ <noscript>
+ <iframe
+ src="https://www.googletagmanager.com/ns.html?id=GTM-KWZ8K6K9"
+ height="0"
+ width="0"
+ style={{ display: "none", visibility: "hidden" }}
+ />
+ </noscript>
+ )}
<QueryProvider>
<OrganizationInitializer />
<AuthenticationGuard />