Skip to content

Instantly share code, notes, and snippets.

@endurtech
Created September 19, 2022 20:42
Show Gist options
  • Save endurtech/5100a4d4807a144f78f45ec95702df3e to your computer and use it in GitHub Desktop.
Save endurtech/5100a4d4807a144f78f45ec95702df3e to your computer and use it in GitHub Desktop.
Insert this code into the functions.php file within your WordPress Avada child-theme to inject any custom code into the beginning portion of your WordPress website just after the opening <body> tag.
<?php
// Inserting a Script into Start of WordPress Avada Theme Body
// https://endurtech.com/insert-script-into-wordpress-body/
add_action( 'avada_before_body_content', 'GA4TAGMGR' );
function GA4TAGMGR()
{
echo '<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-YOURMEASURMENTIDHERE" height="0" width="0" style="display:none;visibility:hidden;"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment