To activate Google Tag Manager on your WordPress site you will first need to insert the two Tag Manager code snippets, the first in the <head> section and the second at the opening of the <body> of your site’s HTML code.
Yes, it will be the first and only time you have to make your hands dirty by manually entering the code, but it is a necessary step.
Below I will explain how to insert code snippets through WordPress.
After creating an account in Google Tag Manager we continue with the next steps.
You can install the code via WordPress in two ways: via Editor or via a Plugin. In the end, I will reveal a third trick that I usually apply in particular situations. I leave it to you to decide the best way (if you need some advice leave a comment!).
1. INSTALLATION USING THE EDITOR
COPY THE SNIPPET
Once the account is created, you will need to copy the two snippets provided by Google Tag Manager.

PASTE THE SNIPPETS INTO THE HTML PAGE
From the WordPress control panel, go to the Appearance section and then click on Editor.
On the right of the screen, you will see all the .php files that make up your WordPress site template. At this point, click on the Header.php file to be able to edit it.
The two codes to be entered go into two different sections: <head> and immediately after opening the <body>.
You just have to look for the <head> and <body> section within the code of this file and paste the two Tag Manager snippets according to the instructions.

Click the Update File button below and… Google Tag Manager is now installed!
The pros and cons of this implementation:
► Pro: it takes you 2 seconds to implement and don’t burden your WordPress instance with Plugin.
► Cons: if you update your theme, you’ll lose the change. One piece of advice I can give you is to use child themes (they’re really cool!).
2. INSTALLATION VIA PLUGIN
Now let’s see how to perform the same procedure, but with the help of a Plugin.
INSTALL THE PLUGIN
From the WordPress control panel, go to the Plugins section and click on Add new.
Search for the Plugin with the query “Google Tag Manager”. You will see several available. I recommend that you install “DuracellTomi’s Google Tag Manager for WordPress”.
Why do I recommend this Plugin? The author knows something about it and it is the Plugin with the most installations and positive reviews.

CONFIGURE THE PLUGIN
After activating “DuracellTomi’s Google Tag Manager for WordPress”, simply enter your Tag Manager ID (GTM-XXXXXX) in the appropriate section within the Plugin.
I don’t recommend the first solution (Footer of the page), I really don’t understand why the author puts it as an option.
You can select the Custom or Codeless injection option under “Container code placement”.
If you select Custom, you will need to copy the small line of code you see and paste it into the <body> of the header.php file via the editor, just like we did before.
The Codeless injection option, on the other hand, is more convenient since, as the name itself implies, you do not need to enter any code. More convenience and simplicity, however, is reflected in a greater margin of error: as the Plugin author himself warns, it is an experimental option that could possibly give some small problems.
In any case, to be sure of the correct installation of Google Tag Manager, I recommend that you always check with Tag Assistant.
But then, if I still have to enter the code manually, what is the advantage of using this Plugin?
Good question!
The advantage is that the Plugin is integrated with the Data Layer and other elements of Google Tag Manager. Through the Plugin, you can then easily enter the data within the Data Layer. To do this, just go to the Plugin, in the second tab: Basic data.
Here select all the data you want to include in your Data Layer, such as post author, post date, post tag, site search terms, user status (logged in or not), etc.
You have the option to enter custom values as well. Really cool, right? All without putting your hand in the code.

Thanks to this Plugin you can also set up in an extremely simple way the tracking of events, scrolling, insert some tags in a blacklist so that they are not executed.
I’ll tell you a gem: Javascript libraries developed by third parties are implemented for these features. Google Tag Manager is very powerful, but don’t fill it with 100 thousand tags because the site suffers from it in terms of loading (even if asynchronous!).
All this information is transferred to Google Tag Manager allowing you to have a lot of useful information for your business.
The pros and cons of this implementation
► Pro: Like every Plugin, everything is simple, 2 clicks and that’s it. Zero codings, zero programmings, very easy! No problem with theme updates (as long as you haven’t used the “custom” implementation, then you’re screwed). It has many tracking features already implemented.
► Cons: like all Plugins, it is always a pain to manage (updates, conflicts, security) and if you do not use the various options that the Plugin offers, but only use it to implement the tag, I do not recommend it.