The following code is to be inserted in checkout.liquid immediately before {{ checkout_scripts }}


<!-- Google Tag Manager App Start -->
    <script>
if (window.location.href.includes('thank_you') !== true) { 
var Shopify = [];
      Shopify["shop"] = "{{ shop.permanent_domain }}";
function loadjQuery(url, success){
     var script = document.createElement('script');
     script.src = url;
     var head = document.getElementsByTagName('head')[0],
     done = false;
     head.appendChild(script);
    
script.onload = script.onreadystatechange = function() {
    if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) {
         done = true;
         success();
         script.onload = script.onreadystatechange = null;
         head.removeChild(script);        
    }
};
}

if (typeof jQuery == 'undefined'){

loadjQuery('https://code.jquery.com/jquery-1.10.2.min.js', function() {
jQuery('head').append('<script src="https:\/\/gtmniddocks.herokuapp.com\/gtmniddocks.js?shop={{ shop.permanent_domain }}"><\/script>');
      });

 } else {
jQuery('head').append('<script src="https:\/\/gtmniddocks.herokuapp.com\/gtmniddocks.js?shop={{ shop.permanent_domain }}"><\/script>');

 }
}
</script>
 <!-- Google Tag Manager App End -->