Skip to content

Commit

Permalink
remove google router id
Browse files Browse the repository at this point in the history
  • Loading branch information
PiffPaffM committed Sep 10, 2021
1 parent f4ebe26 commit 724b860
Showing 1 changed file with 1 addition and 25 deletions.
26 changes: 1 addition & 25 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,8 @@
import "../styles/global.css";
import "../styles/prism-theme.css";
import type { AppProps } from "next/app";

import { useEffect } from 'react'
import { useRouter } from 'next/router'

declare const window: any;

function MyApp({ Component, pageProps }: AppProps) {
const router = useRouter()

useEffect(() => {
const handleRouteChange = (url: any) => {
window.gtag('config', process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS, {
page_path: url,
});
}
//When the component is mounted, subscribe to router changes
//and log those page views
router.events.on('routeChangeComplete', handleRouteChange)

// If the component is unmounted, unsubscribe
// from the event with the `off` method
return () => {
router.events.off('routeChangeComplete', handleRouteChange)
}
}, [router.events])

return <Component {...pageProps} />;
}
export default MyApp;
export default MyApp;

0 comments on commit 724b860

Please sign in to comment.