-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f6f9d8
commit 77ab1c3
Showing
19 changed files
with
26 additions
and
667 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,11 @@ | ||
import type { AppProps } from 'next/app'; | ||
|
||
import { useRouter } from 'next/router'; | ||
|
||
import Script from 'next/script'; | ||
|
||
import * as React from 'react'; | ||
|
||
import '../styles/globals.css'; | ||
|
||
import * as gtag from '../lib/gtag'; | ||
|
||
function App({ Component, pageProps }: AppProps<{ dehydratedState: string }>) { | ||
const getLayout = | ||
(Component as any).getLayout || ((page: React.ReactElement) => page); | ||
|
||
const router = useRouter(); | ||
React.useEffect(() => { | ||
const handleRouteChange = (url: string) => { | ||
gtag.pageview(url); | ||
}; | ||
router.events.on('routeChangeComplete', handleRouteChange); | ||
router.events.on('hashChangeComplete', handleRouteChange); | ||
return () => { | ||
router.events.off('routeChangeComplete', handleRouteChange); | ||
router.events.off('hashChangeComplete', handleRouteChange); | ||
}; | ||
}, [router.events]); | ||
|
||
return ( | ||
<> | ||
{/* Global Site Tag (gtag.js) - Google Analytics */} | ||
<Script | ||
strategy="afterInteractive" | ||
src={`https://www.googletagmanager.com/gtag/js?id=${gtag.GA_TRACKING_ID}`} | ||
/> | ||
<Script | ||
id="gtag-init" | ||
strategy="afterInteractive" | ||
dangerouslySetInnerHTML={{ | ||
__html: ` | ||
window.dataLayer = window.dataLayer || []; | ||
function gtag(){dataLayer.push(arguments);} | ||
gtag('js', new Date()); | ||
gtag('config', '${gtag.GA_TRACKING_ID}', { | ||
page_path: window.location.pathname, | ||
}); | ||
`, | ||
}} | ||
/> | ||
{getLayout(<Component {...pageProps} />)} | ||
</> | ||
); | ||
return <Component {...pageProps} />; | ||
} | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.