diff --git a/docusaurus.config.js b/docusaurus.config.js index 09cb7bff..2d795564 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -56,6 +56,8 @@ const config = { locales: ["en"], }, + clientModules: ['./matomo.js'], + presets: [ [ "classic", diff --git a/matomo.js b/matomo.js new file mode 100644 index 00000000..17247415 --- /dev/null +++ b/matomo.js @@ -0,0 +1,30 @@ +import ExecutionEnvironment from "@docusaurus/ExecutionEnvironment"; + +export default (function () { + if (!ExecutionEnvironment.canUseDOM) { + return null; + } + + return { + onRouteUpdate({ location }) { + // ----- + var _paq = window._paq = window._paq || []; + /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ + _paq.push(["setCustomUrl", location.pathname]); + _paq.push(["setDocumentTitle", document.domain + "/" + document.title]); + _paq.push(["setCookieDomain", "*.restate.dev"]); + _paq.push(["setDomains", "*.restate.dev"]); + _paq.push(["setDoNotTrack", true]); + _paq.push(["disableCookies"]); + _paq.push(['trackPageView']); + _paq.push(['enableLinkTracking']); + (function() { + var u="https://restatedev.matomo.cloud/"; + _paq.push(['setTrackerUrl', u+'matomo.php']); + _paq.push(['setSiteId', '1']); + var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; + g.async=true; g.src='https://cdn.matomo.cloud/restatedev.matomo.cloud/matomo.js'; s.parentNode.insertBefore(g,s); + })(); + }, + }; +})(); \ No newline at end of file