Google Tag

Hi there,
I want to confirm if this is still today the way to do it: (Is there any update)

Thanks for writing in! First of all, make sure that you have setup a child theme correctly and activate it by following our guide here (https://theme.co/apex/forum/t/setup-how-to-setup-child-themes/572).

Then you will see that there are two parts, which you will need to implement accordingly.

A code for of your site
Code immediately after the opening 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

with the code that you have received from Google.

function my_tag_manager_code_head() { ?>

<?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 with the body code provided by Google. <?php // ============================================================================= // VIEWS/HEADER/BASE.PHP // ----------------------------------------------------------------------------- // Declares the DOCTYPE for the site, includes the , opens the // element as well as the .x-root
and .x-site
. // ============================================================================= $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' ) ) ); ?> > <?php wp_head(); ?> >
>
<?php do_action( 'x_before_site_begin' ); ?>
> <?php do_action( 'x_after_site_begin' ); ?>

Add your goolge tag manager code after this line

Hi Iban, this should still work.

Is there a better way in PRO THEME?

Hi Iban,

You mean without the need for coding? If so, unfortunately, we don’t have our own plugin for that. We do have a Google Analytics plugin which is developed in-house but it’s only for adding Google Analytics code and not GTM.

That said, this is a nice feature to have in the future. I will suggest this to the development team but this does not guarantee it will be implemented because as a company, we like to maintain focus.

You might want to look at third-party plugins that are focused on doing this.

Hope this helps.

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