maxandriani / ngx-google-analytics

An easy way to use and configure Google Analytics on Angular 6+ applications
MIT License
120 stars 49 forks source link

Google Tag Manager Question #121

Open acmadden opened 1 year ago

acmadden commented 1 year ago

Hey everyone,

I have a question about using this package with Google Tag Manager versus Global Site Tag.

Since the library allows me to pass the uri within the config options along with the trackingCode, I can connect Google Tag Manager (https://googletagmanager.com/gtm...) instead of the Global Site Tag (https://googletagmanager.com/gtag...).

{
  trackingCode: "MY_GTM_ID",
  uri: "https://googletagmanager.com/gtm.js?id=MY_GTM_ID"
}

To the best of my knowledge, both Google Tag Manager and Global Site Tag use the same data layer. I tested this theory by previewing my site within Tag Assistant with the above configuration. Everything appeared to work as expected (e.g., page_view event fired on route change, etc.).

I'm wondering if anyone has done something similar or advises against doing this.

Thanks!

P.S. Love this package. Well documented and easy to follow the internals.

hakimio commented 11 months ago

This will just work without any issues like in your test.

BTW, I have forked the library and published a new version of the library for Angular 16: Release announcement Installation and usage