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.
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
WP Code
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.)
- Anowave: Magento 2 Google Tag Manager Enhanced Ecommerce (GA4) Tracking
- Weltpixel: Google Analytics 4 (GA4) With GTM Support for Magento 2
Other less commonly used plugins:
- Amasty: Google Analytics 4 with GTM Support for Magento 2
- Magefan: Magento 2 Google Tag Manager & GA4
- Mageplaza: Magento 2 Google Tag Manager Extension (GTM) – Enhanced Ecommerce UA Tracking – Integrated GA4
- Meetanshi: Magento 2 Google Analytics 4 (GA4) Using GTM
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
- Pixabay https://pixabay.com/photos/programming-computer-environment-1857236/
- The perfect tattoo doesn’t exi- meme: https://www.reddit.com/r/ProgrammerHumor/comments/hf98v0/the_perfect_tattoo_doesnt_exi/?rdt=44002