google-marketing-solutions / ga4-ecom-attributor

Apache License 2.0
70 stars 2 forks source link

Why do we need to dataLayer.push({ ecommerce: null })? #6

Open karthikctelia opened 1 month ago

karthikctelia commented 1 month ago

Why do we always need to do the below before pushing ecommerce event to dataLayer. It doesn't make sense from dataLayer perspective as we just push to dataLayer , it doesn't clear the existing key. It just pushes new object. dataLayer.push({ ecommerce: null }); // Clear the previous ecommerce object. https://developers.google.com/analytics/devguides/collection/ga4/ecommerce?client_type=gtm#view_item-gtm