partytown icon indicating copy to clipboard operation
partytown copied to clipboard

[🐞] TypeError: Failed to fetch using GTM

Open AbrahamIQConsulting opened this issue 1 year ago • 6 comments

Describe the bug

Implementing party town with GTM we are seeing this kind of issue:

Reproduction

private integration environment

Steps to reproduce

put type="text/partytown" with the script of GTM

Browser Info

Chrome

Additional Information

No response

AbrahamIQConsulting avatar Sep 01 '23 01:09 AbrahamIQConsulting

Tried to reproduce the issue and I don't see this type error. I've created my own gtag and placed the first item in the head and the noscript a child in the body. Is there anything more specific you can narrow down?

Also it looks like there's no id in this script. Just checking, was that done on purpose?

thejackshelton avatar Sep 01 '23 17:09 thejackshelton

The issue is with Google tag manager (GTM script), are you use gtm.js or gtag.js? @thejackshelton

AbrahamIQConsulting avatar Sep 04 '23 16:09 AbrahamIQConsulting

I ran into this today with an Astro site build. The Astro integration is fine. Getting the loading error after build. Here are my scripts, I think I am using gtag (but not a GA expert by any means):

<script
  type="text/partytown"
  src="https://www.googletagmanager.com/gtag/js?id=<MY_TAG>"></script>
<script type="text/partytown">
  window.dataLayer = window.dataLayer || [];
  function gtag() {
    dataLayer.push(arguments);
  }
  gtag("js", new Date());

  gtag("config", "<MY_TAG>");
</script>

packages:

@astrojs/partytown": "^2.0.4"
"astro": "^4.0.1",

hippee-lee avatar Feb 02 '24 18:02 hippee-lee

I see, there are many Astro site with Partytown so I'm wondering if they have the same problem :thinking: This site is a working example

gioboa avatar Feb 03 '24 08:02 gioboa

Thanks for showing the example. I must be doing something wrong. I'll revisit my implementation and see if I can figure out whats wrong with the above code. It is interesting that the site shown, clears the console (and the error), I haven't seen that before.

hippee-lee avatar Feb 08 '24 16:02 hippee-lee