matomo for vue and basic tracking

This commit is contained in:
2024-03-28 05:49:49 +01:00
parent 19c096bcf6
commit c8ed8c2abe
4 changed files with 10 additions and 16 deletions

View File

@@ -31,6 +31,7 @@
"vee-validate": "^4.12.4",
"vue": "3.3.x",
"vue-google-charts": "^1.1.0",
"vue-matomo": "^4.2.0",
"vue-multiselect": "^3.0.0-beta.3",
"vue3-easy-data-table": "^1.5.47",
"vue3-multiselect-checkboxed": "^0.0.9",

View File

@@ -390,6 +390,8 @@ onMounted(() => {
});
const showRow = async (item) => {
console.log("ITEM=", item);
this.$matomo.trackEvent('Product', 'search', 'text', settingsStore.text);
this.$matomo.trackEvent('Product', 'click', 'code', item.globalCode);
itemCode.value = item.code;
try {

View File

@@ -6,6 +6,7 @@ import { createInertiaApp, usePage } from '@inertiajs/inertia-vue3';
import { InertiaProgress } from '@inertiajs/progress';
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';
import { ZiggyVue } from '../../vendor/tightenco/ziggy/dist/vue.m';
import VueMatomo from 'vue-matomo';
import Themes from './themes'
import Swal from 'sweetalert2';
import { Inertia } from '@inertiajs/inertia';
@@ -30,6 +31,10 @@ createInertiaApp({
return createApp({ render: () => h(app, props) })
.use(plugin)
.use(ZiggyVue, Ziggy)
.use(VueMatomo, {
host: 'https://matomo.soson.eu/',
siteId: '3',
})
.mixin({
methods: {
...commons,
@@ -55,6 +60,8 @@ const Toast = window.Toast = Swal.mixin({
}
})
window._paq.push(['trackPageView']); //To track pageview
Inertia.on('start', commons.authorization)
Inertia.on('finish', commons.authorization)
Inertia.on('finish', () => {

View File

@@ -23,22 +23,6 @@
@routes
@vite('resources/js/app.js')
@inertiaHead
<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://matomo.soson.eu/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '3']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Matomo Code -->
</head>
<body class="font-sans antialiased bg-gray-100 relative min-h-screen">