Tagged: x
-
AuthorPosts
-
October 13, 2016 at 7:57 am #1214576
BenjaminParticipantHello,
I am trying to get my Google tag manager code be placed correct but I get the above warning from the tag assistant.
I have my analytic code working but not tag manager code. Below it the code as it is in the functions.php file in my child theme.// ============================================================================= function add_google_tag_manager_code(){ ?> <!-- Google Tag Manager --> <noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-KHG89S" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> <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= '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-KHG89S');</script> <!-- End Google Tag Manager --> <?php } add_action( 'wp_head', 'add_google_tag_manager_code' ); // End Add Google Tag Manager Code // =============================================================================Can you see any mistakes here?
Best regards,
BenOctober 13, 2016 at 10:41 am #1214871
RupokMemberHi Ben,
You are adding it in right way so it should work fine if the code is correct. Let’s check the source code to make sure it was added.
Cheers!
October 13, 2016 at 5:58 pm #1215360
BenjaminParticipantHello Rupok,
Yes that above code looks good when comparing source.
Although, when checking in my Google tag manager admin, I see that there is additional code which needs to be added also and this code needs to be placed immediately after the opening <body> tag:<!-- Google Tag Manager (noscript) --> <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-KHG89S" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> <!-- End Google Tag Manager (noscript) -->Could you help me to implement this code in my functions.php file?
Cheers,
BenOctober 13, 2016 at 11:45 pm #1215702
RupokMemberHi Ben,
You have placed the other code within
wp_head. So you can use the same step to add withinwp_footer.Also there is a plugin to add scripts within header and footer – https://wordpress.org/plugins/insert-headers-and-footers/
Using script to header and footer is usual. If you need to add anything within the body, you can try RAW Content element within page content.
Hope this makes sense.
October 15, 2016 at 12:26 am #1217030
BenjaminParticipantOk thanks Rupok,
Appreciate your time. Will have a look.
Cheers,
BenOctober 15, 2016 at 1:43 am #1217075
FriechModeratorLet us know how it goes,
Cheers!
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1214576 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
