File tree Expand file tree Collapse file tree 3 files changed +30
-38
lines changed Expand file tree Collapse file tree 3 files changed +30
-38
lines changed Original file line number Diff line number Diff line change 11import Script from 'next/script' ;
22
3- declare global {
4- interface Window {
5- gtag : ( ...args : any [ ] ) => void ;
6- }
7- }
8-
9- const GoogleAnalytics = ( ) => {
10- return (
11- < >
12- < Script
13- strategy = "afterInteractive"
14- src = "https://www.googletagmanager.com/gtag/js?id=G-G1T9SRFV67"
15- async
16- />
17- < Script
18- id = "google-analytics"
19- strategy = "afterInteractive"
20- dangerouslySetInnerHTML = { {
21- __html : `
22- window.dataLayer = window.dataLayer || [];
23- function gtag(){dataLayer.push(arguments);}
24- gtag('js', new Date());
25- gtag('config', 'G-G1T9SRFV67');
26- ` ,
27- } }
28- />
29- </ >
30- ) ;
31- } ;
3+ const GoogleAnalytics = ( ) => (
4+ < >
5+ < Script
6+ strategy = "afterInteractive"
7+ src = "https://www.googletagmanager.com/gtag/js?id=G-G1T9SRFV67"
8+ async
9+ />
10+ < Script
11+ id = "google-analytics"
12+ strategy = "afterInteractive"
13+ dangerouslySetInnerHTML = { {
14+ __html : `
15+ window.dataLayer = window.dataLayer || [];
16+ function gtag(){dataLayer.push(arguments);}
17+ gtag('js', new Date());
18+ gtag('config', 'G-G1T9SRFV67');
19+ ` ,
20+ } }
21+ />
22+ </ >
23+ ) ;
3224
3325export default GoogleAnalytics ;
Original file line number Diff line number Diff line change 11import type { Metadata } from "next" ;
22import { Inter , Roboto } from "next/font/google" ;
33import "./globals.css" ;
4- import Header from "@ /components/Header" ;
4+ import Header from ". /components/header /Header" ;
55import Footer from "@/components/Footer" ;
66import GoogleAnalytics from "./components/GoogleAnalytics" ;
7- import GoogleTagManager from "./components/GoogleTagManager" ;
87
98const inter = Inter ( {
109 variable : "--font-inter" ,
@@ -29,12 +28,7 @@ export default function RootLayout({
2928} > ) {
3029 return (
3130 < html lang = "es" >
32- < head >
33- < GoogleTagManager gtmId = "GTM-XXXXXXX" />
34- </ head >
35- < body
36- className = { `${ inter . variable } ${ roboto . variable } antialiased` }
37- >
31+ < body className = { `${ inter . variable } ${ roboto . variable } antialiased` } >
3832 < GoogleAnalytics />
3933 < Header />
4034 { children }
Original file line number Diff line number Diff line change 1+ declare global {
2+ interface Window {
3+ gtag : ( ...args : any [ ] ) => void ;
4+ }
5+ }
6+
17// Track page views
28export const pageview = ( url : string ) => {
39 if ( typeof window . gtag !== 'undefined' ) {
4- window . gtag ( 'config' , process . env . NEXT_PUBLIC_GA_MEASUREMENT_ID as string , {
10+ window . gtag ( 'config' , 'G-G1T9SRFV67' , {
511 page_path : url ,
612 } ) ;
713 }
You can’t perform that action at this time.
0 commit comments