Skip to main content
added 46 characters in body
Source Link
LucScu
  • 2.4k
  • 28
  • 39

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.

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 tag manager snippet.

Now you have that google tag manager snippet is loaded as first block after body open in all pages.

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.

So you'll have that the tag manager snippet is added in all pages as first block after body tag open.

added 46 characters in body
Source Link
LucScu
  • 2.4k
  • 28
  • 39

JustYou can create a simple custom module with inside Vendor/Module/view/frontend/layout/default.xml with

....
<referenceContainer name="after.body.start">
    <block class="Magento\Framework\View\Element\Template" name="google.tag.manager" before="-" template="Custom_Templatetemplate="Vendor_Module::html/tag-manager.phtml" />
</referenceContainer>
...

where view/frontend/templates/html/tag-manager.phtml is exactly your tag manager snippet.

Now you have that google tag manager snippet is theloaded as first block after body open in all pages.

Just create a custom module with view/frontend/layout/default.xml with

....
<referenceContainer name="after.body.start">
    <block class="Magento\Framework\View\Element\Template" name="google.tag.manager" before="-" template="Custom_Template::html/tag-manager.phtml" />
</referenceContainer>
...

where view/frontend/templates/html/tag-manager.phtml is your tag manager snippet.

Now you have that google tag manager snippet is the first block after body open.

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 tag manager snippet.

Now you have that google tag manager snippet is loaded as first block after body open in all pages.

Source Link
LucScu
  • 2.4k
  • 28
  • 39

Just create a custom module with view/frontend/layout/default.xml with

....
<referenceContainer name="after.body.start">
    <block class="Magento\Framework\View\Element\Template" name="google.tag.manager" before="-" template="Custom_Template::html/tag-manager.phtml" />
</referenceContainer>
...

where view/frontend/templates/html/tag-manager.phtml is your tag manager snippet.

Now you have that google tag manager snippet is the first block after body open.