- This topic has 15 replies, 5 voices, and was last updated 7 years, 11 months ago by
Tom.
-
AuthorPosts
-
November 27, 2017 at 4:11 pm #436397
Satori
As many of you already know. Google Tag Manager provides two sets of code, one to be in the head and the other to be right below de body tag. First one is easy to install, but the second one is hard to accomplish for non-techies like me.
Luckily it seems that in GP 2.0 we can enable this through some magic code. So Tom, show me your magic!
November 27, 2017 at 7:58 pm #436553Leo
StaffCustomer SupportHi there,
The Before Header hook should be what you are looking for: https://docs.generatepress.com/article/hooks-overview/
November 27, 2017 at 9:55 pm #436630Satori
Hi Leo, thank you. It actually cannot display a particular GTM script. But I was told by Tom himself that there does exist a new solution for this on GP 2.0.
November 27, 2017 at 11:12 pm #436658Tom
Lead DeveloperLead DeveloperIn GP 2.0, you can do this:
add_action( 'generate_before_header', 'tu_add_google_tag_manager', 0 ); function tu_add_google_tag_manager() { ?> Code in here <?php }November 28, 2017 at 12:03 am #436691Satori
It didn’t work. Take a look at the screenshots: https://imgur.com/a/jEijE
This Google Tag Manager thing is driving me crazy.
November 28, 2017 at 12:05 am #436692Tom
Lead DeveloperLead DeveloperYou would add that function using one of these methods: https://docs.generatepress.com/article/adding-php/
November 28, 2017 at 12:14 am #436695Satori
Done, thank you so much Tom!
November 28, 2017 at 9:01 am #437071Tom
Lead DeveloperLead DeveloperYou’re welcome 🙂
April 10, 2018 at 9:09 pm #546925Steffen
Hi, I tried to verfiy my site with GTM and used the methods you are talking about but Google is still saying that the GTM is not in the correct position in my website. My Tags in Tag Manager like Analytics are running but it seems to be something wrong.
April 11, 2018 at 8:24 am #547416Leo
StaffCustomer SupportHmm so you’ve added the two parts of code, first part in
wp_headand second part in before header hook?April 11, 2018 at 8:59 am #547478Steffen
yes and also added the php
add_action( ‘generate_before_header’, ‘tu_add_google_tag_manager’, 0 );
function tu_add_google_tag_manager() { ?>
2nd TGM Code
<?php }April 11, 2018 at 8:44 pm #547946Tom
Lead DeveloperLead DeveloperThe function you posted is the correct way to do it.
I see you’re using a caching or minifying plugin – have you tried clearing it to make sure the code is showing up?
April 11, 2018 at 9:48 pm #547976Steffen
Ahh okay, now it is working. Thanks.
April 12, 2018 at 7:29 am #548351Tom
Lead DeveloperLead DeveloperNo problem 🙂
April 22, 2018 at 9:48 am #557321John
i have done exactly as Steffen has stated above but I am still getting this message when I check it with google tag chrome extension “GTM no-script code not found: either missing or not in <body>”

http://www.everytip.co.uk. Any ideas? Cache has been cleared
-
AuthorPosts
- You must be logged in to reply to this topic.