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

SSR support added #193

Open jabiinfante opened 7 months ago

jabiinfante commented 7 months ago

First and foremost, thank you for your library. It has proven to be extremely useful.

While implementing Angular SSR (Server-Side Rendering) with @angular-devkit/build-angular:application, we encountered the same issue reported in #159 and #50.

In addition to resolving the "document not defined" error, I found it noteworthy that the SSR functionality appends the

Regarding my contribution, I've made modifications to the addGtmToDom function to differentiate between PlatformServer and PlatformBrowser. Drawing inspiration from the code snippet provided in the Angular Platform Browser's meta service, I incorporated logic to include the