Magento SEO – A Definitive Guide to Setting Up Google Tag Manager (GTM) on Magento 2

Magento SEO – A Definitive Guide to Setting Up Google Tag Manager (GTM) on Magento 2
COMMENTS ()
Tweet

In this post we’ll look at one of the key components of Magento SEO i.e. how to setup Google Tag Manager on a Magento 2 web store. Here’s how you can do so.

1)  First create a new gmail account, if you don’t have one already.

2)  Next, go to https://www.google.com/analytics/tag-manager/. Expand the “Sign in” dropdown at the top and click “Tag Manager” (as shown in the screenshot below).

 

Magento SEO

 

3)    Select “Create Account”. Here you’ll need to complete the steps for ”Setup Account” and “Setup Container” (as shown in the screenshot below).

4)    Next, you’ll need to setup the “Account Name” under “Setup Account” (as depicted below). The share data check-box here is optional.

 

magento seo

 

5) Then under “Setup Container”, you’ll need to setup the “Container Name” and “Where to Use Container”.

 

magento seo

 

6) Next, you’ll need to agree to the Google Tag Manager Terms of Service, as shown in the screenshot below.

 

magento seo

 

7) Once you perform the above mentioned steps, you’ll notice that the configured container appears automatically along with a pop-up of “Install Google Tag Manager”.
i. If the container does not appear, just select it from top-left menu.
ii. If no pop-up appears for “Install Google Tag Manager”, then just click on the menu item that starts with ‘GTM’, for e.g.: GTM-TMHHCDN.

 

magento seo

 

8) Now, copy the script and paste it under admin → content → configuration → (required) theme → HTML head → Scripts and Style Sheets

 

magento seo

 

magento seo

 

magento seo

 

9) Now, copy the script and paste it under the html body via code logic. In layman’s terms, just paste it into the static block and call the static block in the code (as shown in the snippet below.

<referenceContainer name="before.body.end">
            <block class="Magento\Framework\View\Element\Template" name="gtm.body.script" template="Magento_Theme::html/gtm-body-script.phtml" /> </referenceContainer>
<?php echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('gtm_body_script')->toHtml(); ?>

10)  You can verify the <head> and <body> script by viewing the source of the respective page.

And that’s it. Feel free to comment or reach out if you have any questions. If you need any help with Magento SEO (like setting up Google Tag Manager & Google Analytics on Magento 2), replatforming to Magento, or upgrading from Magento 1 to Magento 2, please get in touch with us.

CALL

USA408 365 4638

VISIT

1301 Shoreway Road, Suite 160,

Belmont, CA 94002

Contact us

Whether you are a large enterprise looking to augment your teams with experts resources or an SME looking to scale your business or a startup looking to build something.
We are your digital growth partner.

Tel: +1 408 365 4638
Support: +1 (408) 512 1812