From 34e13598720d51facd9f8e25dc6d609b1128550e Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Mon, 18 Oct 2021 00:50:24 -0400 Subject: [PATCH] fix ga --- src/App.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 01d26d1..93069d6 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -37,14 +37,17 @@ if (prod) { function App(props: RouteComponentProps) { const [navOpen, setNavOpen] = useState(false); const { user } = useUser(); + function logAnalytics() { + if (prod && !(user?.admin)) { + ReactGA.pageview(window.location.pathname); + }; + } useEffect(() => { - ReactGA.pageview(window.location.pathname); + logAnalytics(); }, []); useEffect(() => { window.scroll(0, 0); - if (prod && !(user?.admin)) { - ReactGA.pageview(window.location.pathname); - } + logAnalytics(); }, [props.location.pathname, user]); return ( <>