- This topic has 9 replies, 4 voices, and was last updated 6 years, 5 months ago by Tom.
-
AuthorPosts
-
October 3, 2017 at 7:53 pm #397016Uwe
hi guys
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 itI 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.
<?php
/**
* 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;?><!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<!– 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-5BPTXW’);</script>
<!– 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(); ?>
</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
UweOctober 3, 2017 at 9:26 pm #397042LeoStaffCustomer SupportHi there,
Which part is not working? Where did the instruction say to insert the code?
October 3, 2017 at 9:31 pm #397044UweHi Leo
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 again
October 3, 2017 at 11:02 pm #397062TomLead DeveloperLead DeveloperYou 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 #397091Uwethanks Tom
October 4, 2017 at 9:29 am #397377TomLead DeveloperLead DeveloperNo problem ๐
May 1, 2018 at 12:58 pm #564904liorsade8hi tom.
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?)
please help,
thanksMay 1, 2018 at 9:06 pm #565085TomLead DeveloperLead DeveloperYou 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-436658
May 2, 2018 at 3:19 am #565274liorsade8ok thanks.
will try.May 2, 2018 at 7:39 am #565423TomLead DeveloperLead DeveloperNo problem ๐
-
AuthorPosts
- You must be logged in to reply to this topic.