Add script between tag <head> and tag </head>

Hi, I need to insert this script onto my website, where I’ve to insert it?

script type=“text/javascript”>
window.smartlook||(function(d) {
var o=smartlook=function(){ o.api.push(arguments)},h=d.getElementsByTagName(‘head’)[0];
var c=d.createElement(‘script’);o.api=new Array();c.async=true;c.type=‘text/javascript’;
c.charset=‘utf-8’;c.src=‘https://rec.smartlook.com/recorder.js’;h.appendChild©;
})(document);
smartlook(‘init’, ‘c9abfb5e08d57f88ed7fc6db466d84edc458f987’);
</script

Thanks in advance

Smartlook provide advice on how to do this on their website: https://www.smartlook.com/help/wordpress/.

It’s advisable to follow their implementation advice. However, if you want to do it yourself, a simple function to insert this code into your header is below. Simply past this function into the functions.php of your child theme. Alternatively, there a numerous plugins that allow you to ‘inject’ code into your header.

Example function:

add_action( 'wp_head', 'my_custom_head_output', 99999 );
function my_custom_head_output() {
  ?>
    <!---- YOUR CODE HERE ----!>
  <?php
}
3 Likes

Thank you very much @mikeshudson

Glad to hear it’s sorted.

Thanks for helping out, @mikeshudson.

1 Like