MatteoGabriele/vue-gtag-next

Which tracking code should I use?

telisjok opened this issue · 2 comments

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.

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. 
        }
    },

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