jaketrent / html-webpack-template

a better default template for html-webpack-plugin
MIT License
830 stars 139 forks source link

Add support for Google Tag Manager #53

Closed jamesdh closed 6 years ago

jamesdh commented 7 years ago

Similar to current support for Google Analytics. Fixes jaketrent/html-webpack-template#52

For those not in the know, GTM can be used to inject Google Analytics and a number of other services. It allows our analytics and marketing people to easily add or remove tools as needed, and we've used it in the past for Google Analytics, Mixpanel, Intercom, etc.

jamesdh commented 7 years ago

Any opinion for or against this @jaketrent?

jaketrent commented 7 years ago

Hey @jamesdh . Yeah, thanks for the followup.

There are so many cool, interesting scripts that one might put on in their html that I'm hesitant to add support for a specific library/feature at this point. I'm more inclined to use the more general scripts option.

What do you think about that?

jamesdh commented 7 years ago

I would normally agree and understand your take on that. The only reason I suggest this addition is because Google Tag Manager also gives you Google Analytics, and a whole lot more. It supersedes GA and gives you a lot more general purpose functionality and power features. If it were me, I'd include GTM over GA, but I also realize a lot of people prefer the complete simplicity of pure GA. GTM does require a bit more setup on Google's side via their Tag Manager dashboard.

I'm not sure it's possible to support GTM with the templates current config options, given it needs to be loaded before any other resources and also requires the use of a noscript/iframe tag at the beginning of the body. It's not as simple as a script option like GA is.

AndersDJohnson commented 6 years ago

@jamesdh Thanks to @holyfirexx's #62 implementing my #51, you can now inject custom HTML, which you may be able to use for Google Tag Manager code.

jaketrent commented 6 years ago

With generic html snippet injection now possible, I'm going to consider this covered. Please reopen and let me know if not, and we can start the convo back up.