-
Hi, nuxt-umami: 2.2.0 Im transitioning from v1 to v2 of this lib, and I cannot get it working in Middleware. I want to call umami endpoint only on certain routes. umami.global.js const excludedRoutes = [
'dashboard',
//
]
export default defineNuxtRouteMiddleware((to, from) => {
if (excludedRoutes.includes(to.name)) {
return
}
const { $umami } = useNuxtApp()
$umami.umTrackView(to.href)
}) Getting this error:
Could you please suggest how to limit umami per route or how to call this func in middleware? Thank you |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi, @tasiotas.
const excludedRoutes = [ 'dashboard' ]
export default defineNuxtRouteMiddleware((to, from) => {
if (excludedRoutes.includes(to.name)) { return }
umTrackView(to.href)
} |
Beta Was this translation helpful? Give feedback.
-
thank you very much, that did the job. |
Beta Was this translation helpful? Give feedback.
Hi, @tasiotas.
umTrackView
is already auto-imported, all you have to do is call it. Make sure to disable autoTrack first.