Implementing Google Analytics

Could anybody give me a real example on how to implement google analytics on my studio projects? I used to add the code on the header without problem before, but now it seems I have to add it through code, as a document.head.insertAdjacentHTML or the like, but this is not working, I have tried a lot of ways and it just doesn’t connect to my google analytics. I also tried tag manager and nothing.

Would be really helpful if this was addressed on the new docs just like legacy web editor