elgorditosalsero / react-gtm-hook

Easily manage the Google Tag Manager via Hook
https://elgorditosalsero-react-gtm-hook.netlify.app/
MIT License
220 stars 28 forks source link

Don't push undefined datalayer during initialization #48

Closed cristianlivella closed 2 years ago

cristianlivella commented 2 years ago

If in the state passed to the GTMProvider component the attribute dataLayer is not set, during the initialization an undefined item is pushed in the dataLayer.

I cannot find information regarding how bad it is to do this (GTM seems working without any problem), but surely it is useless and it causes some problems with some Chrome extensions, such as Datalayer Checker and Adswerve - dataLayer Inspector+ .