Vuejs Event tracking using Google analytics Vuejs Event tracking using Google analytics vue.js vue.js

Vuejs Event tracking using Google analytics


I ended up using vue-analytics . There is Easy to follow documentation from the author

Update: The author has stopped maintaining the package and recommended using another new package he has built called vue-gtag. If you are using Vue2, use this branch instead.


I suggest giving Segment a try to enable analytics onto your Vue app! You can add a single line of tracking code and see this data being sent to GA by enabling the destination on our dashboard. Here is an example of using an event handler using our track call:

<template>  <button v-on:click="trackEvent">    {{ title }}  </button></template><script>export default {  name: 'SignupButton',  data() {    return {      title: 'Signup with Segment today!'    }  },  methods: {    trackEvent () {      window.analytics.track('User Signup')    }  }}</script>

I’m the maintainer of https://github.com/segmentio/analytics-vue. With Segment, you’ll be able to switch different destinations on-and-off by the flip of a switch if you are interested in trying multiple analytics tools (we support over 250+ destinations) - without having to write any additional code. 🙂