mzuccaroli / angular-google-tag-manager

A service library for integrate google tag manager in your angular project
https://itnext.io/how-to-add-google-tag-manager-to-an-angular-application-fc68624386e2
MIT License
136 stars 78 forks source link

getDataLayer won't work because it expects a type `arguments` not `array` #195

Open worthy7 opened 6 months ago

worthy7 commented 6 months ago

I have been scratching my head for quite some time on this.

When using gtag to try and get a client_id it works, but when trying to use the datalayer directly, it does not. I found this:

image

When using the gtag function, it loads an argument type object into dataLayer. This is different from a normal array. I think whatever javascript is watching the dataLayer array, is only executing on "argument" type values.

For this reason, this packages getDataLayer is not useful right now. I think instead it should do something similar to gtag and provide a gtag function on the service which passses it to datalayer.