event

Options API

export default {
  name: 'MyComponent',

  methods: {
    track () {
      this.$gtag.event('aaa', {
        'event_category' : 'bbb',
        'event_label' : 'ccc'
      })
    }
  }
}

Composition API

import { useGtag } from "vue-gtag-next";

export default {
  name: "MyComponent",

  setup() {
    const { event } = useGtag()
    const track = () => {
      event('aaa', {
        'event_category' : 'bbb',
        'event_label' : 'ccc'
      })
    };

    return {
      track,
    };
  },
};

Remember, this is just an example. check the all API parameters in the official gtag documentation here

Last updated