タグの設置について

UserHeatという無料のWEB解析ソフトがあるのですが、それを使用する場合、フォームのページにJavascriptのタグを設置する必要があり、それが、</head>のまえに入れる必要があるということになっています。

サンプルとして下記のようなものです。

<!-- User Heat Tag –>
<script type=“text/javascript”>
(function(add, cla){window[‘UserHeatTag’]=cla;window[cla]=window[cla]||function(){(window[cla].q=window[cla].q||[]).push(arguments)},window[cla].l=1*new Date();var ul=document.createElement(‘script’);var tag = document.getElementsByTagName(‘script’)[0];ul.async=1;ul.src=add;tag.parentNode.insertBefore(ul,tag);})(‘//uh.nakanohito.jp/uhj2/uh.js’, ‘_uhtracker’);_uhtracker({id:'+********});
</script>
<!-- End User Heat Tag –>

このような場合は使用できますでしょうか。

できる場合、教えていただけますでしょうか。

よろしくお願いいたします。

林田大平様

お世話になっております。
cstapの江田と申します。

以下のコードで,headへのscriptの挿入は可能です.
ただし,解析ソフトが正しく動作するかは存じあげません.

(function () {
  "use strict";
  var script = document.createElement('script');
  script.innerText = "(function(add, cla){window['UserHeatTag']=cla;window[cla]=window[cla]||function(){(window[cla].q=window[cla].q||[]).push(arguments)},window[cla].l=1*new Date();var ul=document.createElement('script');var tag = document.getElementsByTagName('script')[0];ul.async=1;ul.src=add;tag.parentNode.insertBefore(ul,tag);})('//uh.nakanohito.jp/uhj2/uh.js', '_uhtracker');_uhtracker({id:'+ ********'});";
  document.head.appendChild(script);
})();

cstap 江田様

お世話になっております。

ご連絡ありがとうございます。

試してみます。

cstap 江田様

お世話になっております。

読み取れました。

ありがとうございました。