- This topic has 9 replies, 4 voices, and was last updated 3 years ago by Tom.
October 3, 2017 at 7:53 pm #397016Uwe
Have just inserted GTM code into the two sections in Hooks, being wp_head and Before_header.
Doesn’t seem to find the first part of the code.
Maybe I am missing something:
Here are the details for the page:
– Default Template, not Elementor Canvas
– At first, I had “Header” turned off in “Disable Elements” for that page (Homepage), but even not disabling that didn’t make a difference, not sure if that had anything to do with it
I have also tried one of you other suggestions and copied header.php into the Child Theme as follows and wonder if this is done correctly.
* The Header for our theme.
* Displays all of the <head> section and everything up till <main id=”main”>
* @package GeneratePress
// No direct access, please
if ( ! defined( ‘ABSPATH’ ) ) exit;
<html <?php language_attributes(); ?>>
<!– Google Tag Manager –>
new Date().getTime(),event:’gtm.js’});var f=d.getElementsByTagName(s),
<!– End Google Tag Manager –>
<meta charset=”<?php bloginfo( ‘charset’ ); ?>”>
<meta http-equiv=”X-UA-Compatible” content=”IE=edge” />
<link rel=”profile” href=”http://gmpg.org/xfn/11″>
<?php wp_head(); ?>
<body <?php generate_body_schema();?> <?php body_class(); ?>>
“><?php _e( ‘Skip to content’, ‘generatepress’ ); ?>
<?php do_action( ‘generate_before_header’ ); ?>
<?php do_action( ‘generate_header’ ); ?>
<?php do_action( ‘generate_after_header’ ); ?><?php do_action( ‘generate_inside_container’ ); ?>
Thanks for your help
UweGP Premium 1.4.3October 3, 2017 at 9:26 pm #397042LeoStaffCustomer SupportOctober 3, 2017 at 9:31 pm #397044Uwe
there are several support threads on the forum here, some suggest the Hooks, one the header.php file into Child.
FYI, I have just noticed that the tracking now works. It seemed to take some time to filter through to Google.
Before we close the thread, maybe you can highlight if there is a difference to how this is set up depending on using a Default page template or an Elementor Canvas?
thanks againOctober 3, 2017 at 11:02 pm #397062TomLead DeveloperLead Developer
You should add that into the wp_head hook in GP Hooks – not into the actual file.
The wp_head hook should be available when using the Canvas page template.October 3, 2017 at 11:51 pm #397091Uwe
thanks TomOctober 4, 2017 at 9:29 am #397377TomLead DeveloperLead DeveloperMay 1, 2018 at 12:58 pm #564904liorsade8
so what should i do best?
create a header.php file into the child theme and put the google tag manger code?
or put it into the wp_header / body with hooks? (and if so how to do it exactly?)
thanksMay 1, 2018 at 9:06 pm #565085TomLead DeveloperLead Developer
You should put it into the wp_head hook using GP Hooks.
Alternatively, you can do this: https://generatepress.com/forums/topic/google-tag-manager-code-right-after-the-body-tag/#post-436658May 2, 2018 at 3:19 am #565274liorsade8
will try.May 2, 2018 at 7:39 am #565423
- You must be logged in to reply to this topic.