Pro - Google Tag Manager eliminates menu

Hi,
I’m using Pro Theme and I was following all the instructions from this topic: https://theme.co/apex/forum/t/pro-theme-google-tag-manager/3415/18.
First I created base.php file inside child theme/framework/views/header/ and there I copied the body part pf the tag.
Then I copied the header part of the tag inside functions.php of child theme.
After some time I was checking my site and I saw that my menu disappeard!

Now I’ve done some trials and even copied this code inside the functions.php file and eliminated the base.php file:

Now I can see the Tag manager in my code but!: The site won’t go in debug mode when I activate it in Google Tag manager interface and the snippet in the browser sees only the tag code and it says I need to add Google Analytics but I’ve already added it inside Tag Manager workspace. > probably because the tag manager results not coded properly inside the site.

I’ve also reset the situation where I have one part of the Tag Manager inside base.php file and other inside functions.php of child theme. And my main menu again, after some time, disappears.
Could it be some issue with my site menu settings? I can’t find the solution. I’m using ubermenu.

I’ve even tried to add the _header.php file in my child theme but nothing.

I’ve tried doing this with another site where I have another theme installed and everything went smoothly on the first attempt.
Can you please analyse this issue?

Thank you.
Regards,
Anita

This is my site: https://www.mediana.com

Hey Anita,

Our themes does not have a problem with Google Tag Manager. Once you place the GTM code in the right places, it should work. If not, there is certainly a problem with your GTM setup.

Regarding the menu, I don’t see the whole masthead in the source code and that is weird because the page template you’re using allows for the header to show up.

Firstly, we need to know if that is caused by the parent theme so please deactivate the child theme and check if the menu will appear again.

If the menu appears, it’s definitely caused by customization. In this case, back-up and delete the current child theme in your site. Then, download a fresh Pro child theme at https://theme.co/apex/child-themes and install and activate it in your site.

Next, re-add your customizations bit by bit and check if the menu disappears each time you add a block of custom code. That will tell you what is causing the issue.

By the way, x_before_site_begin is not the correct hook to add code after the opening body tag. It should be x_after_body_begin. Below is a sample code including adding code to the <head>.

// Add code inside <head>

add_action('wp_head', 'custom_code_inside_head');

function custom_code_inside_head() {
  ?>
  <!-- Custom Code Goes Here -->
  <?php
}

// Add code after body tag in X/Pro themes

add_action('x_after_body_begin', 'custom_code_after_open_body');

function custom_code_after_open_body() {
  ?>
  <!-- Custom Code Goes Here -->
  <?php
}

Those codes will work if copied completely. See the screenshot below.

That is as far as we can help. We can only help with how to add code inside our themes. The responsibility of making the custom code work and the maintenance of it is outside the scope of our support.

If the menu does not appear even when using the parent theme, it’s possibly due to a configuration. In this case, please give us WordPress Admin access credentials in a Secure Note so we could check your setup.

Thanks.

Hi,
the code that you brought above, as I said, I tired to implement it inside functions.php but I’ve done a rollback to the version before: piece of tag manager inside base.php (body of GTM) file and other piece inside functions.php (head of GTM). So that is not the problem even if the code was not correct, but thank you for the correction.

I’ve tried to activate the parent theme but nothing changed.

So I’ve searched the forum and found this: https://theme.co/apex/forum/t/google-tag-right-after-body/47132/9.
So I’ve deactivated the base.php file and placed _header.php file inside my child theme. I believed it was suitable only for X Theme and not Pro, as specified in the thread, but I tought to give it a try and it seams it is working. Could you please check on your side?

Thanks,
Anita

Hey Anita,

To avoid confusion, please let us concentrate on one issue at a time. Let us start with the most crucial one and that is the disappearance of your menu. Let us please forget about the _header.php and base.php for a moment as they are not required to add code (especially for GTM) to the head and after the body tag as I showed you in my previous response.

You said:

I asked for credentials previously if that is the case. Please reply with your credentials and remember not to discuss further about adding GTM code to your site until this is resolved.

Thank you for your cooperation.

Hey Anita,

Thanks for providing us access.

Upon checking, I see the header is displayed now unlike before.

Your GTM code is also present both in the head and after the opening body tag.

It looks like all of your problems are now solved.

If you’re referring to the problem with GTM code’s connection to Google Analytics, that is outside the control of our theme. The only aspect related to our theme is the output of the code in the head and below the opening body tag.

Please consult with a Google Tag Manager expert to investigate the issue with your GTM setup.

Just to let you know, I could say that because I know how to setup GTM. Fixing GTM issues though is outside the scope of our support.

Thank you for understanding.

Hi Christian,
Thank you, as I told you in the thread before I’ve solved it by integrating _header.php file in my child theme and by eliminating the base.php file.
I know that GTM is not configured because there is a container missing, so that is the issue.

Regards,
Anita

Glad your theme issues are now resolved.

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