Author SHA1 Message Date
andwati 2c19e7ed1a Tidy gtag snippet indentation 2026-09-30 14:19:21 +03:00
andwati a06a93019f Only load analytics in production 2026-09-30 14:19:13 +03:00
andwati 77cc86ddf9 Add Google Analytics via next/script 2026-09-30 14:17:41 +03:00
andwatiandGitHub 2960dc622f Merge pull request #5 from andwati/feat/nextjs-site
Replace Astro/Strapi site with Next.js static export
2026-09-30 13:55:52 +03:00
+18 -1
View File
@@ -58,6 +58,9 @@ const websiteLd = {
author: { "@type": "Person", name: site.name },
};
const isProd = process.env.NODE_ENV === "production";
const gaId = "G-9XLTKZF07C";
const umamiScript = process.env.PUBLIC_UMAMI_SCRIPT_URL;
const umamiId = process.env.PUBLIC_UMAMI_WEBSITE_ID;
@@ -81,7 +84,21 @@ export default function RootLayout({ children }: LayoutProps<"/">) {
<body>
<JsonLd data={websiteLd} />
<Layout>{children}</Layout>
{umamiScript && umamiId && (
{isProd && (
<>
<Script
src={`https://www.googletagmanager.com/gtag/js?id=${gaId}`}
strategy="afterInteractive"
/>
<Script id="google-analytics" strategy="afterInteractive">
{`window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${gaId}');`}
</Script>
</>
)}
{isProd && umamiScript && umamiId && (
<Script defer src={umamiScript} data-website-id={umamiId} />
)}
</body>