ga analytics merge to develop (#633)

* added analytics

* added analytics snippet

* Reworked GA addition implementation

Co-authored-by: Alec LaLonde <alec@convergencelabs.com>
This commit is contained in:
Mano
2021-06-07 12:59:41 +05:30
committed by Hammad Jutt
parent 8ef1c117c1
commit bebe182b78
2 changed files with 22 additions and 0 deletions

View File

@@ -19,4 +19,5 @@ export const CONFIG = {
brightIdNodeUrl:
process.env.NEXT_BRIGHTID_NODE_URL || 'http:%2f%2fnode.brightid.org',
publicUrl: process.env.NEXT_PUBLIC_VERCEL_URL || 'http://localhost:3000',
gaId: process.env.NEXT_PUBLIC_GA4_ID || undefined,
};

View File

@@ -1,6 +1,8 @@
/* eslint-disable react/no-danger */
import { ChakraProvider, CSSReset, MetaTheme } from '@metafam/ds';
import { MobileFooter } from 'components/MobileFooter';
import { PageHeader } from 'components/PageHeader';
import { CONFIG } from 'config';
import { Web3ContextProvider } from 'contexts/Web3Context';
import Head from 'next/head';
import { WithUrqlProps } from 'next-urql';
@@ -18,6 +20,25 @@ const App: React.FC<WithUrqlProps> = ({
<Head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>MetaGame</title>
{CONFIG.gaId != null && (
<>
<script
async
src={`https://www.googletagmanager.com/gtag/js?id=${CONFIG.gaId}`}
/>
<script
dangerouslySetInnerHTML={{
__html: `
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments)}
gtag('js', new Date());
gtag('config', '${CONFIG.gaId}');
`,
}}
/>
</>
)}
</Head>
<Web3ContextProvider resetUrqlClient={resetUrqlClient}>
<>