Add Custom Scripts to header

A lot of time we need to add Google Analytics/Tag manager scripts or some other scripts in the header section of our them.

The best way to do it by creating a function in your child theme folders functions.php file or setting it up as an independent plugin.

The code:

function add_custom_script_to_header() {
'< ? p h p' // without the quotes and spaces

// add your custom script provided by Google analytics/ Amazon/ or any other platform.

'< ? php '// without the quotes and spaces
add_action( 'wp_head', 'add_custom_script_to_header' );

That was it 🙂

Happy Coding!!

40total visits,7visits today