Adding google tag manager to xtheme with child

good day,

I want to make sure I add the google tag manger code in the right place… I’m thinking it should be placed in (theme functions) functions.php of the child… which is currently mostly empty. Can you please provide exactly what I need to paste to make this change… thanks for your continued support.
I need to add two codes.


Here is what I have now…

<?php // ============================================================================= // FUNCTIONS.PHP // ----------------------------------------------------------------------------- // Overwrite or add your own custom functions to X in this file. // ============================================================================= // ============================================================================= // TABLE OF CONTENTS // ----------------------------------------------------------------------------- // 01. Enqueue Parent Stylesheet // 02. Additional Functions // ============================================================================= // Enqueue Parent Stylesheet // ============================================================================= add_filter( 'x_enqueue_parent_stylesheet', '__return_true' ); // Additional Functions // =============================================================================

Hello Tim,

Thanks for writing in!

Please use the solution shared in following thread. Please replace <!-- Add the code here --> with the Google Tag manager code.

Thanks.

Ok then for the Body I would use this?

wp_Body’,‘custom_script’

can I update the functions.php file from here or do I need to FTP into it?

Hello Tim,

A quick option would be to add the code in that area of the admin section but it would be safer to add the code through FTP in case there will be errors.

Hope this helps.

what about this body code?

I’ve updated the head code and site is still working, will test functionality.

I can’t get the body code inserted… either I’m adding in the wrong place of using incorrect syntax. everytime I add it it kills the site… i’m doing this through FTP.
I don’t know where the opening body is?

Need to add this.

Hi Tim,

To add a code after <body> tag, one method is to follow this post (https://theme.co/apex/forum/t/google-tag-manager/5269/5?u=mldarshana). You can check our actions and filters guide here (https://theme.co/apex/forum/t/customizations-actions-and-filters-in-x-pro/208),

The other method is to copy the file _header.php file which is under wp-content/themes/x/framework/legacy/cranium/headers/views/global/ into your child theme’s respective location as follows.
/x-child/framework/legacy/cranium/headers/views/global/

Then you can implement your code as follows.

<body <?php body_class(); ?>>
<!-- ADD THE TAG MANAGER CODE HERE -->
  <?php do_action( 'x_after_body_begin' ); ?>

Hope that helps.

Used this one.
(https://theme.co/apex/forum/t/google-tag-manager/5269/5?u=mldarshana).

Worked great… thanks much for the support

You’re welcome!
We’re glad we were able to help you out.

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