Replies: 2 comments 4 replies
-
|
Beta Was this translation helpful? Give feedback.
-
In case anyone comes here like I did I have Vite 2.0.0-alpha2 Best way was this, in // Basic code
export default {
extends: DefaultTheme,
Layout: () => {
return h(DefaultTheme.Layout, null, {
// https://vitepress.dev/guide/extending-default-theme#layout-slots
})
},
enhanceApp({ app, router, siteData }) {
// ...
},
// My code
setup(app) {
onMounted(() => {
// Matomo's JS code
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//matomo.host.someting/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '123']);
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);
})();
// end of Matomo's code
})
}
// End of my code
} satisfies Theme I'm a still Vue/Vite newbie so I had a lot to figure out to workaround this simple feature. Please let me know if anything seems wrong to you |
Beta Was this translation helpful? Give feedback.
-
Hello there, I'm trying to inject Matomo's Vue tracker inside my template but failing.
I managed to create a custom theme by having a custom
MyLayout.vue
but I'm unable to inject thevue-matomo
component inside my Layout's Slot.Any idea on how to load the component, by using the provided example?
Vue.use(VueMatomo, {props: 'myprops'})
Beta Was this translation helpful? Give feedback.
All reactions