Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@astrojs/partytown: TypeError Failed to fetch when using Google Analytics 4 #9528

Closed
1 task
SuperSandyman opened this issue Dec 27, 2023 · 4 comments
Closed
1 task
Labels
needs response Issue needs response from OP needs triage Issue needs to be triaged

Comments

@SuperSandyman
Copy link

SuperSandyman commented Dec 27, 2023

Astro Info

Astro                    v4.0.7
Node                     v20.9.0
System                   Linux (x64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             @astrojs/tailwind
                         @astrojs/react
                         astro-expressive-code
                         @astrojs/partytown
                         @astrojs/sitemap

If this issue only occurs in one browser, which browser is a problem?

Chrome (MS Edge)

Describe the Bug

When implementing Google Analytics 4 using @astrojs/partytown, the following error appears in the console.

 TypeError: Failed to fetch
    at c064db33-abc4-4bbd-8..11ce4b8b1fd:2:21128
    at rt (c064db33-abc4-4bbd-8..11ce4b8b1fd:2:21531)
(anonymous) @ c064db33-abc4-4bbd-8709-311ce4b8b1fd:2

I also get the following error in the data-pterror of the script tag in .

<script type="text/partytown" src="https://www.googletagmanager.com/gtag/js?id=G-xxxxxx" data-pterror="TypeError: Failed to fetch
    at blob:https://www.sandyman.dev/c064db33-abc4-4bbd-8709-311ce4b8b1fd:2:21128
    at rt (blob:https://www.sandyman.dev/c064db33-abc4-4bbd-8709-311ce4b8b1fd:2:21531)"></script>

Both were displayed in Chromium-based browsers, and only the former in Firefox.

I have tried to reproduce this problem, but Stackblitz could not reproduce it. However, when I ran the code locally, the same problem appeared.

Sorry for my poor English:)

What's the expected result?

Correctly measured number of accesses.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-ysvmcv?file=src%2Fcomponents%2FBaseHead.astro

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Dec 27, 2023
@SuperSandyman SuperSandyman changed the title @astrojs/partytown TypeError Failed to fetch" when using Google Analytics 4 @astrojs/partytown: TypeError Failed to fetch" when using Google Analytics 4 Dec 27, 2023
@SuperSandyman SuperSandyman changed the title @astrojs/partytown: TypeError Failed to fetch" when using Google Analytics 4 @astrojs/partytown: TypeError Failed to fetch when using Google Analytics 4 Dec 27, 2023
@bluwy
Copy link
Member

bluwy commented Dec 27, 2023

Maybe some notes from https://partytown.builder.io/google-tag-manager#forward-events and #8588 might help, but I'm not really sure if @astrojs/partytown is doing something that's causing the error. It seems like a core partytown or configuration issue.

@bluwy bluwy added the needs response Issue needs response from OP label Dec 27, 2023
@lilnasy
Copy link
Contributor

lilnasy commented Dec 27, 2023

@matthewp
Copy link
Contributor

The repro is not using ViewTransitions so this is unrelated to that.

This is an upstream issue, all the integration does is add the script to the page.

Check out the partytown issue tracker, lots of discussions on how to get it to work with GA. For ex. QwikDev/partytown#519

@suhaylmv
Copy link

suhaylmv commented Jan 4, 2024

I think Ublock Origin chrome extension may be causing this for you. I had the same issue and after disabling this extension I stopped getting this error message in the console.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs response Issue needs response from OP needs triage Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

5 participants