Google Tag Manager Issues

Hi support!

I am having an issue getting the Google Tag Manager BODY tag to read.
The URL of my website is www.hiretimothysolomon.com

Looking on the forum I found your solution to modify a child theme’s functions.php.
I’ve done that (you can find the code below).

The head tag works fine and I but the body does not.
When I inspect the page source I do find it near the top of the body tag.
But when I try to verify that tag manager is working ( with multiple Google tools ) it still tells me that body tag is not set correct.

In the source between the open body tag and the tag manager code is

> <body class="home page-template page-template-template-blank-4 page-template-template-blank-4-php page page-id-18 logged-in admin-bar no-customize-support x-integrity x-integrity-light x-full-width-layout-active x-content-sidebar-active x-navbar-fixed-top-active x-v5_1_0 x-child-theme-active cornerstone-v2_0_5">
>   <div id="x-root" class="x-root">
> <!-- Google Tag Manager (noscript) -->
> <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-NF79R5P"
> height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
> <!-- End Google Tag Manager (noscript) -->
>     <div id="top" class="site">

Could this be the issue? Is there away to but the tag manager code before this?

Below is my function.php

/ Add Google Tag Manager Code//

=============================================================================
/THIS CODE WILL BE OUTPUT INSIDE THE tag/
add_action(‘wp_head’,‘my_tracking’, 1);
function my_tracking () { ?>

<?php } function add_google_tag_manager_code(){ ?> <?php } add_action( 'x_before_site_begin', 'add_google_tag_manager_code' ); // End Add Google Tag Manager Code // =============================================================================

Hi There,

Could you please provide us with your admin account(by clicking the secure note button at the bottom) so we can take a closer look?

Thanks.

Login credentials attached

Hi There,

After viewed the sourced of your website, I could see the Google tag manager code(iframe):

Does that code need to be after the tag? Or the ID might be incorrect?

Thanks.

Code is correct.

Since Google recommend it goes as high as possible in the body tag
Is there a way to make to the google tag come before this <div id="x-root" class="x-root"> ?

Or maybe be able to try it after <div id="top" class="site"> ?

Hi There,

In this case, you have to copy this file x/framework/legacy/cranium/headers/views/global/_header.php to your child theme x-child/framework/legacy/cranium/headers/views/global/_header.php

Then add the google tag manager code after the body tag:

<?php

// =============================================================================
// VIEWS/GLOBAL/_HEADER.PHP
// -----------------------------------------------------------------------------
// Declares the DOCTYPE for the site and includes the <head>.
// =============================================================================

?>

<!DOCTYPE html>

<html class="no-js" <?php language_attributes(); ?>>

<head>
  <?php wp_head(); ?>
</head>

<body <?php body_class(); ?>>

	<!-- Google Tag Manager (noscript) -->
	<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXXX"
	height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
	<!-- End Google Tag Manager (noscript) -->

  <div id="x-root" class="x-root">

    <?php do_action( 'x_before_site_begin' ); ?>

    <div id="top" class="site">

    <?php do_action( 'x_after_site_begin' ); ?>

Hope it helps :slight_smile:

To confirm this is only for the body tag?

Hey There,

Yes you are correct. Once you have followed Thai’s suggestion, the Google Tag code will appear after the tag.

Please let us know how it goes.

This does not exist. Should I create it?

Can I do it like this?

x-child/framework/views/_header.php

This does not exist. Should I create it?

Yes, create a new one if it not existed.

Can I do it like this?

It must be like this: x-child/framework/legacy/cranium/headers/views/global/_header.php

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.