How To Setup Google Tag Manager

How To Install Google Tag Manager

After creating a container, we can obtain the code for installation on the website. This consists of two pieces of code.

The first one should be placed in the HEAD section of each page and the second one immediately after the BODY tag. The second one is not absolutely necessary.

GTM code
GTM code

For a custom site, this is done by directly intervening in the code. However, since most sites today are created with a platform, there are now specialized and easier methods for installation.

WordPress

In WordPress, we usually use the GTM4WP. It is a powerful plugin that, besides installing GTM, offers excellent solutions for GA4 eCommerce Tracking and several other solutions.

If we have a simple site, we can alternatively use some “headers and footers” plugin for code insertion. There are many. I usually use WP Code.

Using plugins

GTM4WP

GTM4WP settings
GTM4WP settings

WP Code

WP_CODE settings
WP_CODE settings

Manual integration

There is the option to insert the GTM code through the option

Appearance ⟶ Theme Files Editor

but this method should be avoided.

Magento 2

Using plugins

Installation in Magento 2 is usually done with one of the following two plugins and practically involves configuring GA4 eCommerce Tracking (and other services possibly supported, e.g., Facebook Pixel, etc.)

Other less commonly used plugins:

Manual integration

Although rarely used, installation can be done manually:

From the Magento Admin Panel, we choose

Content ⟶ Design ⟶ Configuration ⟶ Edit the Store View ⟶ Other Settings ⟶ HTML Head

and place the main code for the HEAD here.

Then in the Footer section, place the second snippet of code in “Miscellaneous HTML.”

Finally, save the changes.

Shopify

The basic installation is done as follows:

theme.liquid file

Locate the file as follows:

Online Store ⟶ Themes ⟶ Edit code ⟶ theme.liquid

Place the first piece of code immediately after the HEAD tag and the second one immediately after the BODY tag and obviously save the changes.

order confirmation page

Settings ⟶ Checkout ⟶ Order Status Page ⟶ Additional Scripts

Place the first piece of code here and save the changes.

Credits

Shopping Cart
Scroll to Top