gtm-support/vue-gtm

Bug: ID from Google Analytics 4 doesn't work

wolmi opened this issue · 4 comments

wolmi commented

Info

Tool Version
Plugin v2.x.x
Vue v2.x.x

The ID generated on Google Analytics 4 is not supported because the ID starts only with G and the regex that validates the ID only supports ID starting with GTM

Input

Environment variable
VUE_APP_GTM_ID=G-XXXXXXXXX

Vue.use(VueGtm, {
  id: process.env.VUE_APP_GTM_ID,
  vueRouter: router
});

Output or Error

Uncaught Error: 'G-XXXXXXXXX' is not a valid GTM-ID (/^GTM-[0-9A-Z]+$/). Did you mean 'GTM-XXXXXXXXX'?
wolmi commented

if it's just a matter of the regex that validates the ID maybe the next regex will fix it:

^(GTM|G)-[0-9A-Z]+$

This plugin is only for Google Tag Manager and not for Google Analytics!
Please search for another plugin alternative

wolmi commented

Ok, but Google analysts is telling me to configure Google Tags using the G-XXXXXX it seems Google analytics 4 is unified with Google tags?

Ok, but Google analysts is telling me to configure Google Tags using the G-XXXXXX it seems Google analytics 4 is unified with Google tags?

If that's how it is, then we might need to fork this repo or setup a complete new one 🤔

I historically took this repo just over to maintain it (fix bugs and fix vulnerabilities and such)
But I have too much other stuff to do and I'm not involved in using GTM or GA for my self at all, so I don't benefit (anymore) from it

I'm not sure if just changing the RegEx will solve your issue because the handling of e.g. tracking events or anything like that could potentially be totally different.
But I'm not interested into digging into that because of the upper written reasons.
If everything is the same and nothing needs to be changed drastically AND it's only for Vue 3+, then I'm open to PRs and can review them.