You can create a simple custom module with inside Vendor/Module/view/frontend/layout/default.xml
....
<referenceContainer name="after.body.start">
<block class="Magento\Framework\View\Element\Template" name="google.tag.manager" before="-" template="Vendor_Module::html/tag-manager.phtml" />
</referenceContainer>
...
where tag-manager.phtml
is exactly your google tag manager snippet.
Now youSo you'll have that googlethe tag manager snippet is loadedadded in all pages as first block after body tag open in all pages.