Skip to content

Commit 1f7d866

Browse files
author
iitzIrFan
committed
feat: add Google Analytics integration to Docusaurus configuration
1 parent 986f220 commit 1f7d866

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

docusaurus.config.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,32 @@ const config: Config = {
2020
onBrokenLinks: "throw",
2121
onBrokenMarkdownLinks: "warn",
2222

23+
// Google Analytics
24+
scripts: [
25+
{
26+
src: 'https://www.googletagmanager.com/gtag/js?id=G-W02Z2VJYCR',
27+
async: true,
28+
},
29+
{
30+
content: `
31+
window.dataLayer = window.dataLayer || [];
32+
function gtag(){dataLayer.push(arguments);}
33+
gtag('js', new Date());
34+
gtag('config', 'G-W02Z2VJYCR', {
35+
debug_mode: ${process.env.NODE_ENV !== 'production' ? 'true' : 'false'}
36+
});
37+
`,
38+
},
39+
],
40+
2341
i18n: {
2442
defaultLocale: "en",
2543
locales: ["en"],
2644
},
2745

2846
presets: [
2947
[
30-
"classic",
48+
'classic',
3149
{
3250
docs: {
3351
sidebarPath: require.resolve("./sidebars.ts"),

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"dependencies": {
1818
"@docusaurus/core": "3.7.0",
1919
"@docusaurus/plugin-content-docs": "3.7.0",
20+
"@docusaurus/plugin-google-analytics": "^3.8.1",
2021
"@docusaurus/plugin-ideal-image": "3.7.0",
2122
"@docusaurus/preset-classic": "3.7.0",
2223
"@docusaurus/theme-mermaid": "3.7.0",

0 commit comments

Comments
 (0)