<html>
<head>
<!– Add the Google Tag Manager Script here –>
<!– Make sure to place the Google Tag Manager Script as close to the opening <head> tag as possible –>
<!– File in theme that you normally have to edit: header.php in the root theme folder.
Copy this file from your main theme to the child-theme folder and then add the Google Tag Manager Script.
NEVER add the code in the main theme. Only in the child theme
–>
</head>
<body>
<!– Add the Google Tag Manager No-Script tag here –>
<!– Make sure to place the Google Tag Manager Script as close to the opening <body> tag as possible –>
<!– File in the theme that you normally have to edit: header.php in the root theme fold.
Copy this file from your main theme to the child-theme folder and then add the Google Tag Manager Script.
NEVER add the code in the main theme. Only in the child theme. –>
</body>
</html>
Note: Adding the Google Tag Manager code to a WordPress site manually is not best practice!!!!
Instead I would recommend you to install Google Tag Manager through a plugin. Recommended plugins:
1. Site kit by Google – https://wordpress.org/plugins/google-site-kit/
2. Google Tag Manager for WordPress – https://wordpress.org/plugins/duracelltomi-google-tag-manager/
And yes, there are a lot of Google Tag Manager plugins out there. These are just my personal favorite and has been recommended to me.