BuilderIO / partytown

Relocate resource intensive third-party scripts off of the main thread and into a web worker. 🎉
https://partytown.builder.io
MIT License
13.05k stars 433 forks source link

How to access dataLayer object when using Google Tag Manager #50

Closed hafeyang closed 2 years ago

hafeyang commented 2 years ago

when i browse demo of https://partytown.builder.io/example/ i found window.dataLayer object is missed i guess gtag script runs in service worker. but ,what i should do when tracking custom event such as dataLayer.push({'event': 'event_name'});?

hafeyang commented 2 years ago

i got it

partytown  = {forward:["dataLayer.push"]}; 

works