File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import Script from "next/script" ;
2-
31const measurementId = process . env . NEXT_PUBLIC_GA_ID || "G-VWDH18RX25" ;
42
53export default function GoogleAnalytics ( ) {
64 return (
75 < >
8- < Script
6+ < script
7+ id = "google-analytics-init"
8+ dangerouslySetInnerHTML = { {
9+ __html : `window.dataLayer = window.dataLayer || [];
10+ window.gtag = window.gtag || function(...args) { window.dataLayer.push(args); };
11+ window.gtag('js', new Date());
12+ window.gtag('config', ${ JSON . stringify ( measurementId ) } );` ,
13+ } }
14+ />
15+ < script
16+ async
17+ id = "google-analytics"
918 src = { `https://www.googletagmanager.com/gtag/js?id=${ measurementId } ` }
10- strategy = "beforeInteractive"
1119 />
12- < Script id = "google-analytics-init" strategy = "beforeInteractive" >
13- { `window.dataLayer = window.dataLayer || [];
14- window.gtag = window.gtag || function(...args) { window.dataLayer.push(args); };
15- window.gtag('js', new Date());
16- window.gtag('config', '${ measurementId } ');` }
17- </ Script >
1820 </ >
1921 ) ;
2022}
Original file line number Diff line number Diff line change @@ -75,8 +75,10 @@ export default function RootLayout({
7575} ) {
7676 return (
7777 < html lang = "pt-BR" >
78- < body className = { inter . className } suppressHydrationWarning >
78+ < head >
7979 < GoogleAnalytics />
80+ </ head >
81+ < body className = { inter . className } suppressHydrationWarning >
8082 < Script id = "ld-organization" type = "application/ld+json" strategy = "afterInteractive"
8183 dangerouslySetInnerHTML = { { __html : JSON . stringify ( {
8284 '@context' : 'https://schema.org' ,
You can’t perform that action at this time.
0 commit comments