Skip to content

Commit

Permalink
J hardaway add google analytics back (#385)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromehardaway authored Apr 30, 2022
1 parent c1935e6 commit a10cd1a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions .env.local
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ MENTOR_WEBHOOK_ID=
ZIPCODE_GETTER_USERID=
JOBSEARCH_API_ID=
JOBSEARCH_API_KEY=
NEXT_PUBLIC_GOOGLE_ANALYTICS=
16 changes: 16 additions & 0 deletions src/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Head from 'next/head'
import ThemeProvider from '../store/ThemeProvider'
import Nav from '@/components/Nav'
import Footer from '@/components/Footer'
import Script from 'next/script'

// libraries
import 'react-toastify/dist/ReactToastify.css'
Expand Down Expand Up @@ -57,6 +58,21 @@ export default function App({ Component, pageProps }) {
<Footer />
</main>
</ThemeProvider>
<Script
strategy="afterInteractive"
src={`https://www.googletagmanager.com/gtag/js?id=${process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS}`}
/>

<Script id="google-analytics" strategy="lazyOnload">
{`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS}', {
page_path: window.location.pathname,
});
`}
</Script>
</>
)
}

1 comment on commit a10cd1a

@vercel
Copy link

@vercel vercel bot commented on a10cd1a Apr 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.