| | |
| | | })(window, document, "clarity", "script", "${cfg.analytics.projectId}");\` |
| | | document.head.appendChild(clarityScript) |
| | | `) |
| | | } else if (cfg.analytics?.provider === "matomo") { |
| | | componentResources.afterDOMLoaded.push(` |
| | | const matomoScript = document.createElement("script"); |
| | | matomoScript.innerHTML = \` |
| | | let _paq = window._paq = window._paq || []; |
| | | |
| | | // Track SPA navigation |
| | | // https://developer.matomo.org/guides/spa-tracking |
| | | document.addEventListener("nav", () => { |
| | | _paq.push(['setCustomUrl', location.pathname]); |
| | | _paq.push(['setDocumentTitle', document.title]); |
| | | _paq.push(['trackPageView']); |
| | | }); |
| | | |
| | | _paq.push(['trackPageView']); |
| | | _paq.push(['enableLinkTracking']); |
| | | (function() { |
| | | const u="//${cfg.analytics.host}/"; |
| | | _paq.push(['setTrackerUrl', u+'matomo.php']); |
| | | _paq.push(['setSiteId', ${cfg.analytics.siteId}]); |
| | | const d=document, g=d.createElement('script'), s=d.getElementsByTagName |
| | | ('script')[0]; |
| | | g.type='text/javascript'; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); |
| | | })(); |
| | | \` |
| | | document.head.appendChild(matomoScript); |
| | | `) |
| | | } |
| | | |
| | | if (cfg.enableSPA) { |