Adding GTM tag in body in PRO theme

Referring to old post but could not figure out .

Google Tag Manager needs following script to be added immediately after body tag

<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXX"
height=“0” width=“0” style=“display:none;visibility:hidden”>

I could add other script using plugin to add code in header or footer but I am not sure where to add the above code after body tag? I am. using PRO theme

Thanks
Ajay

Hello Ajay,

In order to add the custom code after the body I would suggest you please use the code to activate the child theme functions.php file.

add_action('wp_body_open', 'your_custom_code_body_open');

function your_custom_code_body_open() {

    echo '<script>Your code here</script>';

}

Please note that the code provided above serves as a guide only and is to help you in getting started so implementing it and maintaining the code will be out of our support scope and further maintenance for new possible versions of the theme that may cause the customization to break, you will need to hire a developer or you can subscribe to One where customization questions are answered.

Thanks for understanding

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.