23 lines
641 B
TypeScript
23 lines
641 B
TypeScript
import Script from "next/script";
|
|
|
|
export default function Init() {
|
|
return (
|
|
<>
|
|
<Script
|
|
src={`https://www.googletagmanager.com/gtag/js?id=${process.env.NEXT_PUBLIC_GA_TRACKING_ID}`}
|
|
strategy="lazyOnload"
|
|
/>
|
|
<Script id="google-analytics" strategy="lazyOnload">
|
|
{`
|
|
window.dataLayer = window.dataLayer || [];
|
|
function gtag(){dataLayer.push(arguments);}
|
|
gtag('js', new Date());
|
|
gtag('config', '${process.env.NEXT_PUBLIC_GA_TRACKING_ID}', {
|
|
page_path: window.location.pathname,
|
|
});
|
|
`}
|
|
</Script>
|
|
</>
|
|
);
|
|
}
|