Google recommend your Tag Manager code is added immediately after the opening <body> tag. To do this in Studiopress’s Genesis theme you can use the ‘genesis_before’ hook, and set the priority to “1” to ensure that your function runs before anything else that’s hooked on to ‘genesis_before’:

To do this you can place this code at the bottom of your child themes function.php file – including your Google Tag Manager code.

// Add Google Tag Manager code after opening body tag

add_action(‘genesis_before’, ‘output_google_tags’, 1);

function output_google_tags(){
?&gt;
&lt;!— Your Google Tag Manager code goes here —&gt;
&lt;?php
}

Thanks to Connie from Studiopress for this!

Leave a Comment