mirror of
https://github.com/andwati/andwati.com.git
synced 2026-10-18 09:22:53 +00:00
Add Google Analytics via next/script
This commit is contained in:
@@ -58,6 +58,8 @@ const websiteLd = {
|
|||||||
author: { "@type": "Person", name: site.name },
|
author: { "@type": "Person", name: site.name },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const gaId = "G-9XLTKZF07C";
|
||||||
|
|
||||||
const umamiScript = process.env.PUBLIC_UMAMI_SCRIPT_URL;
|
const umamiScript = process.env.PUBLIC_UMAMI_SCRIPT_URL;
|
||||||
const umamiId = process.env.PUBLIC_UMAMI_WEBSITE_ID;
|
const umamiId = process.env.PUBLIC_UMAMI_WEBSITE_ID;
|
||||||
|
|
||||||
@@ -81,6 +83,16 @@ export default function RootLayout({ children }: LayoutProps<"/">) {
|
|||||||
<body>
|
<body>
|
||||||
<JsonLd data={websiteLd} />
|
<JsonLd data={websiteLd} />
|
||||||
<Layout>{children}</Layout>
|
<Layout>{children}</Layout>
|
||||||
|
<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>
|
||||||
{umamiScript && umamiId && (
|
{umamiScript && umamiId && (
|
||||||
<Script defer src={umamiScript} data-website-id={umamiId} />
|
<Script defer src={umamiScript} data-website-id={umamiId} />
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user