matomo.client.ts 941 B

12345678910111213141516171819202122232425262728
  1. // <noscript><p><img src="https://matomo.morpheu5.net/matomo.php?idsite=1&amp;rec=1" style="border:0;" alt="" /></p></noscript>
  2. import { ConsentStore } from "~~/types";
  3. export default defineNuxtPlugin(_nuxtApp => {
  4. const consentStore = useCookie('consent-store').value as ConsentStore;
  5. const analytics = consentStore?.analytics;
  6. if (analytics || true) {
  7. const u = "https://matomo.morpheu5.net/";
  8. const _paq = window._paq = window._paq || [];
  9. _paq.push(['requireCookieConsent']);
  10. _paq.push(['trackPageView']);
  11. _paq.push(['enableLinkTracking']);
  12. _paq.push(['setTrackerUrl', `${u}matomo.php`]);
  13. _paq.push(['setSiteId', process.dev ? '3' : '1']);
  14. useHead({
  15. script: [
  16. {
  17. src: `${u}matomo.js`,
  18. body: true,
  19. async: true,
  20. }
  21. ]
  22. });
  23. }
  24. });