Google Tag Manager Not Working

Hey Guys,

From a previous post I asked how to add the google tag manager codes, followed all the instructions and the codes are within the website but when I checked using google tag assistant the codes are not working

Here is my website

Hi There @yokellocal

Thanks for writing in! There are couple of possible options to implement Google Tag Manager (GTM) on your site.

  1. Using a plugin: You can use one the following plugins for example (https://wordpress.org/plugins/duracelltomi-google-tag-manager/) or (https://wordpress.org/plugins/insert-headers-and-footers/).

  2. By implementing it on your child theme: First you will need to setup a child theme and activate it. You can follow our child theme setup guide here (https://theme.co/apex/forum/t/setup-how-to-setup-child-themes/57).

Then you will see that there are two parts that you will need to add it into your site.

  • A code for <head> of your site
  • Code immediately after the opening <body> tag

To implement the head part, you can add the following code into your child theme’s functions.php file and replace the following line
<!-- Replace this line with Google Tag Manager head code -->
with the code that you have received from Google.

function my_tag_manager_code_head() { ?>

<!-- Replace this line with Google Tag Manager head code -->


<?php }

add_action( 'wp_head', 'my_tag_manager_code_head' );

Then to implement body tag part, follow the instructions below.

Create file base.php in wp-content/themes/pro-child/framework/views/header/ and replace the following line
<!-- ADD THE TAG MANAGER CODE HERE -->
with the body code provided by Google.

<?php

// =============================================================================
// VIEWS/HEADER/BASE.PHP
// -----------------------------------------------------------------------------
// Declares the DOCTYPE for the site, includes the <head>, opens the <body>
// element as well as the .x-root <div> and .x-site <div>.
// =============================================================================

$x_root_atts = x_atts( apply_filters( 'x_root_atts', array( 'id' => 'x-root', 'class' => 'x-root' ) ) );
$x_site_atts = x_atts( apply_filters( 'x_site_atts', array( 'id' => 'x-site', 'class' => 'x-site site' ) ) );

?>

<!DOCTYPE html>

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

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

<body <?php body_class(); ?>>
<!-- ADD THE TAG MANAGER CODE HERE -->
  <div <?php echo $x_root_atts; ?>>

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

<div <?php echo $x_site_atts; ?>>

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

Add your goolge tag manager code after this line

<!-- ADD THE TAG MANAGER CODE HERE -->

Hope that helps.
Thanks!

hey @mldarshana

there’s no problem adding the codes the problem is getting it to work.

Used google assistant to check to see whether the codes are working or not.

But I did tried using the methods you’ve suggester but I can’t get the code to show up on the base.php file

Hi There @yokellocal

It seems to be a temporary caching issue. When I have checked your site, I can see your Google Tag Manager code added to the body part as well.

If you’re using a caching plugin, make sure to purge your server cache and also clear browser cache when testing for changes.

Thanks!

I tried everything you suggested.

Cleared and purged cache with WP Rocket and the tag assistant plugin still can’t find/detect the google tag manager code in the body area.

Hi @yokellocal

I’ve checked most of the tools described in this article:

And they all reported back that Google Tag Manager is working fine, check this screenshot from “Tag Assistant Extension”:

I still believe this is a caching related issue, try using any of these tools on different browsers or PCs.

Thanks.

Thanks @Alaa

You’re welcome.

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