deco-sites / fashion

The deco.cx Fashion Store Starter
https://fashion.deco.site
76 stars 126 forks source link

Fix SendEventOnLoad to run after the container initialization with GTM #415

Open igorbrasileiro opened 1 year ago

igorbrasileiro commented 1 year ago

What is this issue about?

Some events are being added to dataLayer before the initialization of GTM container or GA config.

How to reproduce it?

Open the home with gtm tag assistant and check the view_item_list event being triggered before the container initialization event.

image

Extra info

Afaik, all gtm events should be fired after container initialization, the container initialization is sent at onload event via Analytics section

igorbrasileiro commented 1 year ago

This issue also happens with the https://github.com/deco-sites/std/blob/main/components/VTEXPortalDataLayerCompatibility.tsx#L103-L106