Skip to content

Commit

Permalink
feat: google analytics 4 (#125)
Browse files Browse the repository at this point in the history
* feat: google analytics 4

* chore: update `next@14` and install `@next/third-parties`
  • Loading branch information
lumirlumir authored Oct 28, 2024
1 parent b5aeed8 commit 9fca1de
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 45 deletions.
108 changes: 64 additions & 44 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@
},
"dependencies": {
"@giscus/react": "^3.0.0",
"@next/third-parties": "^14.2.16",
"@vercel/analytics": "^1.3.2",
"@vercel/speed-insights": "^1.0.14",
"gray-matter": "^4.0.3",
"html-react-parser": "^5.1.18",
"katex": "^0.16.11",
"next": "^14.2.15",
"next": "^14.2.16",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-icons": "^5.3.0",
Expand Down
3 changes: 3 additions & 0 deletions src/app/layout.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Analytics } from '@vercel/analytics/react';
import { SpeedInsights } from '@vercel/speed-insights/next';
import { GoogleAnalytics } from '@next/third-parties/google';

import ThemeProvider from '@/components/common/ThemeProvider';
import ThemeScript from '@/components/common/ThemeScript';
Expand All @@ -16,6 +17,7 @@ import Profile from '@/components/aside/Profile/Profile';
import DarkModeToggle from '@/components/header/DarkModeToggle';
import Title from '@/components/header/Title';

import { GOOGLE_GA_ID } from '@/constants';
import { getGithubUsers } from '@/utils/fetch';

import '@/styles/global.scss';
Expand Down Expand Up @@ -52,6 +54,7 @@ export default function RootLayout({ children }) {

<Analytics />
<SpeedInsights />
<GoogleAnalytics gaId={GOOGLE_GA_ID} />
</Body>
</ThemeProvider>
</html>
Expand Down
3 changes: 3 additions & 0 deletions src/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ export const PATH_DOCS = join(process.cwd(), 'src', 'posts', 'docs');
// Extension
export const EXT_MD = '.md';
export const EXT_MD_REGEXP = new RegExp(`${EXT_MD}$`, 'i');

// Google
export const GOOGLE_GA_ID = 'G-2G4YHTE048';

0 comments on commit 9fca1de

Please sign in to comment.