[Resolved] Google Tag Manager and Elementor

Home Forums Support [Resolved] Google Tag Manager and Elementor

Home Forums Support Google Tag Manager and Elementor

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #397016
    Uwe

    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 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.

    <?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″&gt;
    <?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
    Uwe

    #397042
    Leo
    Staff
    Customer Support

    Hi there,

    Which part is not working? Where did the instruction say to insert the code?

    #397044
    Uwe

    Hi 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

    #397062
    Tom
    Lead Developer
    Lead 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.

    #397091
    Uwe

    thanks Tom

    #397377
    Tom
    Lead Developer
    Lead Developer

    No problem ๐Ÿ™‚

    #564904
    liorsade8

    hi 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,
    thanks

    #565085
    Tom
    Lead Developer
    Lead 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-436658

    #565274
    liorsade8

    ok thanks.
    will try.

    #565423
    Tom
    Lead Developer
    Lead Developer

    No problem ๐Ÿ™‚

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.