Google Tag Manager installation

I have copied _header.php from x/framework/legacy/cranium/headers/views/global/ to x-child/framework/legacy/cranium/headers/views/global/ and have added the noscript gtm just under <body <?php body_class(); ?>>. No success, but I know I’m supposed to add the gtm script in the functions.php. When I copy the functions.php from x theme to x-child theme, the site goes down until the functions.php is removed from the child theme. What am I doing wrong here?

Hi there,

You can get the child theme from here and install and activate it.

Once installed you should be able to have the base functions.php file for the child theme.

Login through FTP and edit the functions.php file and add this code:

add_action('wp_head','custom_script');
function custom_script() {
?>
    <!-- Add the code here -->
<?php
}

Hope this helps.

As previously stated, I have already tried this. When I do this, the website crashes.

Hi there,

You must have incorrect codes in the functions.php which is causing the error.

Please post the codes you have here so we can check.

Thank you.

I haven’t edited any of the code in functions.php, just copied it to the x-child theme. Copying the child theme was the right thing to do, correct? The site works fine when the functions.php remains in the parent theme, but crashes as soon as the functions.php is copied to the x-child theme.

Below is the content of the php.

Hi there,

This is incorrect. It is not necessary to copy the functions.php file from the parent theme to the child theme because there is already a function.php file in the child theme.

As previously instructed in my previous response here, when you download the child theme, it should give you the base files that you need which includes the functions.php file. Then simply open the untouched functions.php file included with the child theme and add the code from the previous post and you should not get any error.

Hope this helps.

I have the child theme downloaded and installed, but there was no function.php file loaded. I have another site with the child theme loaded and it does have this file. Should I re-install the child theme or will this tamper with the site that is currently live?

I successfully re-installed the x-child theme and the functions.php is now available. I inserted the proper tag on the function.php and the proper tag in the _header.php files, but the tags are not showing as active. I’m beginning to lose my mind over this.

Hi there,

If you added the code correctly in the functions.php file as my colleague stated and it is not showing, it might be a problem of cache. You will need to clear cache plugins if you have any installed.

If you need we can help you add the code. Just get back to us with the code that you get from the Google Tag Manager and the URL/User/Pass of your website alongside the FTP information using Secure Note and we will add the code for you.

Thank you.

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