Integrate Google Tag Manager

Hi Themeco

I’m trying to integrate Google Tag Manager on my site and I would like to do it without installing yet another plugin - can you help me/guide me to do it correctly? I have a Tag Manager tracking Code for both header and body.

My website is

Looking forward to hearing.


Hi There,

Upon checking your website I could see that you’ve already installed and activated the child theme.

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

add_action( 'wp_head', 'print_google_tagmanager_script', 999 );
function print_google_tagmanager_script(){
<!-- Google Tag Manager -->
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
<!-- End Google Tag Manager -->

add_action( 'x_before_site_begin', 'print_script_before_site_begin' );
function print_script_before_site_begin(){
	<!-- Google Tag Manager (noscript) -->
	<noscript><iframe src="//"
height="0" width="0" style="display:none;visibility:hidden"></noscript>
	<!-- End Google Tag Manager (noscript) -->

Let us know how it goes!

1 Like

Thanks for your reply.

Like this?

After the Additional Functions should be better.


Thanks, I’ll do that

Let us know how it goes!

It works for me!

Glad that it worked for you :slight_smile:

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