Skip to content

Commit

Permalink
Fix matomo (#488)
Browse files Browse the repository at this point in the history
  • Loading branch information
gvdongen authored Nov 29, 2024
1 parent f581721 commit 8a37a84
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ const config = {
locales: ["en"],
},

clientModules: ['./matomo.js'],

presets: [
[
"classic",
Expand Down
30 changes: 30 additions & 0 deletions matomo.js
Original file line number Diff line number Diff line change
@@ -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);
})();
},
};
})();

0 comments on commit 8a37a84

Please sign in to comment.