Skip to content

Commit 0ed7f0a

Browse files
feat: add google analytics support
1 parent e34c608 commit 0ed7f0a

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ jobs:
2222
- name: Install dependencies
2323
run: npm ci
2424
- name: Build website
25+
env:
26+
GA_TRACKING_ID: ${{ secrets.GA_TRACKING_ID }}
2527
run: npm run build
2628

2729
- name: Upload Build Artifact

docusaurus.config.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ const config: Config = {
3737
ignorePatterns: ['/tags/**'],
3838
filename: 'sitemap.xml',
3939
},
40+
gtag: {
41+
trackingID: process.env.GA_TRACKING_ID || 'development',
42+
anonymizeIP: true,
43+
},
4044
} satisfies Preset.Options,
4145
],
4246
],
@@ -185,6 +189,13 @@ const config: Config = {
185189
},
186190
],
187191
],
192+
193+
scripts: [
194+
{
195+
src: `https://www.googletagmanager.com/gtag/js?id=${process.env.GA_TRACKING_ID}`,
196+
async: true,
197+
},
198+
],
188199
};
189200

190201
export default config;

0 commit comments

Comments
 (0)