- Issue created by @dragos-dumi
Hello. I have a question about the datalayer variable and the gtag function. Is there a specific reason why, even with gtm without gtag enabled, the datalayer events are pushed via gtag function instead directly via datalayer variable?
The main difference between them is that with gtag() you get Arguments, and if you'd push directly via datalayer, you'd get an object. And then when extracting them in gtm data layer variables in the container, you must use eventModel to get the data of the objects; instead of direct key path to the desired variable.
The problem comes that eventModel.[property] overwrites the tagged variable on each event, regardless if the property exists or not in the new event. Whereas with the direct path to the property, if the next event does not have the same keys, it will not overwrite the variables.
Not saying that is wrong, but I do have a debate with someone saying it is not the correct way to use gtag(), if you use gtm only; and was wondering if the gtag function was chosen with a certain purpose or just because google suggests it for gtag and to have same funtions for any of the options?
Thanks,
Active
2.0
Code