Archived topic
Google Tag Manager breaks menu
9 replies · Started by Manuel on February 18, 2020
The menu in frontend disappears after inserting the Google Tag Manager code as mentioned here: https://docs.generatepress.com/article/implement-google-tag-manager/
Tried as element with hooks and also as PHP with the Snippet plugin. Same result.
Deactivating all plugins also didn't work.
How can we solve this?
Hi there,
can you clear and disable your cache plugin - let me know so i can take a closer look
Hi David,
the cache is cleared and the plugin deactivated.
Best regards,
Manuel
I think our documents have been updated incorrectly.
The first script you have the wp_body_open hook. Change this to WP_Head
The second script change the hook to wp_body_open
Hi David,
unfortunately this didn't solve the issue.
Do you have a plugin adding the GTM as well ? As i can see scripts twice.
If so can you remove that and then can you paste the code you have added to the two hooks here.
Please highlight the code and hit the the code button before submitting.
Hook: wp_head, entire site
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXX');</script>
<!-- End Google Tag Manager —>
Hook: wp_body_open, entire site, priority 0
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXX"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) —>
Aah - see this:
<!-- End Google Tag Manager —>
replace with:
<!-- End Google Tag Manager -—>
And this:
<!-- End Google Tag Manager (noscript) —>
replace with:
<!-- End Google Tag Manager (noscript) -—>
Hi David,
sorry for the inconvenience! You were right. There were not the right --> after the line. These two are the correct ones:
<!-- End Google Tag Manager -->
<!-- End Google Tag Manager (noscript) -->
You're welcome - not an inconvenience at all as it helped us correct an error in our documentation.