diff --git a/compose/neurosynth-frontend/public/index.html b/compose/neurosynth-frontend/public/index.html index c83086d1..a68345a7 100644 --- a/compose/neurosynth-frontend/public/index.html +++ b/compose/neurosynth-frontend/public/index.html @@ -28,14 +28,12 @@ diff --git a/compose/neurosynth-frontend/src/App.tsx b/compose/neurosynth-frontend/src/App.tsx index cd0aa50e..62f884cd 100644 --- a/compose/neurosynth-frontend/src/App.tsx +++ b/compose/neurosynth-frontend/src/App.tsx @@ -3,11 +3,12 @@ import { IconButton } from '@mui/material'; import { AxiosError } from 'axios'; import useGoogleAnalytics from 'hooks/useGoogleAnalytics'; import { SnackbarKey, SnackbarProvider } from 'notistack'; -import { useRef } from 'react'; +import { useEffect, useRef } from 'react'; import { QueryCache, QueryClient, QueryClientProvider } from 'react-query'; import Navbar from './components/Navbar/Navbar'; import useGetToken from './hooks/useGetToken'; import BaseNavigation from './pages/BaseNavigation/BaseNavigation'; +import { useLocation } from 'react-router-dom'; const queryClient = new QueryClient({ defaultOptions: { @@ -42,6 +43,15 @@ function App() { useGetToken(); useGoogleAnalytics(); + const location = useLocation(); + useEffect(() => { + if (window.gtag) { + window.gtag('event', 'page_view', { + page_path: `${location.pathname}${location.search}`, + }); + } + }, [location]); + const handleCloseSnackbar = (key: SnackbarKey) => (_event: React.MouseEvent) => { if (notistackRef?.current?.closeSnackbar) notistackRef.current?.closeSnackbar(key); };