Skip to content

Umami and vue router #1685

Answered by rene-wastics
rene-wastics asked this question in Q&A
Discussion options

You must be logged in to vote

So, in Vue.js - similar to Angular - it is necessary to disable auto-tracking in Javascript frameworks.
In the index.html set the data-auto-track="false"

<script async defer
  src="http://mywebsite/umami.js"
  data-website-id="94db1cb1-74f4-4a40-ad6c-962362670409"
  data-auto-track="false"
></script>

In your router (i.e. router/index.js) you can track the views in the router.beforeEach method:

router.beforeEach((to, from, next) => {
  // set your website id according to your umami settings
  window.umami.trackView(to.path, null, '94db1cb1-74f4-4a40-ad6c-962362670409')
  next()
}

Hope this helps someone in a similar scenario. Let me know if you have any feedback or a better solution.

--

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by rene-wastics
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants