Magento gives dynamic code snippets by the setup. It needs to add a GTM account container id into the configuration and Magento will make a dynamic GTM code bit using that container id and set it on every single page of the Magento site.