partytown icon indicating copy to clipboard operation
partytown copied to clipboard

Error GTM with nuxt 3

Open Met96 opened this issue 2 years ago • 4 comments

Hi 😊 I'm trying to implement GTM to nuxt3 using partytown. I've implement script inside nuxt config like below: app: { head: { script: [ { hid: "gtm", src: "https://www.googletagmanager.com/gtm.js?id=GTM-XXXXXX", "data-cookieconsent": "ignore", innerHTML: (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-XXXXXX'); , async: true, type: "text/partytown", }, ], noscript: [ { tagPosition: "bodyOpen", innerHTML: <iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXX" height="0" width="0" style="display:none;visibility:hidden"></iframe>, }, ], } ... modules: { ... "@nuxtjs/partytown", } ... partytown: { debug: true, forward: ["dataLayer.push"], },

And when I launch yarn dev command i have an error "fetch" inside the console like screenshot: Screenshot 2023-01-12 alle 09 56 30

Met96 avatar Jan 12 '23 09:01 Met96

I had the same problem, for me google tag manager links are blocked by my adblocker and that is why the fetch() failed. What happens when you go to the scriptSrc url in your browser?

nielsvanrijn avatar Jan 24 '23 22:01 nielsvanrijn

I have all inside with "src" attribute to type/partytown, but not the other scripts inside I analyzed with attention the funcion on error from partytown and i thinks it's a cookiebot plugin problem.

Met96 avatar Jan 25 '23 19:01 Met96

I don't know if you have resolved it or not yet, but I'm facing the same fetch issue and I'm wondering if a reverse proxy in Partytown would help, someone has already tried this way?

arb85 avatar Sep 16 '23 06:09 arb85

+1

rahulkumarsingh73690 avatar Dec 05 '23 12:12 rahulkumarsingh73690