gtm-support / vue-gtm

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

Bug: My GTM tag starts with G instead of GTM #338

Closed turanibrahim closed 1 year ago

turanibrahim commented 1 year ago

Info

Tool Version
Plugin v2.0.0
Vue v3.2.45
Node v18.12.1
OS mac

Input

app.use(
    createGtm({
      id: 'G-XXXX,
      queryParams: {
        gtm_auth: 'AB7cDEf3GHIjkl-MnOP8qr',
        gtm_preview: 'env-4',
        gtm_cookies_win: 'x',
      },
      defer: false,
      compatibility: false,
      nonce: '2726c7f26c',
      enabled: true,
      vueRouter: router,
    }),
  );

Output or Error

index.js:6 Uncaught Error: 'G-F7Q3NEJYHL' is not a valid GTM-ID (/^GTM-[0-9A-Z]+$/). Did you mean 'GTM-F7Q3NEJYHL'?
    at assertIsGtmId (index.js:6:11)
    at new GtmSupport (index.js:66:7)
    at install (index.js:7:15)
    at Object.install (index.js:90:30)
    at Object.use (runtime-core.esm-bundler.js:4381:28)
    at initGTM (vueGTM.js?t=1675611482495:4:7)
    at main.js?t=1675611482495:16:1

Expected Output

Should work as expected.

Additional Context

I created new google analytics account and google gave me a tag that starts with G-xxx or GT-xxx. When I init plugin with this new tag, plugin gives error but should work as expected. Also, google suggest me to use https://www.googletagmanager.com/gtag/js? instead of plugin uses https://www.googletagmanager.com/gtm.js. I think google made changes on script and tags so, we should adopt plugin to new changes.

Shinigami92 commented 1 year ago

I created new google analytics account [...]

This package is only supporting Google Tag Manage and not Google Analytics Please find an alternative package that fits you needs