mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-05 07:26:46 +00:00
Code🤣
This commit is contained in:
18
components/Gtag.js
Normal file
18
components/Gtag.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import { useEffect } from 'react'
|
||||
import { useRouter } from 'next/router'
|
||||
import * as gtag from '@/lib/gtag'
|
||||
|
||||
const Gtag = () => {
|
||||
const router = useRouter()
|
||||
useEffect(() => {
|
||||
const handleRouteChange = url => {
|
||||
gtag.pageview(url)
|
||||
}
|
||||
router.events.on('routeChangeComplete', handleRouteChange)
|
||||
return () => {
|
||||
router.events.off('routeChangeComplete', handleRouteChange)
|
||||
}
|
||||
}, [router.events])
|
||||
return null
|
||||
}
|
||||
export default Gtag
|
||||
Reference in New Issue
Block a user