beyonk-group / svelte-google-analytics

Google Analytics component for Svelte
77 stars 12 forks source link

403 on gtag when using debug_mode: true #12

Closed lalilaloe closed 2 years ago

lalilaloe commented 2 years ago

In my case I had to change the loader url to gtm.js to make debug_mode work. Otherwise a 403 was returned on the loaded url, with google saying I did not have access.

Maybe add an option to use gtm or gtag?

--- a/node_modules/@beyonk/svelte-google-analytics/src/GoogleAnalytics.svelte
+++ b/node_modules/@beyonk/svelte-google-analytics/src/GoogleAnalytics.svelte
@@ -17,7 +17,7 @@
     loader([
       {
         type: 'script',
-        url: `//www.googletagmanager.com/gtag/js?id=${mainProperty}`
+        url: `//www.googletagmanager.com/gtm.js?id=${mainProperty}`
       }
     ],
     test,
antony commented 2 years ago

Do you know what the difference is? Perhaps one is out of date.

dextermb commented 2 years ago

Based on the answer found here. We could potentially look at swapping to gtm although gtag is fully supported. I'd also consider gtag to be lighterweight than gtm.

...both fully supported methods for the deployment of tags for Google products...

Here's what they say about when to use each solution:

Both Tag Manager and gtag.js perform similar functions:

  • Tag Manager is a tag management system that allows you to quickly and easily update tags on your website or mobile app from a web interface.
  • gtag.js is the JavaScript framework that is used to add Google tags directly to web pages.

Feel free to read more on their documentation.

antony commented 2 years ago

I think being able to swap between two is fine. We don't use GTM because people tend to go wild and throw a hundred tracking tags in a page, but if others want to I'm all for it.

dextermb commented 2 years ago

I've enabled debug_mode for our ventures in local development, I don't seem to get a 403 when using gtag therefore I'll close this issue as it may be a config management issue not related to this package.

Of course, @lalilaloe, feel free to re-open if you find it is an issue with the package.