Skip to content

[🐞] CORS error for Google Tag Manager Service Worker #635

@brandonfredericksen

Description

@brandonfredericksen

Describe the bug

I'm getting the following CORS error when using Partytown and Google Tag Manager.

Access to XMLHttpRequest at 'https://www.googletagmanager.com/static/service_worker/4al0/sw_iframe.html?origin=https%3A%2F%2Fwww.url.com' from origin 'https://www.url.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

image

Error happens in production as well.

Current implementation:

<Partytown
  debug={false}
  forward={['dataLayer.push']}
  loadScriptsOnMainThread={[
    'https://googleads.g.doubleclick.net/pagead/viewthroughconversion',
  ]}
/>

I'm using Remix. I've tried adding the url to the loadScriptsOnMainThread without success:

<Partytown
  debug={false}
  forward={['dataLayer.push']}
  loadScriptsOnMainThread={[
    'https://googleads.g.doubleclick.net/pagead/viewthroughconversion',
    'https://www.googletagmanager.com/static/service_worker', // doesn't work
  ]}
/>

Reproduction

private

Steps to reproduce

Use Partytown with Google Tag Manager

Browser Info

Chrome

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions