Awesome! Thanks for the quick reply!
function ao_js( $content ) {
$content .= str_replace( "</body>", "script type="text/javascript">ok</script></body>",$content );
return $content;
}
add_filter( 'autoptimize_html_after_minify', 'ao_js', 1 );
bro can you write easier code to add js below @@
<!-- Google Tag Manager -->
<script data-no-optimize="1" defer>
(function (w, d, s, l, i) {
w[l] = w[l] || []; w[l].push({
'gtm.start':
new Date().getTime(), event: 'gtm.js'
}); var f = d.getElementsByTagName(s)[0],
j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : ''; j.async = true; j.src =
'https://www.googletagmanager.com/gtm.js?id=' + i + dl; f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'dataLayer', 'GTM-P4RRabc');
</script>
<!-- End Google Tag Manager -->