Hi,
I tried original Google’s approach for adding Google Tag Manager by using different threads here in the forum but in the end it breaks headers in PRO Theme.
I see that many people recommend to use this third party plugin instead: https://wordpress.org/plugins/duracelltomi-google-tag-manager/
But it still requires to embed a string of code into the theme’s header template to follow recommendations of Google. Could you please help with the script for doing this correctly?
-
Install, activate the plugin and enter Google Tag Manager ID in it’s settings. Then we select Custom in Container Code Placement for embedding the code provided into the theme (that is all easy).
-
We copy header.php from original PRO Theme folder into the Child’s Theme. Open it for edit but it’s almost empty. There is no
<head> </head>
and<body> </body>
parts. In accordance with instruction of the developer the code<?php if ( function_exists( 'gtm4wp_the_gtm_tag' ) ) { gtm4wp_the_gtm_tag(); } ?>
shall go right after the<body>
. Do I need to pre-populate anything inside<head>
and<body>
of the header.php in the Child Theme to make it work properly or there is another way for embedding that code?