Skip to content

Commit 544dc8c

Browse files
committed
www(добавление или удаление функционала): add google GoogleAnalytics
add google GoogleAnalytics
1 parent 1e96ae8 commit 544dc8c

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

www/analytics/google-analytics.tsx

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

www/pages/_app.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {useDocSearch} from "../hooks/use-doc-search";
66
import React from "react";
77
import { MetaMultiDescription } from "../components/meta-multi-description/MetaMultyDescription";
88
import { appConfig } from "../app-config";
9+
import { GoogleAnalytics } from "../analytics/google-analytics";
910

1011
function MyApp({ Component, pageProps }: AppProps) {
1112
useDocSearch();
@@ -14,6 +15,7 @@ function MyApp({ Component, pageProps }: AppProps) {
1415
return (
1516
<BaseAppLayout>
1617
<Head>
18+
<GoogleAnalytics/>
1719
<MetaMultiDescription title={ appConfig.title } description={ appConfig.description }/>
1820
<meta name="yandex-verification" content="d7555ce264b8a099"/>
1921
<meta name="viewport"

0 commit comments

Comments
 (0)