matomo.client.ts 888 B

123456789101112131415161718192021222324252627
  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) {
  7. const u = "https://matomo.morpheu5.net/";
  8. const _paq = window._paq = window._paq || [];
  9. _paq.push(['trackPageView']);
  10. _paq.push(['enableLinkTracking']);
  11. _paq.push(['setTrackerUrl', `${u}matomo.php`]);
  12. _paq.push(['setSiteId', process.dev ? '3' : '1']);
  13. useHead({
  14. script: [
  15. {
  16. src: `${u}matomo.js`,
  17. body: true,
  18. async: true,
  19. }
  20. ]
  21. });
  22. }
  23. });