Analytics counters (Google, Yandex)

Where can I insert the Yandex Metrics and Google Analytics counter codes so that they work on all pages of my website?

You can use layout container for this.
Website could have different layouts, but anyway this will not be significant quantity, usually only one or two are used, just do it for each of them.

ok thanks u so much