Hmm yes confusing
If it has to go immediately after the CLOSING
</head> tag, then thats easy by placing a HTML element, onto the body before anything else, and inserting the code there (make it a symbol so easy to put onto every page.
I have been putting it into the <head> bit right at the top (before the <meta charset="utf-8">
IE
<head>
><!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id="xxxxxxxxxxx "></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', ' xxxxxxx ');
</script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="generator" content="RSD 5.0.3541">
<meta name="description" content=" xxxxx ">
<title>xxxxxxxx</title
I have had it this way now since the start of the new GA4 (june 2023) and it works OK getting results information etc )
However the site hase been updated already and now needs that GA4 code putting back, I think I may try it after the </head> thingy, (before the <body> thingy on a testing website, to see if it still works with the code in that position, if so then happy as I can place it in a HTML element on the body on every page thereafter
Fingers crossed.