MatteoGabriele / vue-gtag-next

Global Site Tag plugin for Vue 3 (gtag.js)
MIT License
44 stars 3 forks source link

Which tracking code should I use? #35

Open telisjok opened 2 years ago

telisjok commented 2 years ago

Hi, sorry if my question is silly but I'm wondering, which tracking code should I use?

import { defineNuxtPlugin } from '#app';
import VueGtag from 'vue-gtag-next';

export default defineNuxtPlugin((nuxtApp) => {
  const config = useRuntimeConfig();
  nuxtApp.vueApp.use(VueGtag, {
    property: {
      id: config.public.GOOGLE_ANALYTICS_TRACKING_CODE
    },
    appName: 'Website',
    pageTrackerScreenviewEnabled: true
  }, nuxtApp.vueApp.router);
});

So, should I use the Google Tag Manager Container's code which has the form GTM-XXXXXX or the Google Analytic's GA4 Property Code which has the form XXXXXXXXX (it is just 9 numbers. the universal's analytics code was UA-XXXXXXX-XX).

Thanks in advance.

ricardotjen commented 1 year ago

I personally use the pageview to track all pages that the browsers access...

nuxtApp.vueApp.use(VueGtag, {
    property : {
        id : "Xxxxxx",
        params : {
            send_page_view : true --> by default it is false. 
        }
    },
ltroya-as commented 10 months ago

The GTM tag seems to not work because the GTM installation code is different.

I use the G-(GA4) property code to track all my data and custom events. But I am figuring out how to add GTM using this library because I need to add custom events with custom params, and (not completely sure) I need to setup GTM in order to do that