Title: Javascript is wrapping google tag manager code
Last modified: July 17, 2018

---

# Javascript is wrapping google tag manager code

 *  Resolved [pslcbs](https://wordpress.org/support/users/pslcbs/)
 * (@pslcbs)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/javascript-is-wrapping-google-tag-manager-code/)
 * Hi,
    I’m experiencing a trouble with your plugin because when I enable it with“
   Enable mobile menu” setting your module wraps in an additional <div> all the 
   <body> tag content, including the google tag manager code inside <body> and Google
   doesn’t find it in it’s correct place. The code shows as follows:
 *     ```
       <body class="customize-support mob-menu-slideout-over">
         <div class="mobmenu-push-wrap">
       	<!-- Google Tag Manager (noscript) -->
       		<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXXX" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
       	<!-- End Google Tag Manager (noscript) -->
       .......
       ```
   
 * But if I disable Mobile Menu plugin with “Enable mobile menu” the code is correct
   and Google detects it correctly
 * Is not possible to decide what code is wrapped and what not?
 * Thank you for your answer
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fjavascript-is-wrapping-google-tag-manager-code%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Plugin Author [Rui Guerreiro](https://wordpress.org/support/users/takanakui/)
 * (@takanakui)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/javascript-is-wrapping-google-tag-manager-code/#post-10502610)
 * Hi [@pslcbs](https://wordpress.org/support/users/pslcbs/),
 * That is caused by the Slideout Push content display type, change it to Slideout
   Over content and that won’t happen.
 * You aren’t in the latest plugin version since I removed that Enable Button since
   it was redundant.
 * Upload to the latest version and change to Slideout Over Content Display type
   will do the trick.
 * Let me know the result.
 *  Thread Starter [pslcbs](https://wordpress.org/support/users/pslcbs/)
 * (@pslcbs)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/javascript-is-wrapping-google-tag-manager-code/#post-10504849)
 * Hi,
    No, with 2.5.1 version, it not was caused about ‘Slideout push’ content 
   display type because I changed it to ‘Slideout Over’ and the result is the same,
   with the same classes and moreover the ‘Slideout over’ display doesn’t works,
   the menu displayed is always the ‘Slideout push’ version:
 * <body class=”mob-menu-slideout-over”>
    <div class=”mobmenu-push-wrap”> <!– Google
   Tag Manager (noscript) –> <noscript><iframe src=”[https://www.googletagmanager.com/ns.html?id=GTM-XXXXXXX&#8221](https://www.googletagmanager.com/ns.html?id=GTM-XXXXXXX&#8221);
   height=”0″ width=”0″ style=”display:none;visibility:hidden”></iframe></noscript
   > <!– End Google Tag Manager (noscript) –>
 * I upgraded to 2.6 version and the resulting html code is ok for google tag but
   the trouble now is that the display is always a ‘Slideout over’ empty display
   no matter of the setting tried ‘Slideout over’ or ‘Slideout push’, left or right
   version.
    The menu is there, in html, but is not displayed to user
 * Now is 2.6 installed for if you want to give a look. But not for long time because
   I will downgrade to 2.5.1 to have at least the menu displayed.
 * Thanks
 *  Plugin Author [Rui Guerreiro](https://wordpress.org/support/users/takanakui/)
 * (@takanakui)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/javascript-is-wrapping-google-tag-manager-code/#post-10505130)
 * Hi [@pslcbs](https://wordpress.org/support/users/pslcbs/),
 * It seems your theme isn’t implementing the body_class template tag. We need to
   add a class to the body to later style the menu when it is displayed.
 * [https://developer.wordpress.org/reference/functions/body_class/](https://developer.wordpress.org/reference/functions/body_class/)
 * Just replace the current body markup
    `<body>`
 * by this one
 * `<body <?php body_class(); ?>>`
 * Also I think the plugin that is minifying the scripts is breaking a few scripts,
   can you exclude the file mobmenu.js from that minification. The Minify plugins
   have always an option for that since they can’t guarantee that the process won’t
   break any script.
 * Give it a try and let me know.
 *  Thread Starter [pslcbs](https://wordpress.org/support/users/pslcbs/)
 * (@pslcbs)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/javascript-is-wrapping-google-tag-manager-code/#post-10505397)
 * Ok, fixed!!
    Thank you very much for your great and speedy support despite it
   was not a trouble caused by your module. The solution was to replace `<body>`
   by `<body <?php body_class(); ?>>`
 * Now it works correctly displaying not wrapping all body contents in mobile menu
   divs
 * Not necessary to exclude the Mobile Menu js file mobmenu.js from the minifying
   plugin.
 * Thanks again!
 *  Plugin Author [Rui Guerreiro](https://wordpress.org/support/users/takanakui/)
 * (@takanakui)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/javascript-is-wrapping-google-tag-manager-code/#post-10505539)
 * [@pslcbs](https://wordpress.org/support/users/pslcbs/) That’s great. What matters
   is that is sorted.
    If you have 2 minutes we would appreciate a review at [https://wordpress.org/support/plugin/mobile-menu/reviews/](https://wordpress.org/support/plugin/mobile-menu/reviews/)
 * Thanks
 *  Thread Starter [pslcbs](https://wordpress.org/support/users/pslcbs/)
 * (@pslcbs)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/javascript-is-wrapping-google-tag-manager-code/#post-10505658)
 * Done! 😉
 *  Plugin Author [Rui Guerreiro](https://wordpress.org/support/users/takanakui/)
 * (@takanakui)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/javascript-is-wrapping-google-tag-manager-code/#post-10506355)
 * Thanks I appreciate that.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Javascript is wrapping google tag manager code’ is closed to new replies.

 * ![](https://ps.w.org/mobile-menu/assets/icon-128x128.png?rev=1890426)
 * [WP Mobile Menu - The Mobile-Friendly Responsive Menu](https://wordpress.org/plugins/mobile-menu/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/mobile-menu/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/mobile-menu/)
 * [Active Topics](https://wordpress.org/support/plugin/mobile-menu/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/mobile-menu/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/mobile-menu/reviews/)

## Tags

 * [gtag](https://wordpress.org/support/topic-tag/gtag/)
 * [javascript](https://wordpress.org/support/topic-tag/javascript/)

 * 7 replies
 * 2 participants
 * Last reply from: [Rui Guerreiro](https://wordpress.org/support/users/takanakui/)
 * Last activity: [7 years, 10 months ago](https://wordpress.org/support/topic/javascript-is-wrapping-google-tag-manager-code/#post-10506355)
 * Status: resolved