Hello,
I want to install Google Tag Manager (GTM) on my website, but I don’t want to use any extensions. I want to install it directly in my theme files.
I am using a child theme.
Should I install the scripts in the child theme, or should they go in the main theme? Here’s where GTM recommends placing the codes:
Where to place the GTM code?
GTM consists of two parts that must be placed in specific locations:
The main script script → Inside head
Must be placed as high as possible in <head> to load quickly.
Ensures that tags fire at the beginning of the page load.
The <noscript> tag → Right after <body>
Must be placed immediately after the opening <body> tag.
Allows GTM to load even if JavaScript is disabled.
Never place it in the footer!
Can you tell me exactly how to do this?
Also, if you know of a reliable plugin that makes installation easier, let me know. But keep in mind that the second script must not be placed in the footer.
Thanks!