Great news for WordPress developers – WordPress now has a theme action hook to put code immediately after the <body> tag! The new tag was included in WordPress 5.2 in May 2019, and is slowly being adopted by theme developers (e.g. It was added to Beaver Builder Theme in April 2020 – screengrab below).

No more having to hack your theme to put Google Tag Manager or other scripts in the <body> section of your website! Just use an action hook in either functions.php or your functional plugin like so:

// Add code just after <body> tag
function custom_content_after_body_open_tag() {
    <script>Custom script here</script
add_action('wp_body_open', 'custom_content_after_body_open_tag');

Is this helpful?