Skip to content

Commit 31b7881

Browse files
authored
Add GA4 tag to react.dev (#6350)
1 parent e85b71d commit 31b7881

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/pages/_document.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ const MyDocument = () => {
99
return (
1010
<Html lang={siteConfig.languageCode} dir={siteConfig.isRTL ? 'rtl' : 'ltr'}>
1111
<Head />
12+
<script
13+
async
14+
src={`https://www.googletagmanager.com/gtag/js?id=${siteConfig.googleAnalyticsTagId}`}
15+
/>
16+
<script
17+
dangerouslySetInnerHTML={{
18+
__html: `window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}gtag('js', new Date());gtag('config', '${siteConfig.googleAnalyticsTagId}');`,
19+
}}
20+
/>
1221
<body className="font-text font-medium antialiased text-lg bg-wash dark:bg-wash-dark text-secondary dark:text-secondary-dark leading-base">
1322
<script
1423
dangerouslySetInnerHTML={{

src/siteConfig.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ exports.siteConfig = {
1717
apiKey: 'e8451218980a351815563de007648b00',
1818
indexName: 'beta-react',
1919
},
20+
googleAnalyticsTagId: 'G-B1E83PJ3RT',
2021
};

0 commit comments

Comments
 (0)