Matomo: script in header

I am installing Matomo for a friend’s website. The database has been set up. The instructions state:

Make sure this code is on every page of your website. We recommend pasting it immediately before the closing tag.

… I know where the “head” section is in the sidebar area of each page. What I’m not sure about is what they mean by “immediately before the closing tag”. I’m assuming it means if there is other code in this area to make sure the script they provide is that last thing in that area. But I’m not 100% sure. Is there possible somewhere else I should be putting this code?

Matomo provides analytics. As they state on their webpage: " Google Analytics alternative that protects your data and your customers’ privacy. Take back control with Matomo – a powerful web analytics platform that gives you 100% data ownership."

RW doesn’t allow inserting at the end of the head code area, although it has been requested many times.

The Matamo code should however, work using the RW Code Head area. In an ideal world Matamo would like to to make their code the last thing in the head area, to be sure than nothing that comes after it, interferes with the Matamo code.

He’s right, I use Matomo on most sites, just stick it into the global head section and you’ll be good.

If you want to stick it behind a cookie consent, I do that using Privacy Centre.

@Webdeersign and @TemplateRepo Thanks to both of you! That’s what I’ve done and all is working well with Matomo. I “guessed” I should be doing as both of your wrote, but great to have your confirmation!