diff --git a/docusaurus.config.js b/docusaurus.config.js index f7ce94e..f86f571 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -47,6 +47,9 @@ const config = { theme: { customCss: './src/css/custom.css', }, + googleTagManager: { + containerId: 'GTM-KMKCCQD4' + } }), ], ], diff --git a/package-lock.json b/package-lock.json index b12a3e8..9d97a0f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,6 +7,7 @@ "dependencies": { "@docusaurus/core": "^3.10.1", "@docusaurus/faster": "^3.10.1", + "@docusaurus/plugin-google-tag-manager": "^3.10.1", "@docusaurus/preset-classic": "^3.10.1", "@docusaurus/theme-common": "^3.10.1", "@docusaurus/theme-mermaid": "^3.10.1", diff --git a/package.json b/package.json index 0d84d51..15bd5d2 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "dependencies": { "@docusaurus/core": "^3.10.1", "@docusaurus/faster": "^3.10.1", + "@docusaurus/plugin-google-tag-manager": "^3.10.1", "@docusaurus/preset-classic": "^3.10.1", "@docusaurus/theme-common": "^3.10.1", "@docusaurus/theme-mermaid": "^3.10.1", diff --git a/src/theme/Root/index.js b/src/theme/Root/index.js new file mode 100644 index 0000000..c22c998 --- /dev/null +++ b/src/theme/Root/index.js @@ -0,0 +1,15 @@ +import React from 'react'; +import { useLocation } from '@docusaurus/router'; +import * as CookieConsent from 'vanilla-cookieconsent'; + +export default function Root({ children }) { + const location = useLocation(); + + React.useEffect(() => { + if (CookieConsent.acceptedCategory('analytics') && window.dataLayer) { + window.dataLayer.push({event: 'pageview'}); + } + }, [location]); + + return <>{children}; +}