I am trying to: add Google Tag Manager code in everypage of my site.
I uploaded the code in header.php and it work on some worpdress pages, but not the pages that use toolset view/layout/types
Link to a page where the issue can be seen: bestcase.com/community does not have the GTM code. bestcase.com does have it.
thank you
Hi,
Please describe detail steps to duplicate the same problem:
How do you setup the Google Tag Manager code in header.php?
How do you setup those pages that use toolset view/layout/types?
I need to test and debug it in my localhost. thanks
Hi,
navigate to bestcase.com, check in the code or via "Google Tag Assistant" that the GTM code is present.
Navigate to bestcase.com/community, repeat the step and see that code is not present.
Navigate to bestcase.com/cac and see that code is also note present.
I have added bot GTM code in header.php I made a copy of the header.php from the DIVI theme, and paste it in my divi-child theme folder.
I have no idea how to setup the pages using toolset plugin, I did not build the website. I see that some pages are using layout, and it looks like layout contains 'bricks' of other page like: breadcumbs, menu, footer, etc.
I don't see any space for pasting head and body code
thanks for your help
REgards
I have tried the URL you mentioned above:
enlace oculto
I can see only below message:
This site has been blocked by the network administrator.
Block reason: Gateway GEO-IP Filter Alert
As I mentioned above, please provide detail steps to duplicate the same problem, what is the GTM code you have added into header.php?
I need to test and debug it in my localhost. thanks
Are you guys in Russia? Can you use a proxy from another country to access our website?
Code I put in header.php (in my divi child theme):
<!-- 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=
'enlace oculto);
})(window,document,'script','dataLayer','GTM-XXXXXXX');</script>
<!-- End Google Tag Manager -->
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="enlace oculto"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
The code is present on most pages. but not on the ones created/using toolset views/layouts.
Are you stripping the code or something?
No, I am in China, I don't have other proxy of other country,
In your case, it depends on your theme files, and since it is a custom codes problem, in order to debug this problem, please provide a copy of your website, I need to duplicate and debug the same problem in my localhost:
https://toolset.com/faq/provide-supporters-copy-site/
You can put the duplicator package in google drive disk, and share the downloadable links.
Can you ask another of your team member not in russia or china, to look at this ticket please?
It will be much easier.
Serhii Salii answered the same problem in this ticket, I need more information starting from there:
https://toolset.com/forums/topic/adding-google-tag-manager-js-code-to-the-head-of-every-page-that-uses-a-layout/
Thank you for your understanding.
I have been able to get a proxy account from USA, and for the custom codes mentioned in the thread:
https://toolset.com/forums/topic/adding-google-tag-manager-js-code-to-the-head-of-every-page-that-uses-a-layout/#post-443737
I have tested those codes in my localhost, there is a typo in it, you can put them into your theme file "functions.php", and test again:
// define the wp_print_scripts callback
function action_wp_print_scripts() {
echo "<!-- 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=
'<em><u>enlace oculto</u></em>);
})(window,document,'script','dataLayer','GTM-XXXXXX');</script>
<!-- End Google Tag Manager -->";
};
// add the action
add_action( 'wp_print_scripts', 'action_wp_print_scripts', 10);
function filter_wp_add_after_body($content){
return '<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="<em><u>enlace oculto</u></em>"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->' . $content;
}
add_filter('get_layout_content_for_render', 'filter_wp_add_after_body');
Please replace GTM-XXXXXX with your GTM key/ID.
Thanks, I did see the "" typo, and it seems to work. I ended up using a plugin in the meantime.