Both Tag Manager and gtag.js perform similar functions:
- Tag Manager is a tag management system that allows you to quickly and easily update tags on your website or mobile app from a web interface.
- gtag.js is the JavaScript framework that is used to add Google tags directly to web pages.
Both solutions are built on the same core Google infrastructure, and are interoperable. You are free to choose the solution that best suits your needs.
Consider Tag Manager if you need:
- The ability to deploy and modify both Google and 3rd party tags
- The ability to deploy and modify tags for both web and mobile apps
- The ability to deploy and modify tags on the fly from a web interface
- Collaboration and versioning capabilities
Consider gtag.js if you are unable to use Google Tag Manager, or the following capabilities are important to you:
- The ability to install tags directly on your web page, without the ramp-up time of setting up a tag management system
- The ability to work with your tags directly in JavaScript without being required to work with a separate interface
https://support.google.com/tagmanager/answer/7582054?hl=en
Answer from Michele Pisani on Stack OverflowVideos
I have a web design agency and on all my clients websites I have Google analytic property and GA4 via gtag.js script. I recently learned more about GTM and realizing it makes more sense to add the GTM tag and then add GA4 via GTM. How do I go about doing this?
I have setup a GTM account and working on 1st website right now and created an Account and container for that website and added container tag code to the website. I also added a 'Google Tag.' Should I now remove the gtag.js script from the site and add another tag via GTM for google analytics?
No. But you can create an Adwords conversion tag within GTM (there is a template for this, the part before the slash is the conversion id, the part after the slash the conversion label). If you want you can configure the tag via the dataLayer, but you'd still have to create a tag within GTM and apply a trigger to make this work.
Gtag.js is great for sites that don't use tag management systems. If you use GTM, then use GTM triggers and tag templates for adwords to accomplish your measurement needs.
Gtag.js will be the library that replaces analytics.js, and thus replace the ga('send') type of measurement code. You have likely replaced that syntax with the GTM GA tag templates and triggers like "All Pages".