Inject Tracking Code with a Plugin in WordPress

Inject Tracking Code with a Plugin in WordPress

Plugin

My Custom Functions

Simply put, the code injected with the plugin will be appended to functions.php

Code

// Below code will add <script> with wp_head hook to relative location
function analytics_code()
{  
	?>
      
        <script> 
          // JS tracing code block
        </script> 

    <?php
}

add_action("wp_head","analytics_code");