gtm-support / vue-gtm

Simple implementation of Google Tag Manager for Vue
https://www.npmjs.com/package/@gtm-support/vue-gtm
MIT License
192 stars 23 forks source link

Bug: GTM ID is not valid #415

Closed DevAmine closed 1 month ago

DevAmine commented 2 months ago

Info

App won't start if an invalid GTM ID is used in my setup (which, I believe, is a pretty standard setup).

Tool Version
Plugin 2.2.0
Vue v3
Node v16.17.1
OS linux,mac

Input


    createGtm({
      id: "G-XXXXXXXXXX", // Gtm 4 ID
      defer: false, // Script can be set to `defer` to speed up page load at the cost of less accurate results (in case visitor leaves before script is loaded, which is unlikely but possible). Defaults to false, so the script is loaded `async` by default
      compatibility: false, // Will add `async` and `defer` to the script tag to not block requests for old browsers that do not support `async`
      enabled: true, // defaults to true. Plugin can be disabled by setting this to false for Ex: enabled: !!GDPR_Cookie (optional)
      debug: false, // Whether or not display console logs debugs (optional)
      loadScript: true, // Whether or not to load the GTM Script (Helpful if you are including GTM manually, but need the dataLayer functionality in your components) (optional)
      vueRouter: useRouter(), // Pass the router instance to automatically sync with router (optional)
      //ignoredViews: ['homepage'], // Don't trigger events for specified router names (optional)
      trackOnNextTick: true, // Whether or not call trackView in Vue.nextTick
    })

Output or Error


'G-XXXXXXXXXX' is not a valid GTM-ID (/^GTM-[0-9A-Z]+$/).

Expected Output

I would expect a console warning Your are using an invalid GTM ID and the app should load but without GTM. To add support for GTM 4 ID format that starts with G- instead of GTM-

fabianpoels commented 1 month ago

https://github.com/gtm-support/core/pull/427