// Add Google Tag Manager Code after opening body tag
add_action( 'wp_body_open', function() { ?>
YOUR CODE HERE
<?php } );
Snippets: How To Properly Add Google Tag Manager Code
All PHP snippets should be added via a child theme's functions.php file or via the Code Snippets Plugin (or alternative plugin)