mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
Merge branch 'main' into fix/local
This commit is contained in:
@@ -1,12 +1,17 @@
|
||||
import { useEffect } from 'react'
|
||||
import { useRouter } from 'next/router'
|
||||
import { siteConfig } from '@/lib/config'
|
||||
import * as gtag from '@/lib/plugins/gtag'
|
||||
|
||||
import { useRouter } from 'next/router'
|
||||
import { useEffect } from 'react'
|
||||
/**
|
||||
* Google Analytics
|
||||
* @returns
|
||||
*/
|
||||
const Gtag = () => {
|
||||
const router = useRouter()
|
||||
const ANALYTICS_GOOGLE_ID = siteConfig('ANALYTICS_GOOGLE_ID')
|
||||
useEffect(() => {
|
||||
const gtagRouteChange = url => {
|
||||
gtag.pageview(url)
|
||||
gtag.pageview(url, ANALYTICS_GOOGLE_ID)
|
||||
}
|
||||
router.events.on('routeChangeComplete', gtagRouteChange)
|
||||
return () => {
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import BLOG from '@/blog.config'
|
||||
|
||||
// https://developers.google.com/analytics/devguides/collection/gtagjs/pages
|
||||
export const pageview = url => {
|
||||
window.gtag('config', BLOG.ANALYTICS_GOOGLE_ID, {
|
||||
export const pageview = (url, ANALYTICS_GOOGLE_ID) => {
|
||||
window.gtag('config', ANALYTICS_GOOGLE_ID, {
|
||||
page_path: url
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user