Google Tag Manager

Add the Google Tag Manager Script

Partytown Script

Set the script element’s type attribute to text/partytown. For example:

  <script type="text/partytown" src=""></script>
  <script type="text/partytown">
    window.dataLayer = window.dataLayer || [];
    window.gtag = function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());

    gtag('config', 'YOUR-ID-HERE');

Google Analytics 4 (GA4)

GA4 responses come with the correct CORS headers, so you will not have to proxy the requests to Older versions of Google Analytics required proxying, but have been sunset by Google and are no longer supported.

Forward Events

Google Tag Manager uses the dataLayer array to send events. In order for Partytown to forward the calls to window.dataLayer.push({..}), the forward config should add "dataLayer.push". Please see forwarding events and triggers for more information.

Example Config

  "forward": ["dataLayer.push"]

Please see the integration docs for framework specific configuration.

Made with ❤️ by

© 2024, Inc.

Introducing Visual Copilot.

100% free. Supports all popular frameworks.

Try Visual Copilot