Need to add GTM code right after the <body> tag

Dear support,

I’ve received support for this on the previous forum for another project i was working on, but i cant find the thread from the old forum anymore.
I need to add a piece of code at the begining of the body RIGHT AFTER tag.

Adding that from functions.php wont work as the code will appear after some other code.
The solution i was given last time was to tweak something on the backend. Some base php file i guess.

Can you please let me know how to do that again ?
Im using PRO btw !

Thanks in advance

Hi There,

Please add the following code under functions.php file locates in your child theme:

add_action( 'x_before_site_begin', 'print_script_before_site_begin' );
function print_script_before_site_begin(){
	?>	
	<!-- Google Tag Manager Code Will Go Here -->
	<?php
}

Hope it helps :slight_smile:

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