File tree Expand file tree Collapse file tree 3 files changed +26
-0
lines changed
Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 11import type { Metadata } from "next" ;
22import { Inter , JetBrains_Mono } from "next/font/google" ;
33import "./globals.css" ;
4+ import GoogleAnalytics from "../components/GoogleAnalytics" ;
45
56const inter = Inter ( {
67 variable : "--font-inter" ,
@@ -26,6 +27,7 @@ export default function RootLayout({
2627 < body
2728 className = { `${ inter . variable } ${ jetbrainsMono . variable } antialiased` }
2829 >
30+ < GoogleAnalytics />
2931 { children }
3032 </ body >
3133 </ html >
Original file line number Diff line number Diff line change 1+ 'use client' ;
2+
3+ import Script from 'next/script' ;
4+
5+ const GA_TRACKING_ID = 'G-B84V644JQH' ;
6+
7+ export default function GoogleAnalytics ( ) {
8+ return (
9+ < >
10+ < Script
11+ src = { `https://www.googletagmanager.com/gtag/js?id=${ GA_TRACKING_ID } ` }
12+ strategy = "afterInteractive"
13+ />
14+ < Script id = "google-analytics" strategy = "afterInteractive" >
15+ { `
16+ window.dataLayer = window.dataLayer || [];
17+ function gtag(){dataLayer.push(arguments);}
18+ gtag('js', new Date());
19+ gtag('config', '${ GA_TRACKING_ID } ');
20+ ` }
21+ </ Script >
22+ </ >
23+ ) ;
24+ }
You can’t perform that action at this time.
0 commit comments