URGENT PLEASE - GTM Stopped working

Hi,

I have big problem with a clients site which I’d really appreciate some help with please.

Google Tag Manager stopped working around Jan 4, 2019. I checked the code the I installed months ago in _header.php . and it’s still the same.

I just cant work out why the GTM tag is no longer showing in the head and body of the site.

I will send through the login details to the site after this message - could you please have a look for me and let me know what you think?

Thanks,
Darren

Hi @DesignMunky,

Thanks for writing in!

Instead you can setup a child theme and add the following code into your child theme’s functions.php file.

// Begin Google Tag Manager Code
// =============================================================================
function my_custom_google_tag_manager_code(){
?>

<!-- Replace this line with your Google Tag Manager Code  -->


<?php 
}
add_action( 'wp_head', 'my_custom_google_tag_manager_code' );
// End Google Tag Manager Code

For body.

// Add Google Tag Manager Code in Body
// =============================================================================
function my_custom_tag_manager_body(){
?>

<!-- Replace this line with your code provided by google -->

<?php 
}
add_action( 'x_before_site_begin', 'my_custom_tag_manager_body' );

Hope that helps.

Hi,

Thanks for the fast reply - much appreciated. I’ll add the new code in shortly, but first I just wanted to check with you on what I should do about the the folllowing code in the _header.php file?

<?php

// =============================================================================
// VIEWS/GLOBAL/_HEADER.PHP
// -----------------------------------------------------------------------------
// Declares the DOCTYPE for the site and includes the .
// =============================================================================

?>

> <?php wp_head(); ?>
<?php do_action( 'x_before_site_begin' ); ?>

<div id="top" class="site">

<?php do_action( 'x_after_site_begin' ); ?>

Hi Basanta,

I’ve made the changes you suggeested and deleted all the content in the header.php file and it seems to be working properly again - thanks!

Do you have any idea why I suddenly got this problem in the first place? I had made no changes to the header.php file and yet everything stopped working on Jan 5.

I Need to make sure this doesn’t happen again.

Cheers,
Darren.

Hi Darren,

Did you directly do any changes to your Pro parent theme templates ? If so, it will override your template files whenever you update your theme. Instead you need to implement your changes into you child theme’s template files (I see you already have a child theme setup).

If you have already used your child theme earlier and if you have experienced this issue, you need to investigate this issue further with the help of your hosting provider as they have full access to your error logs. It could be due to another plugin’s conflict as well.

Thanks!

Hi Mildarshana,

No, I didn’t make any changes to the Pro Parent theme template. I will check with the hosting provider and see if they can help with error logs.

Thanks,
D.

Hey D,

_header.php that’s located in \framework\legacy\cranium\headers\views\global powers the Classic Header. The most probable reason why it’s not working is because you’ve switched to Pro Header.

If you switch back to the Classic Header, you’ll find that your it is broken because you’ve left the template empty in the child theme. Please remove custom templates if they are no longer in use in order to avoid issues in the future.

Please also keep track of the changes you’ve done in your website.

Thanks.

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