- This topic has 22 replies, 2 voices, and was last updated 1 year ago by
David.
-
AuthorPosts
-
March 19, 2020 at 9:32 pm #1200135
Ajay
hey, I’m unable to see a Google Tag Manager head code on my site. the body tag is visible but the head tag isn’t watchable. head tag applied hook is wp_head and the proxy is 10 with all pages. how can I see my code?
March 20, 2020 at 12:44 am #1200217David
StaffCustomer SupportHi there,
i can see the HTML comments for the Tag in the WP_head ie.
<!-- Google Tag Manager --> <!-- End Google Tag Manager -->
If the comments are part of your code it says the hook is working.
The missing script says that maybe the code has an error in there.
Can you copy and paste the exact code you have here. Make sure you highlight the code and click the Code button before submitting.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/March 20, 2020 at 1:38 am #1200255Ajay
sorry but I didn’t get it what do you wanna say but I did copy and past again in and the issue is not sorted out until now. please help?
March 20, 2020 at 1:54 am #1200268David
StaffCustomer SupportCopy the code you have in your site. And paste it here in this forum.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/March 20, 2020 at 1:58 am #1200280Ajay
look:
<!-- 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-NW4WCSB');</script> <!-- End Google Tag Manager -->
March 20, 2020 at 2:07 am #1200287David
StaffCustomer SupportTry adding it to your site using the Functions Method here:
https://docs.generatepress.com/article/implement-google-tag-manager/#using-functions
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/March 20, 2020 at 2:37 am #1200315Ajay
why I cannot put code via hook? also, I’m using autopimize plugin that might be causing the problem? any solution add code without using any plugin?
March 20, 2020 at 2:42 am #1200320David
StaffCustomer SupportThe Hook Element writes the code to the Database.
Some Hosts will not allow<script>
tags to be written to the database. You can check this with your Host.The functions method i provided does not require plugins.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/March 20, 2020 at 2:47 am #1200326Ajay
so i can simply put the code into the head and body section? in theme editor? but if someday the theme update would come in the future then my code will be there whether yes or not? please guide me step by step how to do that?
March 20, 2020 at 3:45 am #1200363Ajay
what should I do I’m so confused?
March 20, 2020 at 4:00 am #1200374David
StaffCustomer SupportThis is the code – simply add your scripts in place of
<!-- Add your code -->
:<?php add_action( 'wp_head','gtm_part_1' ); function gtm_part_1() { ?> <!-- Google Tag Manager --> <!-- Add your code --> <!-- End Google Tag Manager --> <?php } add_action( 'wp_body_open','gtm_part_2',0 ); function gtm_part_2() { ?> <!-- Google Tag Manager (noscript) --> <!-- Add your code --> <!-- End Google Tag Manager (noscript) --> <?php }
Then you have two choices to add these codes:
1. Install the Code Snippets plugin:
https://en-gb.wordpress.org/plugins/code-snippets/2. Install a Child Theme.
Link to child theme here:
http://generatepress.com/api/themes/generatepress_child.zipThen edit the Child Theme Functions.php and add the codes
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/March 20, 2020 at 4:32 am #1200387Ajay
I got the reason why it was happening. As my investigation, the autoptimize plugin was causing the problem. otherwise, I could be able to see my code. I think code is working properly but autoptimize has been hidden the code. isn’t it right? there is no need to do anything. what is your thought about it?
March 20, 2020 at 4:36 am #1200394David
StaffCustomer SupportIf you can disable Autoptimize i can take a look.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/March 20, 2020 at 9:48 pm #1201210Ajay
ok now I do let’s check that
March 21, 2020 at 5:32 am #1201621David
StaffCustomer SupportYep – i can see GTM Script in the
<head>
.
What are the JS settings you have used in Autoptimize ? Can you share a screenshot ?Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/ -
AuthorPosts
- You must be logged in to reply to this topic.