Latest method for adding tag manager

I have added some of the code using the php functions method but not sure of the other half what is the latest method ?

Hi there,

Thanks for writing in! You can setup a child theme (refer knowledge base section) first and then add the following codes into your child theme’s functions.php file.

To add anything into your WP Header section.

// Add Google Tag Manager Code in Head
// =============================================================================
function my_custom_code1(){
?>

<?php } add_action( 'wp_head', 'my_custom_code1' ); To add a code after body tag. // Add Google Tag Manager Code in Body // ============================================================================= function my_custom_code2(){ ?> <?php } add_action( 'x_before_site_begin', 'my_custom_code2' ); Hope that helps.

Hi @wicara,

That code will still work.

wp_head is a standard hook by wordpress

https://codex.wordpress.org/Function_Reference/wp_head

and x_before_site_begin is a standard hook of the theme

https://theme.co/apex/forum/t/customizations-actions-and-filters-in-x/208

Thanks

I tried the code and it does not seem to have worked, I also tried verifying other components via tag manager and it did not work

Hi @wicara,

I checked your site source code and can see the codes being added.

Please double check your google tag code and make sure it’s correct.

Thanks

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