|
16 | 16 | <link rel="stylesheet" href="/styles.css" /> |
17 | 17 | <link rel="icon" type="image/png" href="images/favicon.png" /> |
18 | 18 | <!-- Matomo --> |
19 | | - <script> |
| 19 | + <!-- <script> |
20 | 20 | var _paq = (window._paq = window._paq || []); |
21 | 21 | _paq.push(["disableCookies"]); // Call disableCookies before calling trackPageView |
22 | 22 | /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ |
|
38 | 38 | _paq.push(["setDocumentTitle", document.title]); |
39 | 39 | _paq.push(["trackPageView"]); |
40 | 40 | }); |
41 | | - </script> |
| 41 | + </script> --> |
42 | 42 | <!-- End Matomo Code --> |
43 | 43 | </head> |
44 | 44 |
|
|
54 | 54 | "/.*/_sidebar.md": "/_sidebar.md", |
55 | 55 | }, |
56 | 56 | relativePath: true, |
| 57 | + matomo: { |
| 58 | + host: "//matomo.research.software", |
| 59 | + id: 5, |
| 60 | + disableCookies: true, |
| 61 | + }, |
57 | 62 | }; |
58 | 63 | </script> |
59 | 64 | <script src="https://cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script> |
60 | 65 | <script src="https://cdn.jsdelivr.net/npm/docsify/lib/plugins/external-script.min.js"></script> |
61 | 66 | <script src="https://cdn.jsdelivr.net/npm/docsify/lib/plugins/search.min.js"></script> |
62 | 67 | <script src="https://cdn.jsdelivr.net/npm/prismjs/components/prism-bash.min.js"></script> |
| 68 | + <!-- custom version of Matomo plugin, modified from https://github.com/docsifyjs/docsify/blob/develop/src/plugins/matomo.js --> |
| 69 | + <script> |
| 70 | + function appendScript(options) { |
| 71 | + const script = document.createElement("script"); |
| 72 | + script.async = true; |
| 73 | + script.src = options.host + "/matomo.js"; |
| 74 | + document.body.appendChild(script); |
| 75 | + } |
| 76 | + |
| 77 | + function init(options) { |
| 78 | + window._paq = window._paq || []; |
| 79 | + if (options.disableCookies) { |
| 80 | + window._paq.push(["disableCookies"]); // Call disableCookies before calling trackPageView |
| 81 | + } |
| 82 | + // window._paq.push(["trackPageView"]); |
| 83 | + window._paq.push(["enableLinkTracking"]); |
| 84 | + setTimeout(() => { |
| 85 | + appendScript(options); |
| 86 | + window._paq.push(["setTrackerUrl", options.host + "/matomo.php"]); |
| 87 | + window._paq.push(["setSiteId", String(options.id)]); |
| 88 | + }, 0); |
| 89 | + } |
| 90 | + |
| 91 | + function collect() { |
| 92 | + if (!window._paq) { |
| 93 | + init($docsify.matomo); |
| 94 | + } |
| 95 | + |
| 96 | + window._paq.push(["setCustomUrl", "/" + window.location.hash]); |
| 97 | + window._paq.push(["setDocumentTitle", document.title]); |
| 98 | + window._paq.push(["trackPageView"]); |
| 99 | + } |
| 100 | + |
| 101 | + const install = function (hook) { |
| 102 | + if (!$docsify.matomo) { |
| 103 | + // eslint-disable-next-line no-console |
| 104 | + console.error("[Docsify] matomo is required."); |
| 105 | + return; |
| 106 | + } |
| 107 | + |
| 108 | + hook.doneEach(collect); |
| 109 | + }; |
| 110 | + |
| 111 | + window.$docsify = window.$docsify || {}; |
| 112 | + $docsify.plugins = [install, ...($docsify.plugins || [])]; |
| 113 | + </script> |
63 | 114 | </body> |
64 | 115 | </html> |
0 commit comments