Skip to content

Commit

Permalink
feat: add Google Analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
SigureMo committed Nov 26, 2023
1 parent 8449b1a commit 8672059
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { withPwa } from '@vite-pwa/vitepress'
const metaInfo = {
title: '飞桨开源社区博客',
description: 'Wonderful stories from PaddlePaddle contributors',
gtagId: 'G-7XR50K1YRK',
}

export default withPwa(
Expand Down Expand Up @@ -53,6 +54,19 @@ export default withPwa(
color: '#ffffff',
},
],
// Google Analytics
[
'script',
{ async: '', src: `https://www.googletagmanager.com/gtag/js?id=${metaInfo.gtagId}` },
],
[
'script',
{},
`window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${metaInfo.gtagId}');`,
],
],
pwa: {
outDir: '.vitepress/dist',
Expand Down

0 comments on commit 8672059

Please sign in to comment.