pageview

Options API

export default {
  name: 'MyComponent',

  methods: {
    track () {
      this.$gtag.pageview({
        page_path: '/about',
      })
    }
  }
}

Composition API

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

export default {
  name: "MyComponent",

  setup() {
    const { pageview } = useGtag() 
    const track = () => {
      pageview({ page_path: "/about" });
    };

    return {
      track,
    };
  },
};

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

Last updated