Skip to content

Commit 0e44ca1

Browse files
authored
Bring back Google Analytics (#3832)
1 parent a683d90 commit 0e44ca1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

website/src/pages/_app.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { FC } from 'react';
22
import type { AppProps } from 'next/app';
3+
import Script from 'next/script';
34
import { appWithTranslation } from 'next-i18next';
45
import { extendTheme, LinkProps, theme as chakraTheme } from '@chakra-ui/react';
56
import { mode } from '@chakra-ui/theme-tools';
@@ -10,6 +11,7 @@ import {
1011
ExtendComponents,
1112
handlePushRoute,
1213
Link,
14+
useGoogleAnalytics,
1315
} from '@guild-docs/client';
1416
import { FooterExtended, Header, Subheader } from '@theguild/components';
1517
import type { LinkProps as NextLinkProps } from 'next/link';
@@ -81,6 +83,7 @@ const mdxRoutes = { data: serializedMdx && JSON.parse(serializedMdx) };
8183

8284
const AppContent: FC<AppProps> = appProps => {
8385
const { Component, pageProps, router } = appProps;
86+
const analytics = useGoogleAnalytics({ router, trackingId: "G-TPQZLLF5T5" });
8487
const isDocs = router.asPath.startsWith('/docs');
8588

8689
return (
@@ -126,6 +129,8 @@ const AppContent: FC<AppProps> = appProps => {
126129
rel: 'noopener noreferrer',
127130
}}
128131
/>
132+
<Script {...analytics.loadScriptProps} />
133+
<Script {...analytics.configScriptProps} />
129134
{isDocs ? (
130135
<DocsPage appProps={appProps} accentColor={accentColor} mdxRoutes={mdxRoutes} />
131136
) : (

0 commit comments

Comments
 (0)