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">
/* Insert GTM Script Here */
</script>
Google Analytics 4 (GA4)
When using Google Analytics, it’s recommended to use Google Analytics 4. Not only is GA4 Google’s official recommendation, but it’s also because the GA4 responses come with the correct CORS headers. Simply put, if you ensure you’re using GA4, you will not have to proxy the requests to www.google-analytics.com
.
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.