Skip to content

Commit ee6a5dd

Browse files
authored
✨ - Add Google Analytics Script (#11)
1 parent 8d00c5c commit ee6a5dd

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/app/layout.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { config } from '@fortawesome/fontawesome-svg-core'
33
import '@fortawesome/fontawesome-svg-core/styles.css'
44
import '@/styles/globals.css'
55
import ProfileContainer from '@/components/ProfileContainer'
6+
import GoogleAnalytics from '@/components/GoogleAnalytics'
67
config.autoAddCss = false
78

89
export default function RootLayout({
@@ -25,6 +26,7 @@ export default function RootLayout({
2526
</div>
2627
</div>
2728
</div>
29+
<GoogleAnalytics />
2830
</body>
2931
</html>
3032
)

src/components/GoogleAnalytics.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
'use client'
2+
import Script from 'next/script'
3+
4+
export default function GoogleAnalytics() {
5+
return (
6+
<>
7+
<Script async src={`https://www.googletagmanager.com/gtag/js?id=G-9JLBHQ70PM`} />
8+
<Script id="ga-script">
9+
{`
10+
window.dataLayer = window.dataLayer || [];
11+
function gtag(){dataLayer.push(arguments);}
12+
gtag('js', new Date());
13+
14+
gtag('config', 'G-9JLBHQ70PM');
15+
`}
16+
</Script>
17+
</>
18+
)
19+
}

0 commit comments

Comments
 (0)