BuilderIO / partytown

Relocate resource intensive third-party scripts off of the main thread and into a web worker. 🎉
https://partytown.builder.io
MIT License
12.88k stars 427 forks source link

[🐞] TypeError: Failed to fetch using GTM #455

Open AbrahamIQConsulting opened 11 months ago

AbrahamIQConsulting commented 11 months ago

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

thejackshelton commented 10 months ago

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?

AbrahamIQConsulting commented 10 months ago

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

hippee-lee commented 5 months ago

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",
gioboa commented 5 months ago

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

hippee-lee commented 5 months ago

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.